Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Instrument. Logic problem?

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

    Multi-Instrument. Logic problem?

    Hy guys, I'm trying to code an easy program but it doesn't work. Exactly (version semplified):

    protected override void Initialize()
    {
    SetStopLoss("Long", CalculationMode.Ticks, 10, false);
    CalculateOnBarClose = true;
    AddRenko("CL 10-12", 3, MarketDataType.Last);
    AddRenko("CL 10-12", 4, MarketDataType.Last);
    AddRenko("CL 10-12", 5, MarketDataType.Last);
    }

    protected override void OnBarUpdate()
    {
    if (Condition1)
    {
    if (BarsInProgress == 0)
    {
    Do this
    }
    }

    if (Condition2)
    {
    if (BarsInProgress == 1)
    {
    Do this
    }
    }
    if (Condition3)
    {
    if (BarsInProgress == 2)
    {
    Do this
    }
    }
    if (Condition4)
    {
    if (BarsInProgress == 3)
    {
    Do this
    }
    }
    }


    The problem is that the strategy ONLY uses the primary bars object (Renko=2, that I enter in the strategy tab) though Condition1 is not true but Condition2,3or4 are true. Ideas?

    Thanks to all and have a good day!

    #2
    mirkocero, how do you know that the added bars are not used? Your added series would not be visualized per default but made available internally for calculations and order submissions - if you add Print statements to further debug to each condition, what you see reported in the output window?

    Comment


      #3
      Thanks for the quickly reply!
      I know it because the order placed in the market depends on the added bars object. All the orders placed are right if we only consider the primary bars object. But I don't understand why, if condition1 is not true, the strategy continues to use the primary bars object to put orders.

      I will add now the Print Statement...

      Comment


        #4
        Can you please post the order entry call snippet you use in your code? Do you submit to a specific BarsInProgress?

        Comment


          #5
          I'm using this one. Example on secondary bars object:
          if (BarsInProgress == 1)
          {if (Indicator(BarsArray[1], val1, val2)[0] > Close[0])
          {
          EnterLongLimit(0, true, 1, Indicator(BarsArray[1], val1, val2)[0] , "Long");

          Comment


            #6
            Thanks, but here you still submit to the primary series only - albeit on an update coming from the second series.

            EnterLongLimit(0, true, 1, Indicator(BarsArray[1], val1, val2)[0] , "Long");

            Comment


              #7
              Thanks! I will try it as soon as it possible!

              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