Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using the DrawText() function from inside a strategy script

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

    using the DrawText() function from inside a strategy script

    I want to use DrawText() to print information on the chart panel when I apply the strategy to the chart. However, none of the information I am trying to print appears on the chart panel.


    BTW, even though I am doing this inside a strategy, my strategy is in fact a "multiple timeframe indicator". I made it a strategy because I can't have multiple time frames in the same indicator script.

    What I am trying to do for a N-timeframe strategy in my on bar update method is:



    int i0 = BarsInProgress;
    if(i0 > 0) {

    calculate indicatorvalue[i0] where indicatorvalue is an N-size array containing the indicator value on each of the time frames processed by my strategy

    return;
    }
    else { use DrawText() to print the indicator value in each timeframe }




    Can someone please help?

    #2
    clksoft,

    Please check your Control Center logs for any errors. Please post your exact line of code for DrawText() being used. Thank you.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks. I see that my strategy failed to initialize. I was trying to add bar arrays with periods 2x, 4x, 8x and 16x that of the chart to which I apply the strategy with the following in my initialize:

      Add(BarsArray[0].Period.Id, 2*BarsArray[0].Period.Value);
      Add(BarsArray[0].Period.Id, 4*BarsArray[0].Period.Value);
      Add(BarsArray[0].Period.Id, 8*BarsArray[0].Period.Value);
      Add(BarsArray[0].Period.Id, 16*BarsArray[0].Period.Value);

      That caused the following to appear in the log:

      1/10/2010 4:54:11 PM|3|128|Failed to call method 'Initialize' for strategy 'clk0': 'BarsArray' property can not be accessed from within 'Initialize' method

      Is there another way to do what I am trying to do without knowing in advance what interval BarsArray[0].Period.Value will be when I apply the strategy to a chart?

      Comment


        #4
        You cannot use BarsArray[] in Initialize(). The bars objects do not exist yet. You have to type out what you want exactly.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks. It's all working the way I want it now. Too bad I have to decide in advance what my multiple timeframes will be though!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          637 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
          571 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X