Strategy: Friday Bond Short Strategy (1H Timeframe)
Objective: This strategy aims to open short positions on a specified day and hour (Eastern Time) and close those positions on another specified day and hour. The background color of the chart will turn green when a position is active, providing a visual cue of an open trade.
Parameters:
1. Entry Day: • Defines the day of the week on which the short position will be opened. • Value: 6 for Friday (Pine Script’s weekday numbering: Monday = 2, Friday = 6). 2. Entry Hour: • Specifies the hour (Eastern Time) when the short position will be opened. • Value: 13 for 13:00 ET (1:00 PM). 3. Exit Day: • Defines the day of the week on which the short position will be closed. • Value: 2 for Monday. 4. Exit Hour: • Specifies the hour (Eastern Time) when the position will be closed. • Value: 13 for 13:00 ET (1:00 PM).
How It Works:
1. Time Adjustment to Eastern Time: • The script converts all time references to Eastern Time (America/New_York) to ensure the strategy operates according to the desired time zone. 2. Entry Conditions: • The strategy checks if the current day of the week matches the specified entry_day and if the current hour matches the specified entry_hour. • If both conditions are met, a short position is opened (strategy.entry("Short", strategy.short)). 3. Exit Conditions: • Similarly, the strategy checks if the current day of the week matches the specified exit_day and if the current hour matches the specified exit_hour. • If both conditions are met, the open short position is closed (strategy.close("Short")). 4. Background Color: • The background color of the chart is adjusted based on whether there is an open position: • Green Background: If the strategy has an open position (strategy.position_size > 0), the background is set to light green. • No Background Color: If there is no open position, the background color is not set (na).
Summary:
The Friday Bond Short Strategy is designed to enter short positions on Fridays at 1:00 PM ET and close them on Mondays at 1:00 PM ET. The chart background color turns green when a short position is active, providing a clear visual indication of when the strategy is engaged in a trade.
Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.