Selection for the first Signal only – help please
Forums › ProRealTime English forum › ProBuilder support › Selection for the first Signal only – help please
- This topic has 3 replies, 2 voices, and was last updated 2 years ago by robertogozzi.
Viewing 4 posts - 1 through 4 (of 4 total)
-
-
12/21/2021 at 8:38 PM #183711
Hello everybody,
I’d like to change the following code so that only the first Green after Red appears (or first Red after Green), i.e. I’d like only the Signals with arrows to appear. The idea is to include this into an Algo where only the first Signal is taken.
I tried with the “CondLongExclusive”, but it didn’t work.
Thanks
First Signal only1234567891011121314151617181920212223242526272829StoK = Stochastic[14,3](close)StoD = Stochasticd[14,3,5](close)MyRSI = RSI[14](close)Cond1 = StoK > StoK[1] and StoK[2] > StoK[1]Cond2 = StoK > StoDCond3 = MyRSI > MyRSI[1]Cond10 = StoK < StoK[1] and StoK[2] < StoK[1]Cond20 = StoK < StoDCond30 = MyRSI < MyRSI[1]SignalLong = 0SignalShort = 0if cond1 and cond2 and cond3 thenSignalLong = +1endifif cond10 and cond20 and cond30 thenSignalShort = -1endifCondLongExclusive=0CondLongExclusive = SignalLong=1 and (SignalShort[1]=-1 or SignalShort[2]=-1 or SignalShort[3]=-1 or SignalShort[4]=-1 or SignalShort[5]=-1 or SignalShort[6]=-1 or SignalShort[7]=-1 or SignalShort[8]=-1)RETURN SignalLong as "Long", SignalShort as "Short"12/23/2021 at 7:48 AM #183790There you go:
12345678910111213141516171819202122232425262728293031323334353637383940StoK = Stochastic[14,3](close)StoD = Stochasticd[14,3,5](close)MyRSI = RSI[14](close)Cond1 = StoK > StoK[1] and StoK[2] > StoK[1]Cond2 = StoK > StoDCond3 = MyRSI > MyRSI[1]Cond10 = StoK < StoK[1] and StoK[2] < StoK[1]Cond20 = StoK < StoDCond30 = MyRSI < MyRSI[1]SignalLong = 0SignalShort = 0if cond1 and cond2 and cond3 thenSignalLong = +1endifif cond10 and cond20 and cond30 thenSignalShort = -1endif//CondLongExclusive=0////CondLongExclusive = SignalLong=1 and (SignalShort[1]=-1 or SignalShort[2]=-1 or SignalShort[3]=-1 or SignalShort[4]=-1 or SignalShort[5]=-1 or SignalShort[6]=-1 or SignalShort[7]=-1 or SignalShort[8]=-1)IF SignalLong THENMySignal = SignalLongENDIFIF SignalShort THENMySignal = SignalShortENDIFx = MySignalIF MySignal = MySignal[1] THENx = 0ENDIFRETURN (x = 1) as "Long", -(x = -1) as "Short"1 user thanked author for this post.
12/25/2021 at 3:05 AM #183831Excellent, thank you so much Roberto and Merry Christmas !
1 user thanked author for this post.
12/25/2021 at 11:08 AM #183836Merry Christmas Khaled, thank you 😊
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
Find exclusive trading pro-tools on
Similar topics: