PP Fractals // Error message
Forums › ProRealTime English forum › ProOrder support › PP Fractals // Error message
- This topic has 28 replies, 4 voices, and was last updated 3 years ago by
PeterSt.
-
-
02/28/2022 at 1:17 AM #188965
Hello,
I tried to embed the PP Fractals indicator developed by Vonasi https://www.prorealcode.com/prorealtime-indicators/pp-fractals/ in a Strategy, where among conditions to go Long (Close> $resistancevalue[z]) and go Short (Close<close < $supportvalue[z]). The backtest works perfectly fine on 100k 1min TF. However, when I put it live, I got this error message twice. It seems to be linked to the number of values in the Arrays. Note: this is the only Array I’ve in my system. Also, I tried with Preload 10000 bars and without Preload and the problem is the same.
I congratulate Vonasi for his work as the System without this condition generates 40% less Gains!
Any idea on how to overcome this problem?
Thank you.
02/28/2022 at 2:20 AM #188968Hi Khaled,
I don’t understand much of Vonasi’s Indicator code, so the only hint I can give you is that an array can’t contain more than 1M elements. And the message you show seems to be about that.
An other hint could be that the indicator is a kind of lame (not decent) in not being able to find a “base” for its signal, as Vonasi explains himself. So you could have run into that situation where it needs to go back further than the array size allows for.Please keep in mind that my text may not make any sense because I really can’t follow what is going on in his code (up to my thinking that it can’t work at all 😐 ).
Hopefully others can help more; the 1M max elements is key …1 user thanked author for this post.
02/28/2022 at 2:33 AM #188969What I would attempt :
1a = a + 1All such situations (also for b and z at first glance) could be written like this :
123if a < 999999 then // 1 extra to be on the safe side.a = a + 1endifThis will stop going back further than technically possible, but don’t ask me for the reliability of the result and its impact. But at least it won’t fail.
On a (not so unimportant) side note :
You may have read (elsewhere) me questioning what would or could happen in LIVE when the progression of time may cross the threshold of the boundaries of arrays. But this (erroring-out) would require 1M bars plus the amount of looking back first. Anyway, this would be a “feature” of Live which BackTesting would not allow for (it won’t go wrong when time passes).Hope this helps !
1 user thanked author for this post.
02/28/2022 at 8:11 AM #18897102/28/2022 at 8:42 AM #18897202/28/2022 at 9:12 AM #18897502/28/2022 at 9:14 AM #188976Please post the strategy code, we dont know how you have implemented the code into the strategy. I assume you want to trade the last segment breakout? If so, then most of the indicator code is not necessary.
1 user thanked author for this post.
02/28/2022 at 10:03 AM #188991Thank you Nicolas for your time. Indeed, I’d like to get signals on the last segment breakout.
Below the code run on SP500 – 100k – 1min TF – spread 0.6
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276DEFPARAM CUMULATEORDERS = FALSETIMEFRAME(60 minutes)LongConso=0ShortConso= 0Long=0Short=0//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////PRC_SwingLine Ron Black | indicator by Nicolasif upsw=1 thenif high>hH thenhH=highendifif low>hL thenhL=lowendifif high<hL thenupsw=0lL=lowlH=highendifendifif upsw=0 thenif low<lL thenlL=lowendifif high<lH thenlH=highendifif low>lH thenupsw=1hH=highhL=lowendifendifif upsw=1 thenswingline=hLelseswingline=lHendifif close>open theniRange = abs(close-open)elsif close<open theniRange = abs(open-close)endifif close>open thenUpWick = high - closeLoWick = open-lowelsif close<open thenUpWick = high-openLoWick = close-lowendif// LONGif close>open thenif close[1]>open[1] thenif close>close[1] thenlong1=1endifendifendifif close>open thenif close[1]<open[1] thenif close>open[1] thenlong2=1endifendifendifif iRange>UpWick or LoWick>UpWick thenlong3 = 1endif//if close>close[1] and close[2]>close[1] then//long4 = 1//endifif high>high[1] or low>low[1] thenlong5=1endifif (long1 or long2) and long3 and long5 and close>swingline thenLong=1endif// SHORTif close<open thenif close[1]>open[1] thenif close<open[1] thenshort1=1endifendifendifif close<open thenif close[1]<open[1] thenif close<close[1] thenshort2=1endifendifendifif iRange>LoWick or LoWick<UpWick thenshort3 = 1endif//if close<close[1] and close[2]<close[1] then//short4 = 1//endifif high<high[1] or low<low[1] thenshort5=1endifif (Short1 or short2) and short3 and short5 and close<swingline thenShort=-1endif////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SR PP Fractal Lines by Vonasi//BarsBefore = 1//BarsAfter = 1Support = 1Resistance = 1Points = 1//Make sure all settings are valid onesBarsBefore = max(BarsBefore,1)BarsAfter = max(BarsAfter,1)StartBack = max(0,startback)if barindex >= barsbefore + barsafter then//Look for a low fractalBarLookBack = BarsAfter + 1if low[BarsAfter] < lowest[BarsBefore](low)[BarLookBack] THENif low[BarsAfter] = lowest[BarLookBack](low) THENif a<99999 thena = a + 1endif$supportbar[a] = barindex[barsafter]$supportvalue[a] = low[barsafter]endifendif//Look for a high fractalif high[BarsAfter] > highest[BarsBefore](high)[BarLookBack] THENif high[BarsAfter] = highest[BarLookBack](high) THENif b<99999 thenb = b + 1endif$resistancebar[b] = barindex[barsafter]$resistancevalue[b] = high[barsafter]endifendifif islastbarupdate then//support lineif a >= 2 thenif support thenflag = 0zz = 0for z = a-zz downto 1for xx = 1 to aif z-xx < 1 thenbreakendifif $supportvalue[z] > $supportvalue[z-xx] thenif points thenendifflag = 1breakendifif zz<99999 thenzz = zz + 1endifnextif flag = 1 thenbreakendifzz = 0nextendifendif//resistance lineif b >= 2 thenif resistance thenflag = 0zz = 0for z = b-zz downto 1for xx = 1 to bif z-xx < 1 thenbreakendifif $resistancevalue[z] < $resistancevalue[z-xx] thenif points thenendifflag = 1breakendifif zz<99999 thenzz = zz + 1endifnextif flag = 1 thenbreakendifzz = 0nextendifendifendifendif////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LongConso = long=1 and close > $resistancevalue[z]ShortConso = short=-1 and close < $supportvalue[z]////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////TIMEFRAME(5 minutes, UPDATEONCLOSE)nLots = min(10,round((2000+STRATEGYPROFIT)/(close*.5*.1),1))IF NOT LongOnMarket AND LongConso THENBUY nLots CONTRACTS AT MARKETENDIFIF NOT ShortOnMarket AND ShortConso THENSELLSHORT nLots CONTRACTS AT MARKETENDIF////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////If LongOnMarket AND ShortConso THENSELL AT MARKETSELLSHORT nLots CONTRACTS AT MARKETENDIFIF ShortOnMarket AND LongConso THENEXITSHORT AT MARKETBUY nLots CONTRACTS AT MARKETENDIF////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////TIMEFRAME(1 minute)SET STOP %LOSS .3 //SLSET TARGET %PROFIT 1.6 //TP02/28/2022 at 11:05 AM #189001Ok, so arrays are not useful anymore, there was useful in case of plotting them on the chart in the past.
Here is the code, not a real breakout, your condition is testing a price superior or inferior.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278DEFPARAM CUMULATEORDERS = FALSETIMEFRAME(60 minutes)LongConso=0ShortConso= 0Long=0Short=0//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////PRC_SwingLine Ron Black | indicator by Nicolasif upsw=1 thenif high>hH thenhH=highendifif low>hL thenhL=lowendifif high<hL thenupsw=0lL=lowlH=highendifendifif upsw=0 thenif low<lL thenlL=lowendifif high<lH thenlH=highendifif low>lH thenupsw=1hH=highhL=lowendifendifif upsw=1 thenswingline=hLelseswingline=lHendifif close>open theniRange = abs(close-open)elsif close<open theniRange = abs(open-close)endifif close>open thenUpWick = high - closeLoWick = open-lowelsif close<open thenUpWick = high-openLoWick = close-lowendif// LONGif close>open thenif close[1]>open[1] thenif close>close[1] thenlong1=1endifendifendifif close>open thenif close[1]<open[1] thenif close>open[1] thenlong2=1endifendifendifif iRange>UpWick or LoWick>UpWick thenlong3 = 1endif//if close>close[1] and close[2]>close[1] then//long4 = 1//endifif high>high[1] or low>low[1] thenlong5=1endifif (long1 or long2) and long3 and long5 and close>swingline thenLong=1endif// SHORTif close<open thenif close[1]>open[1] thenif close<open[1] thenshort1=1endifendifendifif close<open thenif close[1]<open[1] thenif close<close[1] thenshort2=1endifendifendifif iRange>LoWick or LoWick<UpWick thenshort3 = 1endif//if close<close[1] and close[2]<close[1] then//short4 = 1//endifif high<high[1] or low<low[1] thenshort5=1endifif (Short1 or short2) and short3 and short5 and close<swingline thenShort=-1endif////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SR PP Fractal Lines by Vonasi//BarsBefore = 1//BarsAfter = 1Support = 1Resistance = 1Points = 1//Make sure all settings are valid onesBarsBefore = max(BarsBefore,1)BarsAfter = max(BarsAfter,1)StartBack = max(0,startback)if barindex >= barsbefore + barsafter then//Look for a low fractalBarLookBack = BarsAfter + 1if low[BarsAfter] < lowest[BarsBefore](low)[BarLookBack] THENif low[BarsAfter] = lowest[BarLookBack](low) THEN//if a<99999 then//a = a + 1//endif//$supportbar[a] = barindex[barsafter]//$supportvalue[a] = low[barsafter]supportvalue = low[barsafter]endifendif//Look for a high fractalif high[BarsAfter] > highest[BarsBefore](high)[BarLookBack] THENif high[BarsAfter] = highest[BarLookBack](high) THEN//if b<99999 then//b = b + 1//endif//$resistancebar[b] = barindex[barsafter]//$resistancevalue[b] = high[barsafter]resistancevalue = high[barsafter]endifendif//if islastbarupdate then////support line//if a >= 2 then//if support then//flag = 0//zz = 0//for z = a-zz downto 1//for xx = 1 to a//if z-xx < 1 then//break//endif//if $supportvalue[z] > $supportvalue[z-xx] then//if points then//endif//flag = 1//break//endif//if zz<99999 then//zz = zz + 1//endif//next//if flag = 1 then//break//endif//zz = 0//next//endif//endif//////resistance line//if b >= 2 then//if resistance then//flag = 0//zz = 0//for z = b-zz downto 1//for xx = 1 to b//if z-xx < 1 then//break//endif//if $resistancevalue[z] < $resistancevalue[z-xx] then//if points then//endif//flag = 1//break//endif//if zz<99999 then//zz = zz + 1//endif//next//if flag = 1 then//break//endif//zz = 0//next//endif//endif//endifendif////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LongConso = long=1 and close > resistancevalue//$resistancevalue[z]ShortConso = short=-1 and close < supportvalue//$supportvalue[z]////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////TIMEFRAME(5 minutes, UPDATEONCLOSE)nLots = min(10,round((2000+STRATEGYPROFIT)/(close*.5*.1),1))IF NOT LongOnMarket AND LongConso THENBUY nLots CONTRACTS AT MARKETENDIFIF NOT ShortOnMarket AND ShortConso THENSELLSHORT nLots CONTRACTS AT MARKETENDIF////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////If LongOnMarket AND ShortConso THENSELL AT MARKETSELLSHORT nLots CONTRACTS AT MARKETENDIFIF ShortOnMarket AND LongConso THENEXITSHORT AT MARKETBUY nLots CONTRACTS AT MARKETENDIF////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////TIMEFRAME(1 minute)SET STOP %LOSS .3 //SLSET TARGET %PROFIT 1.6 //TP1 user thanked author for this post.
02/28/2022 at 11:23 AM #189007Thank you Nicolas.
The code I provided generates in backtest a net gain of 5,328 with a WinRate of 25% and a Drawdown of -2500.
Without changing parameters such as SL, TP, Barsbefore, Barsafter, the code with your changes generates in backtest over the same period a net loss of -1,806 with a WinRate of 23% and a Drawdown of -1897.
So there is something in the original code that was certainly useful.
How can we please just overcome the problem of 1,000,000 values in the Array of the first code?
Much appreciated.
02/28/2022 at 11:41 AM #18901102/28/2022 at 11:54 AM #189013All right. There is is. It required the correct 1euro instrument.
But no error messages (yet), and I removed the If 99999 WHICH btw has one 9 too few (I suggested 999999).
What’s next ?
🙂1 user thanked author for this post.
02/28/2022 at 12:07 PM #189017In case you want to pursue this further : It doesn’t seem to be resilient to more normal markets (pre-Inflation – this is 200K).
N.b.: 1M fails on the “500” error @nonetheless also receives. This is not related to the arrays, as it seems.1 user thanked author for this post.
02/28/2022 at 12:09 PM #189019Peter, thanks for taking the time.
What I meant by “worked one time”, the Algo took live 4 LONG trades in a row (entry and exit properly with small profit), then at the 5th Signal, I had again the same error message. I tried again and again and it’s the same error message.
The Backtest works fine.
The error appears only when I put it Live.
I suspect the solution is what you suggested earlier, limit the number of values in the Array table. May be it should be at the very beginning of the PP Fractals code so that no calculation is performed beyond 999,999
Much appreciated
02/28/2022 at 12:14 PM #189020limit the number of values in the Array table.
Because I don’t understand what it (the arrays) is doing there anyway, I suggest that we better interpret what @Nicolas is saying. So to me it now seems that he (from his own code ever back ?) tells that the arrays were only there for graphing, while you don’t graph anything. So just eliminate the code concerned (?).
Otherwise your error in Live (I missed that one – apologies) could be related to the 500-error I receive with the 1M backtest.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on