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:	65
Size:	62.0 KB
ID:	1287161

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      173 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      90 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      129 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      208 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      185 views
      0 likes
      Last Post CarlTrading  
      Working...
      X