Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter positions only after script has been started

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Enter positions only after script has been started

    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.

    #2
    Hello BillCh,

    I suggest to review the information at the forum thread below.


    You will need to use:

    if (Historical)
    return;

    Comment


      #3
      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?

      Comment


        #4
        Hello BillCh,

        I see . Please see the link below.


        Correct, it will loop and return on historical data in your chart.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        61 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X