Help with this Code (cant get an MA to display correctly)
Forums › ProRealTime English forum › ProBuilder support › Help with this Code (cant get an MA to display correctly)
- This topic has 6 replies, 3 voices, and was last updated 5 years ago by VPT PRT.
-
-
02/13/2019 at 9:06 PM #91331
Hi all,
I’m hoping to get some help with a small problem.
In the attached .itf file I have been trying to code in Upper and Lower boundaries (like dynamic reference points). I would like to apply a EMA to the upper and lower boundary plots, but when I try to do this it always ends up changing the original boundary, and all I want is a new EMA plot of the boundary.
Can anyone please tell me where I’m going wrong?
02/13/2019 at 9:14 PM #91334All I want to do is use the EMA to smooth out the boundaries.
So in the picture attached are two EMA’s that I have applied to the two boundaries. I just used the ‘add indicator’ button on the indicator settings tap. I just want to hardwire the EMA’s into the .itf attached…….
Hoping you can help
Thanks
Ross
02/14/2019 at 9:10 AM #9134902/14/2019 at 11:39 AM #91355Thanks for that Nicolas, good point.
Here is the code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465if PeriodsBefore>0 thena = (ExponentialAverage[iFirstMaPeriod](ExponentialAverage[iSecondMaPeriod](ROC[1](close[PeriodsBefore]))))b = (ExponentialAverage[iFirstMaPeriod](ExponentialAverage[iSecondMaPeriod](ABS(ROC[1](close[PeriodsBefore])))))MyMacd = 100 * (a/b)elsea = (ExponentialAverage[iFirstMaPeriod](ExponentialAverage[iSecondMaPeriod](ROC[1](close))))b = (ExponentialAverage[iFirstMaPeriod](ExponentialAverage[iSecondMaPeriod](ABS(ROC[1](close)))))MyMacd = 100 * (a/b)endif//NormMidpointValue = 0//(NormUpperboundary+NormLowerBoundary)/2//MidpointValue =0if NormUpperboundary < MyMacd+ShieldValue thenNormUpperboundary = MyMacd+ShieldValueelseif (NormUpperboundary-ABS(NormUpperboundary-NormLowerBoundary)* Percentage/100)>= MyMacd thenNormUpperboundary = NormUpperboundary-(ABS(NormUpperboundary-NormLowerBoundary)* Percentage/100)endifendifif NormLowerBoundary > MyMacd-ShieldValue ThenNormLowerBoundary = MyMacd-ShieldValueelseif (NormLowerBoundary + ABS(NormUpperboundary-NormLowerBoundary)* Percentage/100) <= MyMaCD thenNormLowerBoundary = (NormLowerBoundary + (ABS((NormUpperboundary-NormLowerBoundary))* Percentage/100))endifendifIndicator = 0Indicator = ((MyMacd - NormLowerBoundary) *200/(NormUpperboundary-NormLowerBoundary) -100)//NormMidpointValue = ((NormMidpointValue - NormLowerBoundary) *200/(NormUpperboundary-NormLowerBoundary) -100)> 100If TypeOfRange >0 thenif UpperBoundary <= TypeOfRange thenUpperBoundary = TypeOfRangeendifendifif Upperboundary < Indicator+RangeShieldValue thenUpperBoundary = Indicator+RangeShieldValueelseif (UpperBoundary-ABS(UpperBoundary-LowerBoundary)* RangePercentage/100)>= Indicator thenUpperBoundary = UpperBoundary-(ABS(UpperBoundary-LowerBoundary)* RangePercentage/100)endifendifUpperBoundary = Average[1](UpperBoundary)If TypeOfRange >0 thenif LowerBoundary >= 0-TypeOfRange thenLowerBoundary = 0-TypeOfRangeendifendifif LowerBoundary > Indicator-RangeShieldValue ThenLowerBoundary = Indicator-RangeShieldValueelseif (LowerBoundary + ABS(UpperBoundary-LowerBoundary)* RangePercentage/100) <= Indicator thenLowerBoundary = (LowerBoundary + (ABS((UpperBoundary-LowerBoundary))* RangePercentage/100))endifendifLowerBoundary = Average[1](LowerBoundary)return Indicator*Multiplier COLOURED(100, 100, 100) as "MACD", UpperBoundary COLOURED(0,0, 255) as "Upper Boundary", 0 COLOURED(255, 0, 0) as "midline", LowerBoundary COLOURED( 0,255, 0) as "Lower Boundary", (UpperBoundary+LowerBoundary)/2 as "range midline"02/14/2019 at 11:55 AM #9135602/14/2019 at 12:01 PM #91357Create a new variable to be used as your displayed value this way you don’t mess up your calculations.
1234UB = ExponentialAverage[10](UpperBoundary)LB = ExponentialAverage[10](LowerBoundary)return Indicator*Multiplier COLOURED(100, 100, 100) as "MACD", UB COLOURED(0,0, 255) as "Upper Boundary", 0 COLOURED(255, 0, 0) as "midline", LB COLOURED( 0,255, 0) as "Lower Boundary", (UB+LB)/2 as "range midline"1 user thanked author for this post.
02/14/2019 at 9:49 PM #91425 -
AuthorPosts
Find exclusive trading pro-tools on