Hi,
In prorealtime charts you can set the system to colour code when a Moving Average is in an uptrend and when it is in a downtrend.
If you want to use this in a automated strategy, e.g. you create an indicator which is the 50day moving average basis closing prices.
then you want to code the system such that it can identify if the 50MA is an uptrend or a downtrend.
what i cant find is how you write this in code.
any ideas please?
If the color is green, trend is up, basically it means that the current value of the indicator is higher than the previous period one. So for a simple moving average, it would mean:
//define your indicator
indi = average[20]
//trend is bullish? (green) result = 1 if true
result = indi>indi[1]
and opposite rule for a bearish trend. Hope it helps, sorry for delay answering your question.