Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

previous hight low

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

    previous hight low

    I want create a script in NT8, this script paint horizontal line with the hight and low price of yesterday, the script fails and i couldnt resolve this,

    protected override void OnBarUpdate()
    {
    if (Bars.IsFirstBarOfSession && CurrentBar > 0)
    {
    DateTime currentSessionDate = Time[0].Date;

    if (lastDayProcessed != currentSessionDate)
    {
    previousDayHigh = High[HighestBar(High, CurrentBar - 1)];
    previousDayLow = Low[LowestBar(Low, CurrentBar - 1)];
    lastDayProcessed = currentSessionDate;

    // Elimina las líneas anteriores si existen
    RemoveDrawObject("PreviousDayHighLine");
    RemoveDrawObject("PreviousDayLowLine");

    // Dibuja las nuevas líneas horizontales
    Draw.Line(this, "PreviousDayHighLine", 0, previousDayHigh, -20, previousDayHigh, Brushes.Orange);
    Draw.Line(this, "PreviousDayLowLine", 0, previousDayLow, -20, previousDayLow, Brushes.Orange);
    }
    }
    }


    Thanks!!

    #2
    Hello dcriador,

    Thank you for your post.

    In what way is the script failing? Is there unexpected behavior, if so please describe the behavior in detail.

    Are there errors in the Log tab of the Control Center?

    You can use the PriorDayOHLC() indicator to get the high and the low of the previous session.



    Please note your script is removing the same drawing object and redrawing it on each pass of OnBarUpdate(). Is this what you are looking to do?

    I look forward to your response.

    Comment


      #3
      Draw not exist in current context
      Click image for larger version

Name:	image.png
Views:	56
Size:	62.0 KB
ID:	1287161

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      78 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X