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

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 arvidvanstaey, Today, 02:19 PM
      4 responses
      10 views
      0 likes
      Last Post arvidvanstaey  
      Started by samish18, 04-17-2024, 08:57 AM
      16 responses
      56 views
      0 likes
      Last Post samish18  
      Started by jordanq2, Today, 03:10 PM
      2 responses
      8 views
      0 likes
      Last Post jordanq2  
      Started by traderqz, Today, 12:06 AM
      10 responses
      18 views
      0 likes
      Last Post traderqz  
      Started by algospoke, 04-17-2024, 06:40 PM
      5 responses
      47 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X