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 ntbone, Today, 02:30 PM
          0 responses
          5 views
          0 likes
          Last Post ntbone
          by ntbone
           
          Started by tuliomgui, Yesterday, 10:07 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by Learner Trader, Today, 08:36 AM
          1 response
          24 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by GeorgeW, Today, 03:15 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by timko, Today, 11:55 AM
          4 responses
          11 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Working...
          X