OPEN-SOURCE SCRIPT

Power Hour Money Strategy

ที่อัปเดต:
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.
เอกสารเผยแพร่

  1. Only triggers strategy alert on confirmed bar
  2. New Alert for unconfirmed bar
alignmentgggoaaatmultitimeframetimeframeTrend Analysis

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ