cfgParticipant
New
Hi,
As the title says… anyone knows how to calculate and display in the chart the distance in pips between two simple moving averages? i.e. SMA 300 and SMA 20.
Thnx
cfg
Post your topic in the correct forum:
_ ProRealTime Platform Support: only platform related issues.
_ ProOrder: only strategy topics.
_ ProBuilder: only indicator topics.
_ ProScreener: only screener topics
_ General Discussion: any other topics.
_ Welcome New Members: for new forum members to introduce themselves.
I moved it from ProRealTime Platform Support.
Thank you 🙂
This will display both averages and the difference as an average of the difference from Sma300 (to be added ON the price chart):
Sma20 = average[20,0](close)
Sma300 = average[300.0](close)
Diff = Sma20 - Sma300
Return Sma20 as "Sma20", Sma300 as "Sma300",(Sma300-Diff) as "Difference"
This one will plot a line for the sole difference (to added BELOW the price chart):
Sma20 = average[20,0](close)
Sma300 = average[300.0](close)
Diff = Sma20 - Sma300
Return Diff as "Difference"
cfgParticipant
New
Hi Robertogozzi, thank you for your message.
Apologies for posting in the wrong section.
Both indicators are working correctly, but I cannot understand the “difference”. The difference in pips between 119.868 and 119.739 cannot be 119.97, but 0.129. How can I display the difference in pips between the two simple moving averages? i.e +32 when sma20 superior to sma300 or -32 when sma20 is below sma300.
Thanks in advance.
cfg
Use the second one, you will have to put it UNDER the price (not ON it), like Macd, etc…, because they are not on the same scale.
The first one cannot work, actually.
In both indicators 300.0 must be replaced with:
300,0
ZigoParticipant
Master
It can also like this:
//Zigo
//4/05/2021
MA300=Average[300](close)
MA20=Average[20](close)
diff=round(MA300-MA20)
a= ((MA300+MA20)/2)
if diff -diff[1] <0 then
r=0
g=155
bl=155
elsif diff-diff[1]>0 then
r=255
g=0
bl=0
endif
DRAWTEXT(" #diff#", barindex, a, dialog, standard, 12)coloured(r,g,bl,255)
return
cfgParticipant
New
Good morning Zigo,
Thank you for your message.
Your code seems to be working well, but it doesn’t display the pips in numbers as in your picture.
Does it work for pro-real-time?
Because the rounding isn’t using decimals, try with a value transformed in points:
//Zigo
//4/05/2021
MA300=Average[300](close)
MA20=Average[20](close)
diff=round((MA300-MA20)/pointsize)
a= ((MA300+MA20)/2)
if diff -diff[1] <0 then
r=0
g=155
bl=155
elsif diff-diff[1]>0 then
r=255
g=0
bl=0
endif
DRAWTEXT(" #diff#", barindex, a, dialog, standard, 12)coloured(r,g,bl,255)
return
cfgParticipant
New
Hi Nicolas.
Thank you for your message.
It is working now, thank you so much. Can you clarify if this code would work with JPY pairs?
Yes it works OK with forex pairs with JPY.