gggoaaat

Power Hour Money Strategy

gggoaaat 已更新   
Description of the Pine Script Code: "Power Hour Money Strategy"

This Pine Script strategy, "Power Hour Money Strategy," is designed to trade based on the alignment of multiple time frames (month, week, day, and hour). The strategy aims to enter long or short positions depending on whether all selected time frames are in sync (all green for long positions, all red for short positions). Additionally, the script includes configurations for trading during specific sessions and automatically closing positions at the end of the trading day.

Core Features:

1. Time Frame Sync Check:
- The strategy evaluates whether the current price is higher than the opening price for the month, week, day, and hour to determine if each time frame is "green" (bullish) or "red" (bearish).

2. Session Control:
- The user can select between different trading sessions:
- "NY Session 9:30-11:30"
- "Extended NY Session 8-4"
- "All Sessions"
- Trades are only executed if the current time falls within the selected session.

3. Trailing Stop Mechanism:
- The strategy includes an optional trailing stop mechanism for both long and short positions.
- The trailing stop is configured with a percentage loss from the current price to protect gains.

4. End-of-Day Position Management:
- An option is provided to automatically close all positions at the end of the trading day (5:45 PM Eastern Time).

Detailed Code Breakdown:

1. Input Settings:
- **Session Selection**: Allows the user to choose the trading session.
- **End-of-Day Close**: Option to automatically close positions at the end of the day.
- **Trailing Stop Loss**: Enables or disables the trailing stop loss feature and sets the percentage for long and short positions.

2. Time Frame Calculations:
- The script uses `request.security` to get the opening prices for higher time frames (monthly, weekly, daily, and hourly).
- It compares the current close price to these opening prices to determine if each time frame is green or red.

3. Session Time Definitions:
- Defines the start and end times for the NY session (9:30-11:30 AM) and the extended session (8:00 AM - 4:00 PM).

4. Trade Execution:
- The strategy checks if all selected time frames are in sync and if the current time falls within the trading session.
- If all conditions are met, it enters a long or short position.

5. Trailing Stop Loss Implementation:
- Adjusts the stop price based on the trailing percentage and the current position's size.
- Automatically exits positions if the trailing stop condition is met.

6. End-of-Day Close Implementation:
- Uses a timestamp to check if the current time is 5:45 PM Eastern Time.
- Closes all positions if the end-of-day condition is met.

7. Plotting and Logging:
- Plots indicators to visualize the green/red status of each time frame.
- Logs information about the status of each time frame for debugging and analysis.

Example Usage:
  1. Entering a Long Position: If the month, week, day, and hour are all green and the current time is within the selected session, a long position is entered.
  2. Entering a Short Position: If the month, week, day, and hour are all red and the current time is within the selected session, a short position is entered.
  3. Trailing Stop: Protects gains by exiting the position if the price moves against the set trailing stop percentage.
  4. End-of-Day Close: Automatically closes all open positions at 5:45 PM Eastern Time if enabled.

This strategy is particularly useful for traders who want to ensure that multiple time frames are in alignment before entering a trade and who wish to manage positions effectively throughout the trading day with specific session controls and trailing stops.
版本注释:
  1. Minor update. Removed irrelevant price scale.
版本注释:
  1. Minor Update. Changed Default Settings.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?