5-Bar Run (Help)
Forums › ProRealTime English forum › ProOrder support › 5-Bar Run (Help)
- This topic has 5 replies, 2 voices, and was last updated 5 years ago by
April O’Neil.
-
-
10/12/2020 at 4:56 PM #147182
Hello,
I need help to find error in the strategy bellow, the code do not enter position.
here is strategy’s rules :
- Wait for 5 bar down in a row
- Confirm with RSI<10
- Wait for doji
- Take Profit in funtion of the entry price (50% of the downward move represented by the 5 precedents bars)
Hourly or Daily Datas.
5-Bar Run1234567891011121314151617181920212223242526272829303132//////////inputsminbarsdown = 5RSIthreshold = 10dojispan = 0.10proftarget = 0.50exitbars=5exitRSI=50count = 0n = 1///////varsmom = RSI[14](close)doji = abs(open - close)/(high - low)if close > close[1] thencount = count + 1elsif close < close[1] thencount = 0endif//ENTRYif count >= minbarsdown and mom <= RSIthreshold and doji < dojispan thenbuy n shares at marketSET TARGET PROFIT (TRADEPRICE(1) + proftarget*(close[count] - close))endif//exitif longonmarket and (mom > exitRSI or (BARINDEX-TRADEINDEX(1)) >= exitbars) thensell n shares at marketENDIF10/12/2020 at 5:42 PM #147191Your code could be:
1234567891011121314151617181920212223//////////inputsminbarsdown = 5RSIthreshold = 10dojispan = 0.10proftarget = 0.50exitbars=5exitRSI=50n = 1///////varsmom = RSI[14](close)doji = abs(open - close)/(high - low)//ENTRYif summation[5](close > close[1]) = minbarsdown and mom <= RSIthreshold and doji < dojispan thenbuy n shares at marketSET TARGET PROFIT (TRADEPRICE(1) + proftarget*(close[count] - close))endif//exitif longonmarket and (mom > exitRSI or (BARINDEX-TRADEINDEX(1)) >= exitbars) thensell n shares at marketENDIFusing SUMMATION is simpler and faster.
10/12/2020 at 5:46 PM #147192You wrote BARS DOWN, but actually your code (and mine) is counting BARS UP.
If you want to scan bearish bars, you just need to replace “>” with “<” at line 15 with SUMMATION.
10/12/2020 at 5:56 PM #147197Thanks Roberto,
But still doesn’t resolve the problem
10/12/2020 at 6:15 PM #147200Parameters are too strict, when DOJI is < 0.10 MOM is never below 10 (in my test). Try to test it with a higher value for RSIthreshold.
In my code you will be reported COUNT as not exixting. I don’t know what you are exactly using it for, but this is your original code with the addition of my solution:
1234567891011121314151617181920212223242526272829303132//////////inputsminbarsdown = 5RSIthreshold = 10dojispan = 0.10proftarget = 0.50exitbars=5exitRSI=50count = 0n = 1///////varsmom = RSI[14](close)doji = abs(open - close)/(high - low)if close > close[1] thencount = count + 1elsif close < close[1] thencount = 0endif//ENTRYif summation[5](close > close[1]) = minbarsdown and mom <= RSIthreshold and doji < dojispan thenbuy n shares at marketSET TARGET PROFIT (TRADEPRICE(1) + proftarget*(close[count] - close))endif//exitif longonmarket and (mom > exitRSI or (BARINDEX-TRADEINDEX(1)) >= exitbars) thensell n shares at marketENDIFmoreover, your stop loss will never be reached because it’s a price, not a difference between prices which is what LOSS requires, on DAX it would be ove 13000 pips!, you should compute a difference, such as abs(HIGH – TradePrice(1)) or the like.
10/12/2020 at 6:28 PM #147203Perfect, i spotted the problem,
Thanks for your great help.
Gonna work on it and post results if they give something of interest.
-
AuthorPosts
Find exclusive trading pro-tools on