Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

On SampleMultiTimeFrame

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

    On SampleMultiTimeFrame

    Hi NT experts,

    In your sample code on SampleMultiTimeFrame, the condition is to process event on BarsInProgress =0:
    if (BarsInProgress != 0)
    return;

    However, the following code starts to evalaute values on BarsInProgress 1 and 2:
    if (SMA(BarsArray[1], 5)[0] > SMA(BarsArray[1], 50)[0] && SMA(BarsArray[2], 5)[0] > SMA(BarsArray[2], 50)[0])

    I would assume SMA(BarsArray[1], 5)[0] would produce an error as it tries to get value from BarsArray[1] instead of 0.

    A realted question. What if no such contions as
    if (BarsInProgress != 0) return;

    Will this sample prouce same results?

    Regards,



    #2
    With this check we ensure that OnBarUpdate() calls only would have an effect when being issued from the primary series, all other calls would cause a return out.

    You can still check the BarsArray 1 and 2, as this is just a 'container' offering access to all the bars objects data points, however the call to check the specific array you need will only come from an OnBarUpdate() from the primary series.

    If not ensuring proper BIP calls, the orders for example good get routed to wrong objects, as the call is EnterLong() without including a specific BIP.

    Comment


      #3
      Thanks, Bertrand.

      Let me paraphrase to see if my understanging is accurate:

      a) The data and calculation of secondary series are accessiable when processing event on primary series.

      b) the following should work under the condition (if (BarsInProgress != 0) return:
      EnterLongStop(0, true, int quantity, Highs[1][1],string signalName).
      The High of previous bar's high on seconary series will be correctly evaluated when submitted this order from primary series.

      Let me know if these are correct.

      Regards,

      Comment


        #4
        This is correct BinWang2.

        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
        60 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