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 trader3000a, Today, 08:01 AM
    0 responses
    3 views
    0 likes
    Last Post trader3000a  
    Started by TheTradingMantis, 09-13-2021, 08:34 AM
    2 responses
    40 views
    0 likes
    Last Post DTSSTS
    by DTSSTS
     
    Started by Lucius. valerius, 03-23-2023, 01:39 AM
    6 responses
    149 views
    0 likes
    Last Post dj22522
    by dj22522
     
    Started by QuantKey_Bruce, Today, 06:44 AM
    0 responses
    9 views
    0 likes
    Last Post QuantKey_Bruce  
    Started by jeronymite, 03-24-2023, 12:58 AM
    2 responses
    49 views
    1 like
    Last Post QuantKey_Bruce  
    Working...
    X