View Full Version : Enter positions only after script has been started
BillCh
04-08-2009, 01:27 AM
How can a script be coded to avoid having positions entered when script is started on a chart and chart contains past data which would have met entry (and exit) criteria already in the past? In other words, the first entry should only be possible at or after the script was launched.
NinjaTrader_Jason
04-08-2009, 03:15 AM
Hello BillCh,
I suggest to review the information at the forum thread below.
http://www.ninjatrader-support2.com/vb/showthread.php?p=87841#post87841
You will need to use:
if (Historical)
return;
BillCh
04-08-2009, 04:34 AM
Thanks Jason
When I put this at the beginning of my OnBarUpdate() loop I assume it just returns and loops until live data is being processed, so no "executions" on historical data. But I assume that a lookback period would still work on the first live bar, like SMA(14), as long as at least 13 histroical bars are available, right?
Btw, your reference is a link to this thread here, I guess you wanted to refer to another link?
NinjaTrader_Jason
04-08-2009, 04:40 AM
Hello BillCh,
I see :). Please see the link below.
http://www.ninjatrader-support2.com/vb/showthread.php?t=4878&highlight=if+%28Historical%29
Correct, it will loop and return on historical data in your chart.