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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      55 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      132 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X