Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Assigning indicator values

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

    Assigning indicator values

    Hello, I have the snippet of code where the following conditions paint the bar red or green:

    Code:
    protected override void OnBarUpdate()
            {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
    			
    			if (MACD(12,26,9).Diff[0] > 0 && MACD(12,26,9)[0] > 0)
          			BarColor = Color.Green;
    		
    			else if (MACD(12,26,9).Diff[0] < 0 && MACD(12,26,9)[0] < 0)
          			BarColor = Color.Red;
    			
            }
    Now, I plan on using the indicator in a strategy and was wondering how to set something like: if the bar is red, then value of the indicator == 0, and if the bar if green, then set the value of the indicator == 1 .. or something like this. I just want to be able to call out a 0, or 1 (for red or green bars) when building the strategy..thx

    #2
    Create an indicator plot and set it to 0 or 1 depending on what you want. Please see the Help Guide tutorials on building custom indicators.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    572 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    331 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    549 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    550 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X