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

Draw.TextFixed not working when using strategy on real-time chart.

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

    Draw.TextFixed not working when using strategy on real-time chart.

    I am developing a strategy and want to display the changes in status as the strategy progresses as well as plot some markers on the chart. I am using both the Draw.TextFixed, and Draw.Text functions as well as others. When I run the strategy in the Strategy Analyzer, the text is displayed as expected. I am also using the Print() function with the same text so I can see it in the NinjaScript Output window. When I enable the strategy on the real-time chart I can see the prints in the Output window, but nothing shows on the chart. It was actually working on the real-time chart for a while, but something changed, and I haven't seen it since. Any clues would be greatly appreciated. I have the same instrument and account selected in the strategy as the real-time window. When orders are created, they do display in the real-time window as expected so I know it is working.

    Also, I am using the Brushes.WhiteSmoke and that works great for me, but if I send this to someone who uses a white background it would not work well. Since the ChartControl.Properties are not available in a Strategy, is there another way to select an appropriate brush? I've also tried the other overloads that don't need the brush, and they work ok also, but if I want access to things like the text alignment, I will have to use an overload that requires a brush.

    Thanks in advance!
    Dave.

    #2
    Hello Dave,

    Welcome to the NinjaTrader forums!

    Just to be sure, you are using unique tag names for each drawing object, is this correct?

    Attached is a test script that prints the bar time and number to the output window. Try adding this to a 1 second chart and see if it updates in realtime.


    The ChartControl is available to Strategies that have been directly added to a chart. You will need to add a check for null before using any ChartControl properties or methods.

    You could use the ChartControl.Properties.ChartText for same color as the rest of the NT text in the chart.

    For example:

    Draw.TextFixed(this, "myTextFixed", "Hello world!", TextPosition.BottomRight, ChartControl.Properties.ChartText,
    ChartControl.Properties.LabelFont, Brushes.Blue, Brushes.Transparent, 0);

    https://ninjatrader.com/support/help...xed.htm​
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the quick response!

      Yes, I am using unique tags with string.Format("{0}_{1:yyyyMMddHHmm}", tag, Time[bar]) where "tag" is a string I pass to my function that identifies what kind of mark I'm making.

      The problem was that I was managing the strategy from the strategy tab in the control center and not adding it to the chart itself. When I right click the chart surface and use the "Strategies..." menu to add my strategy everything shows up ok. Thank you for your help! I can now also use the ChartText brush as well. And yes, I will be sure to check for null before using it.

      Thanks again for your help!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X