Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Gaby V.NinjaTrader Customer Service

    Comment


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

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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X