Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawTest issue within Strategy

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

    DrawTest issue within Strategy

    I've ran into this strange issue with using DrawText within a Strategy. For some reason, the following statement will cause all labels/plots to disappear from my chart.

    DrawText("PH" + CurrentBar, "Current High", barsFromHigh, High[barsFromHigh], Color.Blue);

    I've painstaking gone through what is causing my labels/plots to disappear from the above statement and I've found the culprit is passing the variable "barsFromHigh" for the int barsAgo parameter. So if instead I used the following statement, everything would work.

    DrawText("PH" + CurrentBar, "Current High", 0, High[barsFromHigh], Color.Blue);

    What is going on? The first statement works if I use it within an Indicator, but not for a Strategy? Why can't I pass a variable to int barsAgo?

    Your help would be greatly appreciated. Thanks

    #2
    Hello,



    In your log tab do you see an error that says something like "Index out of Range.."? If so, please visit this link:



    It is likely that your number of bars ago exceeds the number of bars on the chart.
    DenNinjaTrader Customer Service

    Comment


      #3
      Hi, thanks for your reply. However, that is not the problem I having. The bars ago number is not out of range. In fact, I am able to print out the bars ago value, just not pass it into the parameter for DrawText.

      Comment


        #4
        Hello,

        If you aren't already, please Print() the value out right above the DrawText() like this:

        Print(barsFromHigh);
        DrawText("PH" + CurrentBar, "Current High", barsFromHigh, High[barsFromHigh], Color.Blue);

        Does the value have a decimal in it or is it an integer? Is it negative or positive? It must be an integer (whole number) and it must be positive.

        Also, what do you have barsFromHigh declared as? It must be declared as an integer something like this:

        int barsFromHigh = 0;

        Just to confirm, you are not getting the Index out of Range error in your log tab?

        The best way to debug these type of errors is to use a try-catch block. Please see this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=9825
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        639 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        572 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X