MarcParticipant
Average
Hi together,
here is another system which works like bullish / bearish harami pattern.
In the End for a long position 3 lower highs and lower lows have to follow immediately. Close of current candle must be higher than open if first candle is bearish or close of current candle must be higher if first candle is bullish. TP is high of first candle.
For Short vice versa.
Perhaps somebody can check if this code seems to be okay?
DEFPARAM CumulateOrders = False
//Buy-Condition l1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze muss größer sein als der Schlusskurs der ersten Kerze
l1 = OPEN[3] < CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Close[3]
//Buy-Condition l2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze ist größer als das Open der ersten Kerze
l2 = OPEN[3] > CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Open[3]
//Sell-Condition s1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit höheren Hochs und höheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
s1 = OPEN[3] < CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Close[3]
//Sell-Condition s2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit höheren hoch und hheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
s2 =OPEN[3] > CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Open[3]
//Kauforder zur Eröffnung der nächsten Kerze wenn Konditionen l1 oder l2 erfüllt sind
IF l1 OR l2 THEN
BUY 1 SHARES AT MARKET NextBarOpen
ENDIF
//Verkauforder zur Eröffnung der nächsten Kerze wenn Konditionen s1 oder s2 erfüllt sind
IF s1 OR s2 THEN
SELLSHORT 1 SHARE AT MARKET NextBarOpen
ENDIF
//TP und SL-Definition
SET TARGET %Profit 1
SET STOP %Loss 1
That seems good. They are rare patterns, but the code works!
On Eur/Usd, daily, I could find just one occurrence of L1 (line 4) in a few years!
MarcParticipant
Average
Great 🙂
Can you t ell me how I can set or implement TP on High of Candle 1 and SL on Low of candle 3 (for Long trades) and vice versa for short?
Mille Grazie
Marc
//For LONG trades:
SET STOP LOSS (close – low[3]) //difference betwee current price and LOW of candle 3
SET TARGET PROFIT (high[1] – close) //difference between the HIGH of candle 1 and current price (a lower current price is assumed)
//For SHORT trades:
SET STOP LOSS (high[3] – close) //difference betwee current price and HIGHof candle 3
SET TARGET PROFIT (close – low[1]) //difference between the LOW of candle 1 and current price (a higher current price is assumed)
MarcParticipant
Average
Hi Roberto,
agein I’d like to thank you.
Is this correct?
DEFPARAM CumulateOrders = true
//Buy-Condition l1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze muss größer sein als der Schlusskurs der ersten Kerze
l1 = OPEN[3] < CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Close[3]
//Buy-Condition l2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze ist größer als das Open der ersten Kerze
l2 = OPEN[3] > CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Open[3]
//Sell-Condition s1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit höheren Hochs und höheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
s1 = OPEN[3] < CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Close[3]
//Sell-Condition s2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit höheren hoch und hheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
s2 =OPEN[3] > CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Open[3]
//Kauforder zur Eröffnung der nächsten Kerze wenn Konditionen l1 oder l2 erfüllt sind
IF l1 OR l2 THEN
BUY 1 SHARES AT MARKET NextBarOpen
ENDIF
//Verkauforder zur Eröffnung der nächsten Kerze wenn Konditionen s1 oder s2 erfüllt sind
IF s1 OR s2 THEN
SELLSHORT 1 SHARE AT MARKET NextBarOpen
ENDIF
//For LONG trades:
IF LongOnMarket THEN
SET STOP LOSS (close - low[3]) //difference betwee current price and LOW of candle 3
SET TARGET PROFIT (high[1] - close) //difference between the HIGH of candle 1 and current price (a lower current price is assumed)
EndIF
//For SHORT trades:
IF ShortOnMarket THEN
SET STOP LOSS (high[3] - close) //difference betwee current price and HIGHof candle 3
SET TARGET PROFIT (close - low[1]) //difference between the LOW of candle 1 and current price (a higher current price is assumed)
EndIf
Yes, it is correct. Good job!
MarcParticipant
Average
Ciao Roberto
thank you very much for your feedback.
Is there a possibility to exclude sundaycandles? When testing this strategy with IG I get other results than using the demo. Perhaps the reason is the tickbytick data…?
Rgds
Marc
You should always use tick-by-tick option, to get correct results, especially on higher TFs.
As for sunday and weekend data, NO you cannot! You can exclude them from being displayed but they are still there and indicators will use them.
If your strategy has SET instructions or LIMIT or STOP instructions in it (which yours does) then you must test with tick by tick data turned on. If however your strategy does not have these and does all its trading at candle close/open then you do not need it turned on and you will then have the benefit of far more data to test on as tick by tick data is only available back to a certain date.
MarcParticipant
Average
I think SL and TP should be amended…
When I’m Long:
SL is Low of candle before entry and TP is High of 3 candles before entry
When I’m Short:
SL is High of candle before entry and TP is Low of 3 candles before entry
Pls find example attached
You agree with below Marc?
I’ll try below on my copy, I was expecting better performance and below may be what it needs?
Edit / PS – Still doesn’t look good? What are you getting, what is intended market and TF?
IF LongonMarket THEN
SET STOP LOSS (Close - Low[1])
SET TARGET PROFIT (High[3] - Close)
EndIf
IF ShortOnMarket THEN
SET STOP LOSS (High[1] - Close)
SET TARGET PROFIT (Close - Low[3])
EndIf
I want to outline that Marc‘s code to deal with SL & TP will only work fron the 2nd candle on, since SET are not written after BUY/SELLSHORT, but only after detecting it’s ONMARKET (either long or short), which takes one whole candle to ProOrder to become aware of it! Not having a TP & SL for one candle is not a big problem for 1-minute charts, but for daily charts….. it could be an awful surprise!
Thank you Roberto.
I think the exit strategy needs work anyway as I changed to below and got attached far better results with the values shown on attached.
IF LongonMarket THEN
//SET STOP LOSS (Close - Low[1])
//SET TARGET PROFIT (High[3] - Close)
SET TARGET PPROFIT A
SET STOP PLOSS B
EndIf
IF ShortOnMarket THEN
//SET STOP LOSS (High[1] - Close)
//SET TARGET PROFIT (Close - Low[3])
SET TARGET PPROFIT C
SET STOP PLOSS D
EndIf
What values did you assign to A, B, C and D?
What values did you assign to A, B, C and D?
I’m guessing 40 60 25 and 120.
[attachment file=76950]