Making a indicator from an algo (quadratic semaphore) – problem
Forums › ProRealTime English forum › ProBuilder support › Making a indicator from an algo (quadratic semaphore) – problem
- This topic has 15 replies, 5 voices, and was last updated 5 years ago by roeroc2008.
-
-
09/03/2018 at 10:59 AM #79624
Hey guys,
I´ve created an algo that I´m pretty pleased with and I have made an indicator out of it.
The only thing I´ve changed in the code when converting it into a indicator is replacing for exaple “buy” with “drawarrow up”, “sellshort” with “drawarrowdown” , nothing else in the code. But as you can see in my pictures the indicator dosen´t always do what the backtest is doing and in some places there´s up to four bars between when the indicator is showing where to take a position and where the backtest is taking it.
Do anyone have a clue about what the problem can be?
09/03/2018 at 11:08 AM #79629Only the complete code of both the Algo and the Indicator allows to replicate what you described.
1 user thanked author for this post.
09/03/2018 at 11:50 AM #79631The only thing I´ve changed
Have you also added / typed Return as the last line of the Algo turned into Indicator?
Post the code on here if you want and I’ll try it also?
1 user thanked author for this post.
09/03/2018 at 11:55 AM #79632Algo and indicator123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236ALGO// IQS-V1 //// SWING ALGO - OMX //// CREATED BY JCAP 18.08.27 //// BASED ON https://www.prorealcode.com/prorealtime-indicators/quadratic-semaphore/ //a=6b=15q=40w=60r=40t=100qq=340length = ap=bx1 = barindexx2 = square(x1)y = highS11 = summation[length](x2) - square(summation[length](x1))/lengthS12 = summation[length](x1*x2) - (summation[length](x1) * summation[length](x2))/lengthS22 = summation[length](square(x2)) - square(summation[length](x2))/lengthSy1 = summation[length](y*x1) - (summation[length](y)*summation[length](x1))/lengthSy2 = summation[length](y*x2) - (summation[length](y)*summation[length](x2))/lengthmax1 = average[length](x1)max2 = average[length](x2)may = average[length](y)b2 = ((Sy1 * S22) - (Sy2*S12))/(S22*S11 - square(S12))b3 = ((Sy2 * S11) - (Sy1 * S12))/(S22 * S11 - square(S12))b1 = may - b2*max1 - b3*max2qr = b1 + b2*x1 + b3*x2yl = lowSy1l = summation[length](yl*x1) - (summation[length](yl)*summation[length](x1))/lengthSy2l = summation[length](yl*x2) - (summation[length](yl)*summation[length](x2))/lengthmayl = average[length](yl)b2l = ((Sy1l * S22) - (Sy2l*S12))/(S22*S11 - square(S12))b3l = ((Sy2l * S11) - (Sy1l * S12))/(S22 * S11 - square(S12))b1l = mayl - b2l*max1 - b3l*max2qrl = b1l + b2l*x1 + b3l*x2period = round(p/2)+1hh = qr[period]ll = qrl[period]countH = 0countL = 0for i = 1 to period-1 doif qr[i]<hh thencountH=countH+1endifif qrl[i]>ll thencountL=countL+1endifnextfor i = period+1 to p+1 doif qr[i]<hh thencountH=countH+1endifif qrl[i]>ll thencountL=countL+1endifnextindicator1 = Average[q](close)c1 = (close < indicator1)indicator2 = Average[w](close)c2 = (close > indicator2)indicator3 = Average[r](close)c3 = (close crosses over indicator3)indicator4 = Average[t](close)c4 = (close crosses under indicator4)indicator5 = Average[qq](close)c5 = (close < indicator5)indicator6 = Average[qq](close)c6 = (close > indicator6)if countH=p and c1 thenbuy 1 contract at marketendifif c3 and c5 thensell at marketendifif countL=p and c2 thensellshort 1 contract at marketendifif c4 and c6 thenexitshort at marketendifINDICATOR// IQS-V1 //// SWING INDICATOR - OMX //// CREATED BY JCAP 18.08.27 ////BASED ON https://www.prorealcode.com/prorealtime-indicators/quadratic-semaphore/ //a=6b=15//x=130q=40w=60r=40//125//150t=100//u=4//c=125qq=340length = ap=bx1 = barindexx2 = square(x1)y = highS11 = summation[length](x2) - square(summation[length](x1))/lengthS12 = summation[length](x1*x2) - (summation[length](x1) * summation[length](x2))/lengthS22 = summation[length](square(x2)) - square(summation[length](x2))/lengthSy1 = summation[length](y*x1) - (summation[length](y)*summation[length](x1))/lengthSy2 = summation[length](y*x2) - (summation[length](y)*summation[length](x2))/lengthmax1 = average[length](x1)max2 = average[length](x2)may = average[length](y)b2 = ((Sy1 * S22) - (Sy2*S12))/(S22*S11 - square(S12))b3 = ((Sy2 * S11) - (Sy1 * S12))/(S22 * S11 - square(S12))b1 = may - b2*max1 - b3*max2qr = b1 + b2*x1 + b3*x2yl = lowSy1l = summation[length](yl*x1) - (summation[length](yl)*summation[length](x1))/lengthSy2l = summation[length](yl*x2) - (summation[length](yl)*summation[length](x2))/lengthmayl = average[length](yl)b2l = ((Sy1l * S22) - (Sy2l*S12))/(S22*S11 - square(S12))b3l = ((Sy2l * S11) - (Sy1l * S12))/(S22 * S11 - square(S12))b1l = mayl - b2l*max1 - b3l*max2qrl = b1l + b2l*x1 + b3l*x2period = round(p/2)+1hh = qr[period]ll = qrl[period]countH = 0countL = 0for i = 1 to period-1 doif qr[i]<hh thencountH=countH+1endifif qrl[i]>ll thencountL=countL+1endifnextfor i = period+1 to p+1 doif qr[i]<hh thencountH=countH+1endifif qrl[i]>ll thencountL=countL+1endifnextindicator1 = Average[q](close)c1 = (close < indicator1)indicator2 = Average[w](close)c2 = (close > indicator2)indicator3 = Average[r](close)c3 = (close crosses over indicator3)indicator4 = Average[t](close)c4 = (close crosses under indicator4)indicator5 = Average[qq](close)c5 = (close < indicator5)indicator6 = Average[qq](close)c6 = (close > indicator6)atr = averagetruerange[length]if countH=p and c1 thenDRAWARROWUP(barindex,low-atr/4) coloured(0,200,0)endifif c3 and c5 thendrawtext("SL",barindex[0],high+atr/4,dialog,bold,15) coloured(255,128,0)endifif countL=p and c2 thenDRAWARROWDOWN(barindex[0],high+atr/4) coloured(200,0,0)endifif c4 and c6 thendrawtext("ES",barindex[0],high+atr/4,dialog,bold,15) coloured(0,191,255)endifreturnI´m running the code/indicator on Sweden 30 OMX daily (it´s the same issue on other markets and timeframe).
09/03/2018 at 1:41 PM #79643Indicator works on my Platform, unless I have misunderstood the Issue?
More later … Grandkids hogging my computer! 🙂
1 user thanked author for this post.
09/03/2018 at 1:52 PM #79645Look at my pictures.
Run the backtest and you can see that there´s inconsistencies between the backtest and indicator. Indicator shows positions that the backtest dosen´t take and the other way around. There´s also some large gaps between indicator positions and backtest positions.
1 user thanked author for this post.
09/03/2018 at 2:03 PM #79646I think that your indicator and your strategy does not share the same settings because all is correct in my own tests (picture attached). Please double check the variables a,b,w, etc. and if they have the same values.
1 user thanked author for this post.
09/03/2018 at 2:33 PM #79653I have the same settings in the backtest and indicator. Right now i have the timesettings at 00:00-00:00 and it get´s even worse if I change it to the real trading hours for omx (09:00-17:30).
09/03/2018 at 2:52 PM #79655Hmmmm .. everything’s working perfectly for me.. please compare your time settings (right click on the price chart and choose ‘custom trading hours’).
Are you with IG? Real or demo account?
Could someone help us with a backtest?
09/03/2018 at 3:16 PM #7965809/03/2018 at 3:47 PM #7966309/03/2018 at 5:34 PM #79668Thanks for your answers. I´m with IG on a demo account with real time data.
I´ve added pictures the timesettings that I´ve used when posting pictures here (00:00-00:00) and the timesettings that I want to use (09:00-17:30, no weekend data, apply settings to non intraday).
09/03/2018 at 5:45 PM #79671Sorry for double posting but I tried to add the “weekend data” and now everything works.
But why is it like this? If I change the timesettings, isn´t the backtest on the new settings then? I just want real data, not IG data…
09/03/2018 at 6:21 PM #79675You can change the settings you like, but candles keep being built on real incoming data by IG, so you won’t see weekend data, but those data are still used to calculate indicators.
I know this because I used to hide weekend data myself and backtests were different from what I could see on the screen.
2 users thanked author for this post.
09/04/2018 at 9:55 AM #79712Oh that´s just shit. I want to be able to trade this strategy outside of IG because tax regulations.
But I guess that I can trade after the strategy (algo) tho it seemes to care about my timesettings, I will have a one or two days delay but it´s better than nothing I guess. Thanks for your answers.
-
AuthorPosts
Find exclusive trading pro-tools on