Job finished
Specification
Strategy Specification for BTCUSD
Platform MT4
Input Variables
| Variable Name | Format | Description |
|---|---|---|
| Trade_Time | hh:mm | Time to place pending orders |
| Start_Time | hh:mm | Start of range detection window |
| End_Time | hh:mm | End of range detection window |
| Gap_Divider | int | Divides the range (Gap) to calculate Buffer |
| Risk_Per_Trade | double | Risk per trade in USD |
| TP_Factor | double | Multiplier for Take Profit distance |
| SL_Factor | double | Multiplier for Stop Loss distance |
| Expiry_Time_Hours_From_Now | double | How long to keep the pending orders before expiry |
| Cleanup_X_Min_Before | int | Minutes before next day’s Trade_Time to force close open trades |
EA Logic
1. Daily Setup Time
-
At Trade_Time , the EA will execute its logic.
2. Range Detection
-
Between Start_Time and End_Time (the window that has just passed):
-
Detect:
-
Max_Price = Highest price in this range
-
Min_Price = Lowest price in this range
-
-
These are calculated by the EA.
-
Display on the chart:
-
Max_Price
-
Min_Price
-
-
3. Gap and Buffer Calculation
-
Calculate:
-
Gap = Max_Price - Min_Price
-
Buffer = Gap / Gap_Divider
-
-
Display on the chart:
-
Gap
-
Buffer
-
4. Risk and Trade Parameters
-
Calculate:
-
Lot_Size = (Risk_Per_Trade × SL_Factor) / Gap
-
-
Display on the chart:
-
Lot_Size
-
TP_Factor
-
SL_Factor
-
Expiry_Time_Hours_From_Now
-
5. Pending Orders at Trade_Time
-
Buy Stop:
-
Entry: Max_Price + Buffer
-
TP = TP_Factor × Gap (measured from Max_Price, not opening price )
-
SL = SL_Factor × Gap (measured from Max_Price, not opening price)
-
Lot_Size as calculated
-
Set expiry to Expiry_Time_Hours_From_Now
-
If triggered and still open, close it Cleanup_X_Min_Before minutes before next day’s Trade_Time
-
Sell Stop:
-
Entry: Min_Price - Buffer
-
TP = TP_Factor × Gap (measured from Min_Price, not opening price)
-
SL = SL_Factor × Gap (measured from Min_Price, not opening price)
-
Lot_Size as calculated
-
Set expiry based on Expiry_Time_Hours_From__Opening
-
If triggered and still open, close it Cleanup_X_Min_Before minutes before next day’s Trade_Time
The following variables and their values should be displayed on the chart window. Text colour must be changeable by the user.
-
Gap
-
Buffer
-
Lot_Size
-
TP_Factor
-
SL_Factor
-
Expiry_Time_Hours_From_Opening
-
Cleanup_X_Min_Before
6. Cleanup
-
Once both trades and pending orders are closed:
-
Remove all chart objects/text related to:
-
Gap
-
Buffer
-
Lot_Size
-
TP_Factor
-
SL_Factor
-
Expiry_Time_Hours_From_Now
-
Cleanup_X_Min_Before
-
-