Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to draw text for all historical occurrences

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

    Trying to draw text for all historical occurrences

    Hi, I used EasyLanguage in the past and decided to switch to Ninjascript, I'm quite new to it.

    I think i'm still not clear on how variables work. To keep it simple I'll ask this question, which might help me with the more complex question I have.

    So I want to draw text, an "H" when ZigZag indicator makes a high

    this code gives me how many bars ago a High occurred in ZigZag indi

    Code:
    int first_high_barsAgo = ZigZag(DeviationType.Points, 0.0002, true).HighBar(0, 1, 999);
    So now I know the position of the High. Here below I'm drawing a text at the High.

    Code:
    if  (first_high_barsAgo > -1) 
    {
    Draw.Text(this, @"v3 Text_1", @"H", first_high_barsAgo, High[first_high_barsAgo]);				
    }
    This is all good and works, but when I add this strategy on a chart, the Text "H" keeps moving when a new high occurs. How do I see all historical drawings, and when a new high occurs the text stays in place and an additional new text is written on the new occurrence? I tried turning first_high_barsAgo into a variable and also created a new variable for the High's as well but didn't work. If you could help please...

    Thanks
    Mehm

    #2
    Hello mntemel,

    Thanks for your post and welcome to the NinjaTrader forums!

    Draw objects on the chart must have unique tag names. If you use the same tag name then when a new one is drawn, the previous one is removed.

    To create a unique tag name a common approach is to add the current bar number. For example:

    Draw.Text(this, @"v3 Text_1"+CurrentBar, @"H", first_high_barsAgo, High[first_high_barsAgo]);

    Comment


      #3
      thanks Paul, did the trick, much appreciated!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      29 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      46 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X