Consecutive bullish or bearish candlesticks – DAX
Forums › ProRealTime English forum › ProOrder support › Consecutive bullish or bearish candlesticks – DAX
- This topic has 26 replies, 6 voices, and was last updated 6 years ago by mcosta.
-
-
01/18/2018 at 5:39 PM #59824
I ran this code since 7 Dec 2017 (as a test phase on demo account before going live with it) and so far it has delivered £959. Just over a month.
1 minute time frame with 2 mini contracts.The main reason I add this is becuse may be someone can some changes or even test it yourself and use it as is.
I have other ones on the same basis where I added TS and MFE (also Sir. Nicolas’s code). These are still in testing phase though.I have tested with various options/variables on various Indices and forex pairs over months.
Because of the variables this code can apply to any forex or Indice on any timeframe. Anything from 10sec to 4hour. You just have to find your own sweet spot that applies to you.This code will check for 4 (in this case) consecutive bullish or bearish candlesticks.
After that the variables apply – Inverse trading and Cumulate orders.
In this case it will open position in the same direction as the candles/trend. (InverseTrading = 0) and will cumulate orders (CumulateOrder = 1)DAX - 1min - multiple candle123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293//-------------------------------------------------------------------------//PRC_TS multiple candlesticks | indicator//01.03.2017//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//This is not my code.//Original code was written and published by Sir.Nicolas//-------------------------------------------------------------------------// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 070000 //UTC +2timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 190000 //UTC +2timeEnterAfter = time < noEntryAfterTime// --- parametersSize = 2 //position sizeStopLoss = 40 //stoploss in pointsTakeProfit = 20 //takeprofit in pointsXcandlesticks = 4 //consecutive bullish or bearish candlesticks to open a new positionInverseTrading = 0 //(0=false ; 1=true) trade in the same direction of the candlesticks pattern or notCumulateOrder = 1 //(0=false ; 1=true) cumulate or not a new trade if the current candlestick is in the same trend as the pattern// ------------//detecting patternsbearpattern = summation[Xcandlesticks](close<open)=Xcandlesticksbullishpattern = summation[Xcandlesticks](close>open)=Xcandlesticks//first orderif not onmarket and timeEnterBefore and timeEnterAfter thenif bearpattern thenif InverseTrading thenBUY Size CONTRACTS AT MARKETelseSELLSHORT Size CONTRACT AT MARKETendiflastbar = barindexlastpattern = -1endifif bullishpattern thenif InverseTrading thenSELLSHORT Size CONTRACT AT MARKETelseBUY Size CONTRACTS AT MARKETendiflastbar = barindexlastpattern = 1endifendif//cumulate order when a new pattern occurredif onmarket and timeEnterBefore and timeEnterAfter and not CumulateOrder and barindex-lastbar>=Xcandlesticks thenif bearpattern thenif InverseTrading thenBUY Size CONTRACTS AT MARKETelseSELLSHORT Size CONTRACT AT MARKETendiflastbar = barindexendifif bullishpattern thenif InverseTrading thenSELLSHORT Size CONTRACT AT MARKETelseBUY Size CONTRACTS AT MARKETendiflastbar = barindexendifendif//cumulate order when a new consecutive candletick happen right after the pattern occurredif onmarket and timeEnterBefore and timeEnterAfter and CumulateOrder and barindex-lastbar=1 thenif longonmarket thenif (close>open and lastpattern=1) or (close<open and lastpattern=-1) thenBUY Size CONTRACTS AT MARKETlastbar = barindexendifendifif shortonmarket thenif (close>open and lastpattern=1) or (close<open and lastpattern=-1) thenSELLSHORT Size CONTRACT AT MARKETlastbar = barindexendifendifendifSET STOP PLOSS StopLossSET TARGET PPROFIT TakeProfit//ENDMay be someone can some changes or even test it yourself and use it as is.
I have tested the various options/variables on various Indices and forex pairs over months.
Because of the variables this code can apply to any forex or Indice on any timeframe. Anything from 10sec to 4hour. You just have to find your own sweet sport that applies to you.This code will check for 4 (in this case) consecutive bullish or bearish candlesticks.
After that the variables apply – Inverse trading and Cumulate orders.
In this case it will open position in the same direction as the candles/trend. (InverseTrading = 0) and will cumulate orders (CumulateOrder = 1)1 user thanked author for this post.
01/19/2018 at 8:44 PM #5992001/19/2018 at 8:57 PM #59924Hi Yannick
I got similar to you! I tried it on several instruments and several time frames, gave up in the end … unusual for me as I like a challenge!
Looks like some good code in the Strat, hope somebody gets it going!? 🙁
GraHal
01/23/2018 at 6:31 AM #60242I dont know why you would get different results.
May be leave it at the times I put in UTC+2
The results I posted is the code that ran on demo account and not backtest results.1 user thanked author for this post.
01/23/2018 at 11:25 AM #6030901/23/2018 at 7:59 PM #60344Hi
Thanks @Andre Vorster
Could share the graph or trade opened and strategy performance (evolution of equity versus time)?
Regards
01/24/2018 at 6:59 AM #60361Yannick.
I’m not sure I understand your question correct.
Can you please elbaborate.01/24/2018 at 7:46 PM #6044301/24/2018 at 9:09 PM #60446Please accept my apologies Andre for earlier comments.
I backtested your Strat over same period as you ran it in Demo and I got good results … about twice as good as yours! 🙂 I left the Times in UTC +2 (I’m UTC / GMT). See attached.
I’ll check it out more now.
Thank You
GraHal01/24/2018 at 11:25 PM #60455I haven’t studied / understood the code (got one eye on the TV! 🙂 ) but I noted the poor performance during a flat period so I added conditions re EMA as shown below.
Results improved to the upper equity curve attached.
GraHal
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293//https://www.prorealcode.com/topic/consecutive-bullish-or-bearish-candlesticks-dax/-------------------------------------------------------------------------//PRC_TS multiple candlesticks | indicator//01.03.2017//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//This is not my code.//Original code was written and published by Sir.Nicolas//-------------------------------------------------------------------------// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 070000//070000 //UTC +2timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 190000//190000 //UTC +2timeEnterAfter = time < noEntryAfterTime// --- parametersSize = 2 //position sizeStopLoss = 40 //stoploss in pointsTakeProfit = 20 //takeprofit in pointsXcandlesticks = 4 //consecutive bullish or bearish candlesticks to open a new positionInverseTrading = 0 //(0=false ; 1=true) trade in the same direction of the candlesticks pattern or notCumulateOrder = 1 //(0=false ; 1=true) cumulate or not a new trade if the current candlestick is in the same trend as the pattern// ------------//detecting patternsbearpattern = summation[Xcandlesticks](close<open)=Xcandlesticksbullishpattern = summation[Xcandlesticks](close>open)=Xcandlesticks//first orderif not onmarket and timeEnterBefore and timeEnterAfter thenif bearpattern and Close < ExponentialAverage[200](close)thenif InverseTrading and Close < ExponentialAverage[100](close) thenBUY Size CONTRACTS AT MARKETelseSELLSHORT Size CONTRACT AT MARKETendiflastbar = barindexlastpattern = -1endifif bullishpattern and Close > ExponentialAverage[175](close) thenif InverseTrading and Close > ExponentialAverage[100](close) thenSELLSHORT Size CONTRACT AT MARKETelseBUY Size CONTRACTS AT MARKETendiflastbar = barindexlastpattern = 1endifendif//cumulate order when a new pattern occurredif onmarket and timeEnterBefore and timeEnterAfter and not CumulateOrder and barindex-lastbar>=Xcandlesticks thenif bearpattern and Close < ExponentialAverage[100](close) thenif InverseTrading and Close < ExponentialAverage[100](close) thenBUY Size CONTRACTS AT MARKETelseSELLSHORT Size CONTRACT AT MARKETendiflastbar = barindexendifif bullishpattern and Close > ExponentialAverage[175](close) thenif InverseTrading and Close > ExponentialAverage[100](close) thenSELLSHORT Size CONTRACT AT MARKETelseBUY Size CONTRACTS AT MARKETendiflastbar = barindexendifendif//cumulate order when a new consecutive candletick happen right after the pattern occurredif onmarket and timeEnterBefore and timeEnterAfter and CumulateOrder and barindex-lastbar=1 thenif longonmarket thenif (close>open and lastpattern=1) or (close<open and lastpattern=-1) thenBUY Size CONTRACTS AT MARKETlastbar = barindexendifendifif shortonmarket thenif (close>open and lastpattern=1) or (close<open and lastpattern=-1) thenSELLSHORT Size CONTRACT AT MARKETlastbar = barindexendifendifendifSET STOP PLOSS StopLossSET TARGET PPROFIT TakeProfit//END01/25/2018 at 2:02 AM #6046501/25/2018 at 5:53 AM #60466Grahal.
Thank you for your input. Appreciated.
I will definately try it.I tried and tested this MultipleCandle code on almost all FX and Indices with various permutations and this code on US Russel 2000 was about the only profitable one.
I tried others with MFE code from Nicolas but those are not as profitable.With your addition to this code other FX and Indices permutations I tried might just might become profitable.
Thank you.
01/27/2018 at 1:41 AM #60652Hi,
I confirm that backtests are better with heikin hashi for “bearpattern” and “bullishpattern”:
1234567xClose = (Open+High+Low+Close)/4if(barindex>2) thenxOpen = (xOpen[1] + xClose[1])/2endif//detecting patternsbearpattern = summation[Xcandlesticks](Xclose<Xopen)=Xcandlesticksbullishpattern = summation[Xcandlesticks](Xclose>Xopen)=XcandlesticksI have tested only DAX and CAC and found better results with DAX.
1 user thanked author for this post.
01/27/2018 at 2:54 PM #60682Hi @noisette , please could you share the full code with your heikin ashi for “bearpattern” and “bullishpattern”:
I added / changed as per your changes above … both to Andre code and to Andre code with my changes (addition of EMA) and I got the results attached. (from bottom up on equity curves)
I both cases worse results. Your full code will establish if I have made the changes incorrectly? Please also might you show the equity curve you got?
Thank You
GraHalPS I added your code as shown attached … as replacement for lines 27 to 33
01/27/2018 at 3:09 PM #60686Hi GraHal,
Sorry, I used your code but I forgot to say that I worked with main modifications bellow:
- 3 consecutive candles instead of 4 (Xcandlesticks = 3).
- EMA 10 instead of your different values.
- SL 20 & TP 40.
- No overnight.
- Starting at 9am, last trade at 5.30pm, close at 11pm.
We probably could improve the code with other indicator instead of EMA.
Results seems to be also with other timeframes.
I’ll share the code when I’ll be at home.
Regards.
1 user thanked author for this post.
-
AuthorPosts