Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Orders entered using Calculated Bands do not enter correctly.

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

    Orders entered using Calculated Bands do not enter correctly.

    This is the strategy that does not work correctly. I think it has something to do with the using the variables as conditions to enter orders. I have used print statements to be sure that the bands calculate correctly and they do. I think maybe I'm not using the correct type of variable or something. Can someone see the flaw?

    Thanks.


    protected override void Initialize()

    {

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()

    {

    {
    // Use this code to setup the upper and lower bands
    // Offset
    double offset = ATR(14)[0] * bandFactor;
    // Lower Band
    double Variable6 = SMA(14)[0] - offset;
    // Upper Band
    double Variable7 = SMA(14)[0] + offset;

    Print("offset = " + offset.ToString());

    }



    {


    {
    if (BarsInProgress == 0)
    {


    // Condition set 1 (Long Entries)
    if (Close[0] >= Open[0]
    && Close[0] >= Variable6
    && Low[1] <= Variable6)

    {
    EnterLong(DefaultQuantity, "");

    }

    #2
    If you mean that EnterLong() never issues a market order then it is likely since it is never called...your code never reaches it. Print out the data in the condition required to call the EnterLong() method to see what values are contained in the variables and work back from there.
    RayNinjaTrader Customer Service

    Comment


      #3
      In my opinion, you should put your band calculation logic into an indicator and do an Add( ) in your Initialize, you'd be able to see the bands on the chart and it would be obvious to you what is happening. If you don't want to do that, for the time being you can just do:

      DrawDot("var6"+CurrentBar, 0, Variable6, Color.Blue);
      DrawDot("var7"+CurrentBar, 0, Variable7, Color.Yellow);

      right after your calculations and again, it should make it easy for you to figure out.

      Comment


        #4
        I performed the print and confirm that the calcs work. I'll keep trying Ray.

        Pete,

        Thanks for the code! I will try to do an indicator. I tried to do the draw statements but they locked my NT up 2 times.

        Thanks Again.

        dendy.

        Comment


          #5
          Thanks again Pete,

          Your suggestion works great. Make the indicator and then use the add command to see what's happening. The orders also work correctly now.

          Have a good one...........

          dendy.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          601 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          347 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          559 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          558 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X