Converting Five Bar Trend indicator to Pro Order
Forums › ProRealTime English forum › ProOrder support › Converting Five Bar Trend indicator to Pro Order
- This topic has 16 replies, 3 voices, and was last updated 6 years ago by
soulintact.
-
-
08/25/2019 at 6:11 AM #105482
Good morning!
I tried to rewrite the latest great indicator of Vonasi, Five Bar Trend Dashboard, to pro order, but failed. Any one care to elaborate what I am doing wrong, thanks!
Five Bar Trend Dashboard by Vonasi to Pro Order functionality123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169//-------------------------------------------------------------------------defparam cumulateorders=falseDefparam preloadbars=10000//-------------------------------------------------------------------------// --- settings of ORDERSamount = 100 //quantity of shares/contracts to open for each new order//-------------------------------------------------------------------------//Indicators//Indicator type: Candle trend in 5 different time frames//Edited code originates from: Five Bar Trend//Author: Vonasi//Date: 20190822//Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard/m5 = customclose//m5=typicalprice//m5=medianprice//m5=totalprice//m5=weightedclose//m5=(close or customclose = open or customclose = high or customclose = low)m10h = highest[2](high)m10l = lowest[2](low)m10o = open[1]m15h = highest[3](high)m15l = lowest[3](low)m15o = open[2]m20h = highest[4](high)m20l = lowest[4](low)m20o = open[3]m25h = highest[5](high)m25l = lowest[5](low)m25o = open[4]if customclose = typicalprice thenm10 = (m10h + m10l + close)/3m15 = (m15h + m15l + close)/3m20 = (m20h + m20l + close)/3m25 = (m25h + m25l + close)/3endifif customclose = medianprice thenm10 = (m10h + m10l)/2m15 = (m15h + m15l)/2m20 = (m20h + m20l)/2m25 = (m25h + m25l)/2endifif customclose = totalprice thenm10 = (m10h + m10l + m10o + close)/4m15 = (m15h + m15l + m15o + close)/4m20 = (m20h + m20l + m20o + close)/4m25 = (m25h + m25l + m25o + close)/4endifif customclose = weightedclose thenm10 = (m10h + m10l + (2 * close))/4m15 = (m15h + m15l + (2 * close))/4m20 = (m20h + m20l + (2 * close))/4m25 = (m25h + m25l + (2 * close))/4endifif customclose = close or customclose = open or customclose = high or customclose = low thenm5 = openm10 = m10om15 = m15om20 = m20om25 = m25oendif//Line 1, First time frame//Red dotif close < m5 thenL1=-1down = down + 1endif//Green dotif close > m5 thenL1=1up = up + 1endif//Line 2, Second time frame//Red dotif close < m10 thenL2=-1down = down + 1endif//Green dotif close > m10 thenL2=1up = up + 1endif//Line 3, Third time frame//Red dotif close < m15 thenL3=-1down = down + 1endif//Green dotif close > m15 thenL3=1up = up + 1endif//Line 4, Fourth time frame//Red dotif close < m20 thenL4=-1down = down + 1endif//Green dotif close > m20 thenL4=1up = up + 1endif//Line 5, Fifth time frame//Red dotif close < m25 thenL5=-1down = down + 1endif//Green dotif close > m25 thenL5=1up = up + 1endif//Market reversal//Downif up[1] = 5 and down <> 5 and up <> 5 thenreda = ucount[1]ucount = 0Arrow=-1endif//Upif down[1] = 5 and down <> 5 and up <> 5 thengreena = dcount[1]dcount = 0Arrow=1endifBullCandle5=((L1=1)and(L2=1)and(L3=1)and(L4=1)and(L5=1)) or ((Arrow=1) and (greena>=3))BearCandle5=((L1=-1)and(L2=-1)and(L3=-1)and(L4=-1)and(L5=-1)) or ((Arrow=-1) and (reda>=3))//Conditions when to actif (not longonmarket and BullCandle5) thenbuy amount shares at marketendifif (longonmarket and BearCandle5 and positionperf>0) thensell at marketendif08/25/2019 at 9:16 AM #105487What is yours not doing? Maybe you are blowing your Account with Lot = 100?? 🙂
Attached with Lot = 1
1 user thanked author for this post.
08/25/2019 at 9:49 AM #105491Just like GraHal it works for me. I have removed all references to customclose and referenced m5 instead so that it will work with the various custom prices by // out the prices you don’t need.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166//-------------------------------------------------------------------------defparam cumulateorders=falseDefparam preloadbars=10000//-------------------------------------------------------------------------// --- settings of ORDERSamount = 100 //quantity of shares/contracts to open for each new order//-------------------------------------------------------------------------//Indicators//Indicator type: Candle trend in 5 different time frames//Edited code originates from: Five Bar Trend//Author: Vonasi//Date: 20190822//Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard///m5=typicalpricem5=medianprice//m5=totalprice//m5=weightedclose//m5=openm10h = highest[2](high)m10l = lowest[2](low)m10o = open[1]m15h = highest[3](high)m15l = lowest[3](low)m15o = open[2]m20h = highest[4](high)m20l = lowest[4](low)m20o = open[3]m25h = highest[5](high)m25l = lowest[5](low)m25o = open[4]if m5 = typicalprice thenm10 = (m10h + m10l + close)/3m15 = (m15h + m15l + close)/3m20 = (m20h + m20l + close)/3m25 = (m25h + m25l + close)/3endifif m5 = medianprice thenm10 = (m10h + m10l)/2m15 = (m15h + m15l)/2m20 = (m20h + m20l)/2m25 = (m25h + m25l)/2endifif m5 = totalprice thenm10 = (m10h + m10l + m10o + close)/4m15 = (m15h + m15l + m15o + close)/4m20 = (m20h + m20l + m20o + close)/4m25 = (m25h + m25l + m25o + close)/4endifif m5 = weightedclose thenm10 = (m10h + m10l + (2 * close))/4m15 = (m15h + m15l + (2 * close))/4m20 = (m20h + m20l + (2 * close))/4m25 = (m25h + m25l + (2 * close))/4endifif m5 = open thenm5 = openm10 = m10om15 = m15om20 = m20om25 = m25oendif//Line 1, First time frame//Red dotif close < m5 thenL1=-1down = down + 1endif//Green dotif close > m5 thenL1=1up = up + 1endif//Line 2, Second time frame//Red dotif close < m10 thenL2=-1down = down + 1endif//Green dotif close > m10 thenL2=1up = up + 1endif//Line 3, Third time frame//Red dotif close < m15 thenL3=-1down = down + 1endif//Green dotif close > m15 thenL3=1up = up + 1endif//Line 4, Fourth time frame//Red dotif close < m20 thenL4=-1down = down + 1endif//Green dotif close > m20 thenL4=1up = up + 1endif//Line 5, Fifth time frame//Red dotif close < m25 thenL5=-1down = down + 1endif//Green dotif close > m25 thenL5=1up = up + 1endif//Market reversal//Downif up[1] = 5 and down <> 5 and up <> 5 thenreda = ucount[1]ucount = 0Arrow=-1endif//Upif down[1] = 5 and down <> 5 and up <> 5 thengreena = dcount[1]dcount = 0Arrow=1endifBullCandle5=((L1=1)and(L2=1)and(L3=1)and(L4=1)and(L5=1)) or ((Arrow=1) and (greena>=3))BearCandle5=((L1=-1)and(L2=-1)and(L3=-1)and(L4=-1)and(L5=-1)) or ((Arrow=-1) and (reda>=3))//Conditions when to actif (not longonmarket and BullCandle5) thenbuy amount shares at marketendifif (longonmarket and BearCandle5 and positionperf>0) thensell at marketendif2 users thanked author for this post.
08/25/2019 at 10:09 AM #105497Thank you Vonasi you solved it. I missed out to remove all references to customclose and to refere m5 instead, thanks!!
09/18/2019 at 4:09 PM #107886Dear Vonasi,
Now I am trying to figure out how to calculate the upper line, which I thought was dcount (down, green) or ucount (up, red). I made a simple exit condition, BearCount that you will find in the end of the code. What am I doing wrong?
Candle trend in 5 different time frames123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184//Indicator type: Candle trend in 5 different time frames//Edited code originates from: Five Bar Trend//Author: Vonasi//Date: 20190822//Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard///m5=typicalpricem5=medianprice//m5=totalprice//m5=weightedclose//m5=openm10h = highest[2](high)m10l = lowest[2](low)m10o = open[1]m15h = highest[3](high)m15l = lowest[3](low)m15o = open[2]m20h = highest[4](high)m20l = lowest[4](low)m20o = open[3]m25h = highest[5](high)m25l = lowest[5](low)m25o = open[4]if m5 = typicalprice thenm10 = (m10h + m10l + close)/3m15 = (m15h + m15l + close)/3m20 = (m20h + m20l + close)/3m25 = (m25h + m25l + close)/3endifif m5 = medianprice thenm10 = (m10h + m10l)/2m15 = (m15h + m15l)/2m20 = (m20h + m20l)/2m25 = (m25h + m25l)/2endifif m5 = totalprice thenm10 = (m10h + m10l + m10o + close)/4m15 = (m15h + m15l + m15o + close)/4m20 = (m20h + m20l + m20o + close)/4m25 = (m25h + m25l + m25o + close)/4endifif m5 = weightedclose thenm10 = (m10h + m10l + (2 * close))/4m15 = (m15h + m15l + (2 * close))/4m20 = (m20h + m20l + (2 * close))/4m25 = (m25h + m25l + (2 * close))/4endifif m5 = open thenm5 = openm10 = m10om15 = m15om20 = m20om25 = m25oendif//Line 1, First time frame//Red dotif close < m5 thenL1=-1down = down + 1endif//Green dotif close > m5 thenL1=1up = up + 1endif//Line 2, Second time frame//Red dotif close < m10 thenL2=-1down = down + 1endif//Green dotif close > m10 thenL2=1up = up + 1endif//Line 3, Third time frame//Red dotif close < m15 thenL3=-1down = down + 1endif//Green dotif close > m15 thenL3=1up = up + 1endif//Line 4, Fourth time frame//Red dotif close < m20 thenL4=-1down = down + 1endif//Green dotif close > m20 thenL4=1up = up + 1endif//Line 5, Fifth time frame//Red dotif close < m25 thenL5=-1down = down + 1endif//Green dotif close > m25 thenL5=1up = up + 1endif//Calculating amount of ups eller downs reflected in first rowup = 0down = 0if close < m5 thendown = down + 1endifif close > m5 thenup = up + 1endifif close < m10 thendown = down + 1endifif close > m10 thenup = up + 1endifif close < m15 thendown = down + 1endifif close > m15 thenup = up + 1endifif close < m20 thendown = down + 1endifif close > m20 thenup = up + 1endifif close < m25 thendown = down + 1endifif close > m25 thenup = up + 1endifif down = 5 thendcount = dcount + 1ucount = 0endifif up = 5 thendcount = 0ucount = ucount + 1endifBearCount=dcount > 709/18/2019 at 10:01 PM #107902Sorry soulintact but I don’t fully understand what you are trying to do. The top line is just the count of bars in a row where all tests have been either all up or all tests have been down.
The only thing I can say is that if a test results in not all tests being up or not all tests being down then the following code does not reset dcount or ucount to zero.
1234567891011if down = 5 thendcount = dcount + 1ucount = 0endifif up = 5 thendcount = 0ucount = ucount + 1endifBearCount=dcount > 71 user thanked author for this post.
09/19/2019 at 7:43 AM #107911Thank you Vonasi for your prompt reply. Sorry for not being clear enough.
As of the included file, I want to be able to calculate the numbers 3(green) 1 (green) 1 (red) 8 (red) 1 (red) 1 (green) 4 (green) 1 (green).
By the code I wanted to exit the position when the number of red/down was greater than 7. I enclose the code again with your suggested modification.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183//Indicator type: Candle trend in 5 different time frames//Edited code originates from: Five Bar Trend//Author: Vonasi//Date: 20190822//Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard///m5=typicalpricem5=medianprice//m5=totalprice//m5=weightedclose//m5=openm10h = highest[2](high)m10l = lowest[2](low)m10o = open[1]m15h = highest[3](high)m15l = lowest[3](low)m15o = open[2]m20h = highest[4](high)m20l = lowest[4](low)m20o = open[3]m25h = highest[5](high)m25l = lowest[5](low)m25o = open[4]if m5 = typicalprice thenm10 = (m10h + m10l + close)/3m15 = (m15h + m15l + close)/3m20 = (m20h + m20l + close)/3m25 = (m25h + m25l + close)/3endifif m5 = medianprice thenm10 = (m10h + m10l)/2m15 = (m15h + m15l)/2m20 = (m20h + m20l)/2m25 = (m25h + m25l)/2endifif m5 = totalprice thenm10 = (m10h + m10l + m10o + close)/4m15 = (m15h + m15l + m15o + close)/4m20 = (m20h + m20l + m20o + close)/4m25 = (m25h + m25l + m25o + close)/4endifif m5 = weightedclose thenm10 = (m10h + m10l + (2 * close))/4m15 = (m15h + m15l + (2 * close))/4m20 = (m20h + m20l + (2 * close))/4m25 = (m25h + m25l + (2 * close))/4endifif m5 = open thenm5 = openm10 = m10om15 = m15om20 = m20om25 = m25oendif//Line 1, First time frame//Red dotif close < m5 thenL1=-1down = down + 1endif//Green dotif close > m5 thenL1=1up = up + 1endif//Line 2, Second time frame//Red dotif close < m10 thenL2=-1down = down + 1endif//Green dotif close > m10 thenL2=1up = up + 1endif//Line 3, Third time frame//Red dotif close < m15 thenL3=-1down = down + 1endif//Green dotif close > m15 thenL3=1up = up + 1endif//Line 4, Fourth time frame//Red dotif close < m20 thenL4=-1down = down + 1endif//Green dotif close > m20 thenL4=1up = up + 1endif//Line 5, Fifth time frame//Red dotif close < m25 thenL5=-1down = down + 1endif//Green dotif close > m25 thenL5=1up = up + 1endifup = 0down = 0if close < m5 thendown = down + 1endifif close > m5 thenup = up + 1endifif close < m10 thendown = down + 1endifif close > m10 thenup = up + 1endifif close < m15 thendown = down + 1endifif close > m15 thenup = up + 1endifif close < m20 thendown = down + 1endifif close > m20 thenup = up + 1endifif close < m25 thendown = down + 1endifif close > m25 thenup = up + 1endifif down = 5 thendcount = dcount + 1ucount = 0endifif up = 5 thendcount = 0ucount = ucount + 1endifBearCount=dcount > 709/19/2019 at 8:53 AM #107922That wasn’t a suggested modification – that was the bit of your original code that I cut and pasted in where values are not set to zero at any time!
In the original code it was like this:
1234567891011121314151617181920flag = 0if down[1] = 5 and down <> 5 and up <> 5 thendrawtext("▲",barindex,2,SansSerif,Bold,16)coloured(0,128,0)a = dcount[1]drawtext("#a#",barindex,3,SansSerif,Bold,16)coloured(0,128,0)dcount = 0flag = 1endifif up[1] = 5 and down <> 5 and up <> 5 thendrawtext("▼",barindex,2,SansSerif,Bold,16)coloured(128,0,0)a = ucount[1]drawtext("#a#",barindex,3,SansSerif,Bold,16)coloured(128,0,0)ucount = 0flag = 1endifif flag = 0 and up <> 5 and down <> 5 thendrawtext("○",barindex,2,SansSerif,Bold,16)coloured(0,0,255)endifIf we remove the graphics and replace them with variables then we can get something like:
12345678910111213141516171819flag = 0if down[1] = 5 and down <> 5 and up <> 5 thendirection = 1a = dcount[1]dcount = 0flag = 1endifif up[1] = 5 and down <> 5 and up <> 5 thendirection = -1a = ucount[1]ucount = 0flag = 1endifif flag = 0 and up <> 5 and down <> 5 thendirection = 0a = 0endifSo now we have a variable ‘direction’ that can be either -1, zero or 1 and the variable ‘a’ which is the quantity of the same direction in a row or zero if all directions are not the same.
1 user thanked author for this post.
09/19/2019 at 2:19 PM #107952Thank you Vonasi for your patience!
What expression would I use to be able to “catch” the red 8, or rather 8 lines of green dots and one red dot of the following line?
I tried a few, and the following is not correct, but with the best performance: BearCount=(direction=1) and (a < 1)
What am I missing? Thanks!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194//Indicator type: Candle trend in 5 different time frames//Edited code originates from: Five Bar Trend//Author: Vonasi//Date: 20190822//Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard///m5=typicalpricem5=medianprice//m5=totalprice//m5=weightedclose//m5=openm10h = highest[2](high)m10l = lowest[2](low)m10o = open[1]m15h = highest[3](high)m15l = lowest[3](low)m15o = open[2]m20h = highest[4](high)m20l = lowest[4](low)m20o = open[3]m25h = highest[5](high)m25l = lowest[5](low)m25o = open[4]if m5 = typicalprice thenm10 = (m10h + m10l + close)/3m15 = (m15h + m15l + close)/3m20 = (m20h + m20l + close)/3m25 = (m25h + m25l + close)/3endifif m5 = medianprice thenm10 = (m10h + m10l)/2m15 = (m15h + m15l)/2m20 = (m20h + m20l)/2m25 = (m25h + m25l)/2endifif m5 = totalprice thenm10 = (m10h + m10l + m10o + close)/4m15 = (m15h + m15l + m15o + close)/4m20 = (m20h + m20l + m20o + close)/4m25 = (m25h + m25l + m25o + close)/4endifif m5 = weightedclose thenm10 = (m10h + m10l + (2 * close))/4m15 = (m15h + m15l + (2 * close))/4m20 = (m20h + m20l + (2 * close))/4m25 = (m25h + m25l + (2 * close))/4endifif m5 = open thenm5 = openm10 = m10om15 = m15om20 = m20om25 = m25oendif//Line 1, First time frame//Red dotif close < m5 thenL1=-1down = down + 1endif//Green dotif close > m5 thenL1=1up = up + 1endif//Line 2, Second time frame//Red dotif close < m10 thenL2=-1down = down + 1endif//Green dotif close > m10 thenL2=1up = up + 1endif//Line 3, Third time frame//Red dotif close < m15 thenL3=-1down = down + 1endif//Green dotif close > m15 thenL3=1up = up + 1endif//Line 4, Fourth time frame//Red dotif close < m20 thenL4=-1down = down + 1endif//Green dotif close > m20 thenL4=1up = up + 1endif//Line 5, Fifth time frame//Red dotif close < m25 thenL5=-1down = down + 1endif//Green dotif close > m25 thenL5=1up = up + 1endifup = 0down = 0if close < m5 thendown = down + 1endifif close > m5 thenup = up + 1endifif close < m10 thendown = down + 1endifif close > m10 thenup = up + 1endifif close < m15 thendown = down + 1endifif close > m15 thenup = up + 1endifif close < m20 thendown = down + 1endifif close > m20 thenup = up + 1endifif close < m25 thendown = down + 1endifif close > m25 thenup = up + 1endifflag = 0if down[1] = 5 and down <> 5 and up <> 5 thendirection = 1a = dcount[1]dcount = 0flag = 1endifif up[1] = 5 and down <> 5 and up <> 5 thendirection = -1a = ucount[1]ucount = 0flag = 1endifif flag = 0 and up <> 5 and down <> 5 thendirection = 0a = 0endifBearCount=(direction=1) and (a < 1)09/19/2019 at 2:45 PM #107957There is a critical bit of my original indicator code that does not seem to have found its way into your code. The calculation of dcount and ucount!
1234567891011121314151617181920212223242526272829303132if down = 5 thendcount = dcount + 1ucount = 0endifif up = 5 thendcount = 0ucount = ucount + 1endifflag = 0if down[1] = 5 and down <> 5 and up <> 5 thendirection = 1a = dcount[1]dcount = 0flag = 1endifif up[1] = 5 and down <> 5 and up <> 5 thendirection = -1a = ucount[1]ucount = 0flag = 1endifif flag = 0 and up <> 5 and down <> 5 thendirection = 0a = 0endifBearCount=(direction=1) and (a > 7)1 user thanked author for this post.
09/19/2019 at 4:19 PM #107978Sorry about that! Although it does not work with the edited code as enclosed. Strange! Any more ideas? Thanks!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204//Indicator type: Candle trend in 5 different time frames//Edited code originates from: Five Bar Trend//Author: Vonasi//Date: 20190822//Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard///m5=typicalpricem5=medianprice//m5=totalprice//m5=weightedclose//m5=openm10h = highest[2](high)m10l = lowest[2](low)m10o = open[1]m15h = highest[3](high)m15l = lowest[3](low)m15o = open[2]m20h = highest[4](high)m20l = lowest[4](low)m20o = open[3]m25h = highest[5](high)m25l = lowest[5](low)m25o = open[4]if m5 = typicalprice thenm10 = (m10h + m10l + close)/3m15 = (m15h + m15l + close)/3m20 = (m20h + m20l + close)/3m25 = (m25h + m25l + close)/3endifif m5 = medianprice thenm10 = (m10h + m10l)/2m15 = (m15h + m15l)/2m20 = (m20h + m20l)/2m25 = (m25h + m25l)/2endifif m5 = totalprice thenm10 = (m10h + m10l + m10o + close)/4m15 = (m15h + m15l + m15o + close)/4m20 = (m20h + m20l + m20o + close)/4m25 = (m25h + m25l + m25o + close)/4endifif m5 = weightedclose thenm10 = (m10h + m10l + (2 * close))/4m15 = (m15h + m15l + (2 * close))/4m20 = (m20h + m20l + (2 * close))/4m25 = (m25h + m25l + (2 * close))/4endifif m5 = open thenm5 = openm10 = m10om15 = m15om20 = m20om25 = m25oendif//Line 1, First time frame//Red dotif close < m5 thenL1=-1down = down + 1endif//Green dotif close > m5 thenL1=1up = up + 1endif//Line 2, Second time frame//Red dotif close < m10 thenL2=-1down = down + 1endif//Green dotif close > m10 thenL2=1up = up + 1endif//Line 3, Third time frame//Red dotif close < m15 thenL3=-1down = down + 1endif//Green dotif close > m15 thenL3=1up = up + 1endif//Line 4, Fourth time frame//Red dotif close < m20 thenL4=-1down = down + 1endif//Green dotif close > m20 thenL4=1up = up + 1endif//Line 5, Fifth time frame//Red dotif close < m25 thenL5=-1down = down + 1endif//Green dotif close > m25 thenL5=1up = up + 1endifup = 0down = 0if close < m5 thendown = down + 1endifif close > m5 thenup = up + 1endifif close < m10 thendown = down + 1endifif close > m10 thenup = up + 1endifif close < m15 thendown = down + 1endifif close > m15 thenup = up + 1endifif close < m20 thendown = down + 1endifif close > m20 thenup = up + 1endifif close < m25 thendown = down + 1endifif close > m25 thenup = up + 1endifif down = 5 thendcount = dcount + 1ucount = 0endifif up = 5 thendcount = 0ucount = ucount + 1endifflag = 0if down[1] = 5 and down <> 5 and up <> 5 thendirection = 1a = dcount[1]dcount = 0flag = 1endifif up[1] = 5 and down <> 5 and up <> 5 thendirection = -1a = ucount[1]ucount = 0flag = 1endifif flag = 0 and up <> 5 and down <> 5 thendirection = 0a = 0endifBearCount=(direction=1) and (a > 7)09/19/2019 at 6:12 PM #107996It works fine for me.
I took your code and just added ‘buy at -close limit’ to turn it into a dummy strategy. I rem’d out all references to L1, L2 etc to make it work and then graphed BEARCOUNT – having changed it to ‘BearCount=(direction=1) and (a > 3)’ and every time there is a run of more than 3 red candles it returns a positive value for BEARCOUNT.
1 user thanked author for this post.
09/19/2019 at 7:51 PM #107998Dear Vonasi,
Sorry for being so slow in mind and persistent, but I still do not follow fully. Do the statement below really correspond to the definition in words?
BearCount=(direction=1) and (a > 7) := (direction is now negative with a least one red dot) and (previously more than 7 of the same direction in a row of green dots)
Cheers!
09/19/2019 at 8:20 PM #108000No
BearCount=(direction=1) and (a > 7) would be that we have just had a run of 8 (sets of 5) red dots and this set is not a set of 5 red dots nor a set of five green dots.
1 user thanked author for this post.
09/19/2019 at 8:29 PM #108001Aha, thanks!
And how would we formulate the expression to “catch” the red 8 as enclosed.
-
AuthorPosts
Find exclusive trading pro-tools on