I've read somewhere on the forums that it is more efficient to assign a frequently used variable under OnStartUp() instead of calling it separately under OnBarUpdate().
For example, I have the following code:
private SMA sma3; private double tempVar1 = 0, tempVar2 = 0; protected override void Initialize() { Add(PeriodType.Day,1); } protected override void OnStartUp() { if (sma3 == null) sma3 = SMA(3); } protected override void OnBarUpdate() { if (BarsInProgress == 1) { tempVar = sma3[0]; tempVar1 = SMA(3)[0]; } }
Could someone tell me what I'm doing wrong?
Thanks.
-Nick
Comment