• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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]);
    Paul H.NinjaTrader Customer Service

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by U0000999, Yesterday, 11:49 PM
      2 responses
      7 views
      0 likes
      Last Post U0000999  
      Started by Mberg, Today, 03:29 AM
      0 responses
      4 views
      0 likes
      Last Post Mberg
      by Mberg
       
      Started by TazoTodua, Today, 03:24 AM
      0 responses
      4 views
      0 likes
      Last Post TazoTodua  
      Started by ahadari28, Yesterday, 04:01 PM
      2 responses
      9 views
      0 likes
      Last Post ahadari28  
      Started by NinjaCustomer, Today, 12:14 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Marco  
      Working...
      X