Hi Everybody
I wish to include a MA horizontally displaced by n bars in an indicator. I have scoured the manual but it does not include an example that includes this, nor is this option included in the syntax at the end of the manual. If one reads the function help option whilst trying to construct the indicator reference is made to this,again with no example (see attached screen capture). Any help/suggestions greatly appreciated. Thank you.
If you want to draw it on the right of the chart (in the “future”), then it is not possible with code sorry.
If you want to get the value from the moving average from X bars ago, you can, use this kind of code:
X = 10 //you'll get the value of the SMA from 10 bars ago
sma20 = average[20](close)[X]
RETURN sma20
Thanks Nicholas. I realize that PRT cannot plot “into the future”. Will try what you suggest and see if it works.
Just in case it’s ok for you to include your shifted MA on your indicator without coding, it might be worth adding that you may also shift horizontally your MA by hand in the property window of the added MA (top right of the property window, in the box just below the period number), that’s what the function help was refering to without giving example.
Hi Noobywan, yes I am aware of that. Thanks.
What exactly is it that you are looking for? Because a simple linear extrapolation should be possible, at least.
Ind1=ma [20]<br>
Ind2=Roc [10](ind1)
Ind3=ind1+ind2
If close crosses ind3 [10] then…
I hope you get the idea.
Hi Derek
The solution suggested by Nicolas was exactly what I was looking for.
Thanks