Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem Printing a Line.

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

    Problem Printing a Line.

    I am calculating 2 variables the same way on a day bar update:-

    if(BarsInProgress == 1) //DAY BARS
    {

    pp = Math.Round((Highs[1][0] + Lows[1][0] + Closes[1][0])/3,2);
    ppD = Math.Round((Highs[1][0] + Lows[1][0] + Closes[1][0])/3,2);
    }

    the output window show the result as expected, both pp & ppD are updated at the close of the day bar at 22.00:-

    XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    11/03/2013 21:55:00
    Yesterday Pivot 142.97
    Todays Pivot 142.56
    Todays Pivot Draw 142.56
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    11/03/2013 22:00:00
    Yesterday Pivot 142.56
    Todays Pivot 142.7
    Todays Pivot Draw 142.7
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    12/03/2013 08:05:00
    Yesterday Pivot 142.56
    Todays Pivot 142.7
    Todays Pivot Draw 142.7
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    How here is what I don't understand. I have one line of code that will enter a position based on pp and one line of code that draws a line based on ppD. Both are calculated on 5 min bars.

    if(BarsInProgress == 2)// 5 Min Bars
    {

    DrawLine("pp" + sessionCount, false, Bars.BarsSinceSession, ppD, 0, ppD ,Color.Black,DashStyle.Dash,2); // DRAWS THE LINE BASED ON VALUE ppD

    if(Closes[2][0] > pp && Closes[2][0] < r1) // ENTERS A POSITION BASED ON pp
    {

    if(longEntryR2 != null) CancelOrder(longEntryR2);
    if(longEntryR1 != null) CancelOrder(longEntryR1);
    if(longEntryS1 != null) CancelOrder(longEntryS1);
    if(longEntryS2 != null) CancelOrder(longEntryS2);
    if(longEntryS3 != null) CancelOrder(longEntryS3);
    if(shortEntryR3 != null) CancelOrder(shortEntryR3);
    if(shortEntryR2 != null) CancelOrder(shortEntryR2);
    if(shortEntryR1 != null) CancelOrder(shortEntryR1);
    if(shortEntryPP != null) CancelOrder(shortEntryPP);
    if(shortEntryS1 != null) CancelOrder(shortEntryS1);
    if(shortEntryS2 != null) CancelOrder(shortEntryS2);

    for(int i=0;i < strength;i++)
    {
    if(Lows[2][i] > pp)
    {
    x++;
    }
    else
    break;
    }

    if(x == strength && badTradeCountPP <= lossingTradeAllowance && Position.MarketPosition == MarketPosition.Flat && longEntryPP == null)
    {
    longEntryPP = EnterLongLimit(0,true, 1,pp + entryAllowance * TickSize , "Long Entry PP");
    }

    x = 0;
    }

    so if we take the example in the output windows on the 12/03/2013 it should base its entry on pp which is 142.70 and draw a line based on ppD at 142.70.

    BUT what is happening is the positions are being placed correctly at 142.70 BUT the line is being drawn at TOMORROWS value of ppD at 142.92?

    I bet it has something to do with historical data, but I don't understand why it would show the correct value in the outputwindow and print the line differently.

    #2
    GKonheiser, from where / which BarsInProgress do you print the confirms? I would always include the timestamp and BarsInProgress to better see the event sequence your script runs through.

    From a quick glance at the code, the drawing seems to be based ppD while the actual order then is tied the pp + your tick offset, did you factor in those price differences when reviewing?

    Comment


      #3
      Yes the ticks offset is set to 0. In the output window I have the time stamp, I will include the bars in progress and get back to you with an output.

      Comment


        #4
        As you can see from the output below, both pp and ppD are updating correctly, the line after the date shows BarsInProgress 2 which are 5 min bars and BarsInProgress 1 which are Day bars. So I just don't understand why we have the difference in what the output window is showing and what is on the chart?

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        09/05/2013 21:40:00
        2
        Yesterday Pivot 145.69
        Todays Pivot 145.72
        Todays Pivot Draw 145.72
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        09/05/2013 21:45:00
        2
        Yesterday Pivot 145.69
        Todays Pivot 145.72
        Todays Pivot Draw 145.72
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        09/05/2013 21:50:00
        2
        Yesterday Pivot 145.69
        Todays Pivot 145.72
        Todays Pivot Draw 145.72
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        09/05/2013 21:55:00
        2
        Yesterday Pivot 145.69
        Todays Pivot 145.72
        Todays Pivot Draw 145.72
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        ssssssssssssssssssssssssssssssssssssssssssssssssss sssssssssssss
        09/05/2013 22:00:00
        1
        Yesterday Pivot 145.72
        Todays Pivot 145.96
        Todays Pivot Draw 145.96
        ssssssssssssssssssssssssssssssssssssssssssssssssss ssssssssssssss
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        09/05/2013 22:00:00
        2
        Yesterday Pivot 145.72
        Todays Pivot 145.96
        Todays Pivot Draw 145.96
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        10/05/2013 08:05:00
        2
        Yesterday Pivot 145.72
        Todays Pivot 145.96
        Todays Pivot Draw 145.96
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        10/05/2013 21:55:00
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        10/05/2013 08:10:00
        2
        Yesterday Pivot 145.72
        Todays Pivot 145.96
        Todays Pivot Draw 145.96
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        10/05/2013 08:15:00
        2
        Yesterday Pivot 145.72
        Todays Pivot 145.96
        Todays Pivot Draw 145.96
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        10/05/2013 08:20:00
        2
        Yesterday Pivot 145.72
        Todays Pivot 145.96
        Todays Pivot Draw 145.96
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

        Comment


          #5
          Thanks GKonheiser, cannot see a reason immediately from those details, however might be able after having it run on our end, would that be ok? If so could you please get in touch with me directly at support at ninjatrader dot com?

          One thing to keep in mind with the bars updating is that for NT a bar is not closed until the open tick of the new bar is seen, so the day bars would still be open at 22:00 if in backtesting and CalculateOnBarClose = true.

          Comment


            #6
            Just sent you a mail. Thanks very much.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            672 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            379 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            111 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            577 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            582 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X