I want to use following as a condition to trade:
Subtract numeric value of SMA x from SMA y. Trade if result is bigger/smaller than result of same subtraction in previous period.
Coding/help appreciated.
Thank you.
There you go (bigger):
x = abs(average[20,0](close) - average[50,0](close))
If x > x[1] Then
.
.
Endif
You may want to remove ABS( and the rightmost parenthesis if you want to have both positive and negative values.
Thank you.
Very helpful.
Last tweak: What to do if I want to use SMA of mean price of last bar, not close?
Thank you.
Instead of CLOSE use MedianPrice.
What do you mean by “SMA of mean price of last bar“? (The sma of mean price of the last bar is the mean price of last bar itself!)