I would like to do a comparision with moving averages in radar. currently I look at the 200 day moving average with the following syntax average(close,200) I would like to do a comparison with the current MA and the MA from 20 bars ago. I am hoping for something that looks like average(close,200) - average(close,200,20) with the final 20 in the syntax to indicate that I want to look at the value of the MA 20 bars ago Any idea on how to get this done?
I don't use TS, but it's fairly easy in a spreadsheet like excel. Just take MA(n) in any column, then copy and paste special(values) the data into another column shifted up or down 20 cells; subtract the two columns. DONE.
if barnumber >= 220 then value1 = (( average(close,200) - average(close,200)[20] ) / average(close,200)[20] ) * 100; this litle calcuation will give you the percentage difference between current ma and the 20bar back ma if you only wish to have the difference as price you allready gave the example yourself if barnumber >= 220 then value1 = average(close,200) - average(close,200)[20]; // the nr between the displacements is the amount of bars you wish to look back to compare both value's
Thank you for all your responses. Let me take this one step further and ask if this would be the correct syntax to get the value of the 200MA from 20 bars ago value1 = average(close,200[20]) so that I could further use it in this way if average(close,200,[20]) - average(close,200) then X = 1 end does this work? Thank you
yes, but your displacement is in the wrong area it comes either emediatly behind close or behind the ma's declaration example value1 = average(close,200); value2 = ( value1 - value1[20] ); in this case value2 is the difference between the both of them from here you could go further if value2 >= somenumber then begin go get some beer end;
Thank you for pointing that out. I tried average(CLOSE[20],200) in my EL and did not get an error. As I understand average(CLOSE[20],200) = 200MA 20 bars ago ? Thanks again Robert
[ yes whatever number you write between these 2 displacements is the amount of bars back you wish to make your calculation ] so no displacements is current value [0] is also current value [50] is value of 50 bars back PHP: close - close[10] would mean close minus close of 10 bars back