Dear all,
I am trying to code a strategy with parameters as below:
- Assumption: The range (or box) created with both “highest” and “lowest” in the period 00h00 – 06h00 (London Time) is supposed to be filled during western sessions (London, NY).
- Ordering: BUY: Price crosses over the “lowest” of the range / BUY EXIT: Price = “highest” of the range / SELL: Price crosses under the “lowest” of the range / SELL EXIT: Price = “lowest” of the range.
- Frequency: Each day, only 1 possibilty: BUY or SELL or no trade (no trade if the price don’t need liquidity on support/resistance-levels created by the range and moves linearly up- or downside).
- Scope of Use: Forex-Main Currencies, excepted the most active ones during the range (JPY, AUD, NZD) – To be checked!
Based on a Nicolas Video (“How to create a breakout box between 2 hours” – (67) How to create a breakout box between 2 hours – ProRealTime – YouTube), I have tried to build an indicator and also an auto-trading-code (see below), but I am not satisfied with both of them.
I would be very thankful for each help and would share with you the afterwards optimization of this strategy (for example, by adding a stochastic or price-action-parameters).
Thanks & Regards
INDICATOR:
if intradaybarindex=0 then
maxprice = 0
minprice = close*100
endif
tcondition = time >= 010000 and time <= 070000
if tcondition then
maxprice = max(maxprice, high)
minprice = min(minprice, low)
endif
return maxprice, minprice
AUTO-TRADING:
// Festlegen der Code-Parameter
DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
IF Time = 070000 then
HAUT = highest[6](high)
BAS = lowest[6](low)
endif
AMPLITUDE = abs(haut - bas)
c3 = (close CROSSES under haut)
c4 = (close CROSSES over bas)
IF not longonmarket and c4 THEN
BUY 1 contract AT MARKET
ENDIF
IF not shortonmarket and c3 THEN
sellshort 1 contract AT MARKET
ENDIF
SET STOP PLOSS 20
set target profit = amplitude
The code seems right to me, just change the last line and add GRAPHONPRICE to visualize the levels:
// Festlegen der Code-Parameter
DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
IF Time = 070000 then
HAUT = highest[6](high)
BAS = lowest[6](low)
endif
AMPLITUDE = abs(haut - bas)
c3 = (close CROSSES under haut)
c4 = (close CROSSES over bas)
IF not longonmarket and c4 THEN
BUY 1 contract AT MARKET
ENDIF
IF not shortonmarket and c3 THEN
sellshort 1 contract AT MARKET
ENDIF
SET STOP PLOSS 20
set target profit amplitude
graphonprice haut
graphonprice bas