Screener daycount only returns 1 – don't know why.
Forums › ProRealTime English forum › ProScreener support › Screener daycount only returns 1 – don't know why.
- This topic has 4 replies, 3 voices, and was last updated 5 years ago by Nicolas.
-
-
04/12/2019 at 7:39 AM #96198
Hi all
I downloaded the Gann Market Model Strategy from the library and edited out the Probacktest code so as to use it as a screener. I also added daycount code that Nicolas assisted me with a while back but can not get it to count. I only get 1(one) all the time for the daycount result. This daycount code works perfectly on other screeners that I have and the code for the “daycount” part is exactly the same.
The edited code is as follows and a screen shot of the results with a circled result clearly not matching the Strategy results. Have poured over this and do not know what is wrong. Any help greatly appreciated.
Thanks
Chris
———————————————————
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293//short terma1= ExponentialAverage[50](high)[1]b1=ExponentialAverage[50](low)[1]if customclose > a1 thenc1 = 1ElseIF customclose < b1 thenc1=-1endifENDIFif c1= -1 thenD1 = a1ELSED1=b1endifa2= ExponentialAverage[100](high)[1]b2=ExponentialAverage[100](low)[1]if customclose > a2 thenc2 = 1ElseIF customclose < b2 thenc2=-1endifENDIFif c2= -1 thenD2 = a2ELSED2=b2endifa3= ExponentialAverage[200](high)[1]b3=ExponentialAverage[200](low)[1]if customclose > a3 thenc3 = 1ElseIF customclose < b3 thenc3=-1endifENDIFif c3= -1 thenD3 = a3ELSED3=b3endifif D1 < close thenresult = 1elseresult = 0endifif D2 < close thenresulta = 1elseresulta = 0endifif D3 < close thenresultb = 1elseresultb = 0endifc10 = (result + resulta + resultb)//Screen for entry condition and start daycountif c10 > 2 THENresultL = 1daycount = 0endif// exit conditionif c10 < 3 THENresultL = 0endif//count days trade openonce daycount = 0IF resultL = 1 and savedate<>Date THENdaycount = daycount + 1savedate = DateENDIFscreener[resultL] (daycount as "days")—————————————————
04/12/2019 at 8:46 AM #96218You can try this version, I changed a bit the way you are finding the start of the signal “resultL”:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192//short terma1= ExponentialAverage[50](high)[1]b1=ExponentialAverage[50](low)[1]if customclose > a1 thenc1 = 1ElseIF customclose < b1 thenc1=-1endifENDIFif c1= -1 thenD1 = a1ELSED1=b1endifa2= ExponentialAverage[100](high)[1]b2=ExponentialAverage[100](low)[1]if customclose > a2 thenc2 = 1ElseIF customclose < b2 thenc2=-1endifENDIFif c2= -1 thenD2 = a2ELSED2=b2endifa3= ExponentialAverage[200](high)[1]b3=ExponentialAverage[200](low)[1]if customclose > a3 thenc3 = 1ElseIF customclose < b3 thenc3=-1endifENDIFif c3= -1 thenD3 = a3ELSED3=b3endifif D1 < close thenresult = 1elseresult = 0endifif D2 < close thenresulta = 1elseresulta = 0endifif D3 < close thenresultb = 1elseresultb = 0endifc10 = result and resulta and resultb//Screen for entry condition and start daycountif c10 and not c10[1] THENresultL = 1daycount = 0//startbar=barindexendif// exit conditionif not c10 THENresultL = 0endif//count days trade openIF resultL = 1 THENdaycount = daycount + 1ENDIFscreener[resultL] (daycount as "days")//(barindex-startbar as "days")I did not compared the days count with the indicator, please do.
04/14/2019 at 3:02 AM #96375Thanks Nicolas. That has got the daycount working (sort of???) It still does not count correctly though. I have attached 2 screen shots showing 2 stocks returning the same 156 days result in the screener.
Problem is their buy dates are about 3 months apart and the strategy shows a continuous hold for these trades. Also I have removed most of the “gann code” and put a simple moving average crossover to buy and my trailing stop to exit to simplify things for this issue.
edited – Just tried changing the long entry from moving averages “greater than” to “crosses over” and got completely different results in the screener – not even the 2 stocks I have attached were in the results. But the strategy with the “crosses over” still shows the same buy dates. what the..
Both the strategy and screener code is below.
1234567891011DEFPARAM CumulateOrders = FalseStopL = call "PRC_StopReversal CPH"[2,5,5,5,1]long = ExponentialAverage[50](close) > ExponentialAverage[100](close)IF Long and not long[1] thenBUY n shares AT MARKETENDIFIF (close) < stopL THENSELL AT MARKETENDIF1234567891011121314151617StopL = call "PRC_StopReversal CPH"[2,5,5,5,1]long = ExponentialAverage[50](close) > ExponentialAverage[100](close)IF long and not long[1] THENresultL = 1daycount = 0ENDIFif (close) < stopL THENresultL = 0endifIF resultL = 1 THENdaycount = daycount + 1ENDIFscreener[resultL] (daycount as "days")Thanks
04/14/2019 at 9:23 AM #9638004/14/2019 at 12:36 PM #96388 -
AuthorPosts
Find exclusive trading pro-tools on