- Code: Select all
if ich.CS[ich.CS:size() - 27] > ich.SL[ich.SL:size() - 27] and
ich.CS[ich.CS:size() - 27] > ich.TL[ich.TL:size() - 27] and
ich.CS[ich.CS:size() - 27] > ich.SA[ich.SA:size() - 27] and
ich.CS[ich.CS:size() - 27] > ich.SB[ich.SB:size() - 27] and
MTF.close[MTF.close:size() - 1] > ich.SL[ich.SL:size() - 1] and
MTF.close[MTF.close:size() - 1] > ich.TL[ich.TL:size() - 1] and
MTF.close[MTF.close:size() - 1] > ich.SA[ich.SA:size() - 1] and
MTF.close[MTF.close:size() - 1] > ich.SB[ich.SB:size() - 1] then
... [do something, like open a trade] ...
In order to see the lagging line you need to look back to position 27 in the history because it lags by 26 periods. The problem is, when the stragegy starts, it generates an "index out of range" error on these tests. I am using the Lua helper script to get prices.
The error goes away if I just put in a dummy counter to burn up some time. However, you seem to need to cycle through 30-60 updates to get past the problem and that takes too long. I have tried to add combinations like Get Price History/Extend Price History and core.UpdateAll but this doesn't seem to work.
How do I get the indicator up and running completely so the strategy runs?