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

How to create a plot for the line color of an indicator

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

    How to create a plot for the line color of an indicator

    I've been using the Trend Magic indicator available on Ninja Trader lately. However, There is no plot for when the lines switch colors (green for long, red for short.) Im not good at all the coding stuff yet so I was wondering.. Would it be possible to add a plot into the code for when the lines change color?

    #2
    Hello tannermcelvany34,

    Thanks for your post.

    NinjaTrader does not come with an indicator called 'Trend Magic' by default. So I may accurately assist, are you referring to the 'Trend Magic' indicator from the Ecosystem User App Share page linked below?

    https://ninjatraderecosystem.com/use...d/trend-magic/

    If so, AddPlot() can be used in OnStateChange() when the State == State.SetDefaults to add a plot to the indicator script.

    A value could be assigned to that plot depending on if the current plot in the script named TrendMagic uses the BullBrush or BearBrush by creating an 'if else if' condition that checks if PlotBrushes[0][0] is equal to the BullBrush or BearBrush. An example of printing to the NinjaScript Output window when PlotBrushes equals BullBrush or BearBrush could be seen below.

    Code:
    if (PlotBrushes[0][0] == BullBrush)
        Print("BullBrush used");
    else if (PlotBrushes[0][0] == BearBrush)
        Print("BearBrush used");​


    Instead of using a Print statement, you would assign a value to your plot.

    See this help guide page for information about using the AddPlot() method and assigning a value to the plot: https://ninjatrader.com/support/help...t8/addplot.htm

    This help guide page contains information about PlotBrushes for you to view: https://ninjatrader.com/support/help...lotbrushes.htm

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:
    https://ninjatrader.com/support/help..._resources.htm

    If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first:
    https://ninjatrader.com/support/help...g_concepts.htm

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ClauTrade, Today, 12:39 PM
    0 responses
    3 views
    0 likes
    Last Post ClauTrade  
    Started by ClauTrade, Today, 12:15 PM
    0 responses
    5 views
    0 likes
    Last Post ClauTrade  
    Started by Snowdogg, Today, 11:39 AM
    0 responses
    3 views
    0 likes
    Last Post Snowdogg  
    Started by SampaioCabezas, Yesterday, 01:58 PM
    2 responses
    21 views
    0 likes
    Last Post SampaioCabezas  
    Started by ny10013, Today, 06:45 AM
    2 responses
    18 views
    0 likes
    Last Post ny10013
    by ny10013
     
    Working...
    X