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 Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              646 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              367 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              107 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              569 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X