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?

    The Trend Magic indicator is an ATR-based trend line that uses CCI to control its upward and downward movement. It was once a popular indicator in the Forex trading world. When the CCI is greater than zero the line is only able to move upwards, and conversely, when the CCI is less than or equal […]


    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 warreng86, 11-10-2020, 02:04 PM
    4 responses
    1,355 views
    0 likes
    Last Post mathewlo  
    Started by Perr0Grande, Today, 08:16 PM
    0 responses
    2 views
    0 likes
    Last Post Perr0Grande  
    Started by elderan, Today, 08:03 PM
    0 responses
    5 views
    0 likes
    Last Post elderan
    by elderan
     
    Started by algospoke, Today, 06:40 PM
    0 responses
    10 views
    0 likes
    Last Post algospoke  
    Started by maybeimnotrader, Today, 05:46 PM
    0 responses
    12 views
    0 likes
    Last Post maybeimnotrader  
    Working...
    X