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

Request for new feature: Add Profit Target Price and Stop Price to charts

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

    Request for new feature: Add Profit Target Price and Stop Price to charts

    It would be great if the profit target and the stop value were printed in the backtest result chart for every single bar where there is an order active. Could be a Wingdings 3 Red Up/Down arrow for the stop and a blue one on the other side for the profit target price.

    I have tried to do this but NT grinds to a halt with the number of Draw.Dot or Draw.Text involved. Somehow NT manages to draw a graphic OHLC bar for each bar very quickly, but I cannot get Draw.Dot or Draw.Text to draw fast enough to not end up with task not responding error.

    e.g. I have tried...

    Code:
    const int FontSize = 5;
    NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Wingdings 3", FontSize) { Size = FontSize, Bold = true };
     
    protected override void OnBarUpdate()
    {
          Draw.Text(this, CurrentBar+"Stop",true, ",", Time[0], Close[0], 0, Brushes.Red, myFont, TextAlignment.Center, null, null, 1);
               ...
    It does work, but it is too slow for any reasonably long backtest. The Chart just stops responding an I have to end the NT task.

    I think that this is not something we can do with Ninjascript because the Draw.Text and Daw.Dot is too slow.

    #2
    Hello,

    Thank you for the post.

    If you are running into problems based on the number of objects being drawn, that would generally be a case where you need to instead use OnRender to draw the data for only the currently visible bars.

    There is a sample indicator that shows some different rendering concepts called SampleCustomRender. As a Strategy cannot use OnRender, you would need to pass data from the strategy into an indicator that will draw the data. For example, the strategy could call the indicator from its OnBarUpdate or other order overrides to provide updates. The indicator could then be used to render data on the chart. We do have a sample that shows passing values to a dummy indicator for plotting purposes here: https://ninjatrader.com/support/foru...ead.php?t=6651

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bmartz, 03-12-2024, 06:12 AM
    5 responses
    32 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by Aviram Y, Today, 05:29 AM
    4 responses
    13 views
    0 likes
    Last Post Aviram Y  
    Started by algospoke, 04-17-2024, 06:40 PM
    3 responses
    28 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by cls71, Today, 04:45 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X