This example should help , notice the indicator values are saved to variables which are type bararray , then you can access past values
'******************************** ' Simple Dual moving average crossover ' TradersStudio(r) 2004-2007 , All rights reserved
Sub MovingAveSystem(SLen As Integer, LLen As Integer) Dim ShortAve As BarArray Dim LongAve As BarArray ShortAve = Average(Close, SLen,0) LongAve = Average(Close, LLen,0) If ShortAve > LongAve And ShortAveΏ] < LongAveΏ] Then Buy("BuyEnt",1,0,Market,Day) End If If ShortAve < LongAve And ShortAveΏ] > LongAveΏ] Then Sell("SellEnt",1,0,Market,Day) End If End Sub
|