Stuck WIth EMA Above Under Above
Forums › ProRealTime English forum › ProBuilder support › Stuck WIth EMA Above Under Above
- This topic has 4 replies, 2 voices, and was last updated 4 years ago by robertogozzi.
-
-
06/24/2020 at 10:48 PM #137059
Hi
I am trying to get a piece of code that measures a close below the ema above the ema and below the ema – I have come up with :-
But its bust 🙁
Any Help gratefully appreciated
123456789101112131415161718192021222324252627282930313233343536373839404142If Barindex > 229 thenFor TP = 24 downto 1 do//Loop 1 Close Below EMAIF close[tp] < ExponentialAverage[8](close)[tp] and close[tp] < ExponentialAverage[20](close) [tp] then//Save When the TP startedTP1=TP//We Found The first CalculationC1 = 1breakelsec1=0endifnextFor TP1 = 24 downto 1 do//Loop 1 Close Below EMAIF close[tp] > ExponentialAverage[8](close)[tp] and close[tp] > ExponentialAverage[20](close) [tp] then//Save When the T2 startedTP2=TP1//We Found The second CalculationC2 = 1breakelsec2=0endifnextFor TP2 = 24 downto 1 do//Loop 1 Close Below EMAIF close[tp] < ExponentialAverage[8](close)[tp] and close[tp] < ExponentialAverage[20](close) [tp] then//We Found The third CalculationC3 = 1breakelsec3=0endifnextendifIf c1 and c2 and c3 thenDRAWTEXT(“ON”,barindex,.1,SansSerif,Bold,10)coloured(0,255,0)endifreturn06/25/2020 at 12:07 AM #137064Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Thank you 🙂
1 user thanked author for this post.
06/25/2020 at 12:24 AM #137069Line 4:
1x = summation[24](close < ExponentialAverage[8](close) and close < ExponentialAverage[20](close))line 17:
1y = summation[24](close > ExponentialAverage[8](close) and close > ExponentialAverage[20](close))line 29:
1z = summation[24](close < ExponentialAverage[8](close) and close < ExponentialAverage[20](close))Lines 4 and 29 are identical, so I must be misunderstanding something.
Moreover, my examples won’t detect adjacent occurrences only, but any occurrence.
More detailed info on what you want to achieve would be beneficial.
1 user thanked author for this post.
06/25/2020 at 3:41 PM #137143Thank you Roberto
I really appreciate your help
The reason for the duplicate is that I want to detect when the close is :-
A. below both the 8 and 20 ema
B. above both the 8 and 20 ema
C. Back below both the 7 and 20 ema
In that order
I hope that’s clearer
06/26/2020 at 12:13 PM #137246There you go:
123456789101112131415161718192021n = 24p1 = 0p2 = 0IF BarIndex > 229 AND close < ExponentialAverage[8](close) and close < ExponentialAverage[20](close)THENFOR i = n - 1 DOWNTO 1IF close[i] < ExponentialAverage[8](close[i]) and close[i] < ExponentialAverage[20](close[i]) THENp1 = iBreakENDIFNEXTFOR j = p1 - 1 DOWNTO 1IF close[j] > ExponentialAverage[8](close[j]) and close[j] > ExponentialAverage[20](close[j]) THENp2 = jBreakENDIFNEXTIf p1 > 0 and p2 > 0 thenDRAWTEXT("ON",barindex,high + range,SansSerif,Bold,10)coloured(0,128,0,255)ENDIFENDIFreturn1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on