Number of bars that are executed before Zorro begins to trade (default = 80). Required for indicators that derive a value from a time period in the past. Set it to a value that is sure to cover the longest indicator time period, or to 0 when no lookback period is required.
Strips off the given period (default = 40) from cumulative indicators.
Some indicators, even when calculated over a finite period, are influenced by an infinite number of past bars. They are cumulative - indicators "with memory". Examples are the EMA (Exponential Moving Average) and the ATR (Average True Range). They use their previous bar's value in their algorithm, which in turn use the value of their previous bars, and so forth. This way a given value will have influence on all the subsequent values. In contrast, a simple moving average (SMA) only reflects the average of its period, without any influence from bars further in the past.
Because a price series is always finite and starts at a certain point, the affect of missing past bars is the more significant, the closer to the start a cumulative indicator is calculated. Thus a trade strategy using the EMA or derived indicators (such as the MACD) could behave different dependent on its bar number. The UnstablePeriod value allows to strip off such initial unstable period and remove the influence of all bars prior to this period. This way indicators are guaranteed to behave the same way regardless of the amount of past data. For coming as close to the real cumulative formula as possible, strip off as much data as you can afford. Getting rid of 40 bars (default) is reasonable for most indicators.
Maximum number of trades per asset and bar of the simulation period (default = 1). If more trades are opened, an error message (Error 049) will be issued. Set this to a higher value when the strategy needs to enter an unusual number of trades, for instance for grid trading or for training an advise function.
Minimum daily trading time of the least traded asset in minutes (default = 360, i.e. 60 minutes * 6 hours). Internally used for determining the maximum lookback time. Set this to a lower value when Error 047 indicates that the lookback period gets not enough historical bars at trading start. This can be the case when an asset is only traded a few hours per day, or when you use a bar function that produces only a few bars per day.
- All variables on this page must be set before loading an asset.
- The number of the first bar at which a trade can be entered is greater or equal to Lookback.
- If LookBack is too small, it will be normally automatically adapted to the maximum time period of all used indicators, and a message "Lookback set to nnnn bars" will be printed to the window and log file. Automatic adaption is not always possible, for instance when different time frames are used or when indicator time periods change during the simulation, f.i. in a training run. Automatically increasing LookBack can also affect the result in an unexpected way because the back test period gets shorter when the lookback period gets longer. For this reason, it is strongly recommended to set LookBack manually in all scripts that are trained or use different time frames.
- If indicators get their data from other indicators - for instance, taking the a SMA of another SMA, or normalizing the value of an indicator - LookBack should be set to at least the sum of all time periods in the indicator chain.
- If LookBack is still too small for a certain indicator or other function - this can happen when UnstablePeriod was changed, or when the indicator time period is not known at the first run of the strategy - an error message will be issued. Set LookBack then to a higher value.
- When using series with an offset (f.i. myseries+n), make sure that LookBack is always higher than the required lookback period of the series plus UnstablePeriod plus the highest offset. Otherwise the series length can be exceeded, resulting in a script error at runtime.
- When optimizing the time period of an indicator, make sure that LookBack is big enough to cover the maximum time period of the optimize range, plus the UnstablePeriod when the indicator is cumulative.
- UnstablePeriod is not used for all cumulative indicators. Cumulative indicators that use series - such as LowPass, DominantPeriod, UO, etc. - use LookBack as unstable period. After the lookback period they can have still differences, but they are negligible.
- In [Trade] mode (see Trading), up to 1 year price history covering the LookBack period is downloaded from the server immediately before trading starts. Thus the lookback duration must not exceed one year for live trading a system (unless PRELOAD is set and price history is already available). A too long lookback period will be indicated with a warning message. Due to weekends and market hours, the lookback duration is normally longer than LookBack * BarPeriod.
UnstablePeriod = 60;
LookBack = 120+UnstablePeriod; // required for ATR(120)
Stop = ATR(120);
bar, BarPeriod, TimeFrame, BarOffset, dayHigh, Date
► latest version online