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

Get plot color of indicator from another indicator

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

    Get plot color of indicator from another indicator

    I am trying to get the color of an indicator plot from another indicator using the following to get the brush for latest bar of the first plot :

    BrushSeries brs = myIndicator(1,14).PlotBrushes[0];
    Brush br = brs[0];

    Problem is brs is always NULL. and also I see no obvious way to get the Brushes color value from brs.

    There must be something simple I am missing?

    #2
    Hello seahn,

    This would be expected, unfortunately comparing brushes like this would not directly work as expected. The PlotBrushes would only be relevant to the indicator its self for setting the plots brush, this would also report null when trying to access the brushes from another script. These are more of a Placeholder series that can be used in place of the brush the plot was set to when it was created.

    You would instead need to use one of the existing plots in the indicator, or if it does not have an exposed plot you would also need to add a public property to expose the plot. After doing this you could access the plotted value to perform logic in another script.

    For example if there was a plot named Signal in the script that gets set when the color changes, the syntax to call the indicator could look like the following:

    Code:
    double value = myIndicator(1,14).Signal[0];
    if(value < 0){ .... }
    If this is a value that is easy to use such as a 1,0 or -1, you can likely use the above as a guide, otherwise if the value is the Plots value such as an averaged price value, you may need to instead change the above example to compare whatever value the indicator is actually producing. You can Print the value if you are unsure.

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

    Comment


      #3
      Thanks for your reply,

      Perhaps since PlotBrushes does not work outside its script it should be declared private unless there are other reasons to expose it, would have saved me some time .

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by JGriff5646, Today, 10:02 PM
      0 responses
      1 view
      0 likes
      Last Post JGriff5646  
      Started by AdamDJ8, Today, 09:18 PM
      0 responses
      2 views
      0 likes
      Last Post AdamDJ8
      by AdamDJ8
       
      Started by knowmad, Today, 03:52 AM
      2 responses
      27 views
      0 likes
      Last Post knowmad
      by knowmad
       
      Started by ETFVoyageur, Today, 07:05 PM
      0 responses
      10 views
      0 likes
      Last Post ETFVoyageur  
      Started by Orion815, 05-02-2024, 08:39 AM
      2 responses
      18 views
      0 likes
      Last Post Orion815  
      Working...
      X