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

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 alifarahani, Today, 09:40 AM
    6 responses
    36 views
    0 likes
    Last Post alifarahani  
    Started by Waxavi, Today, 02:10 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    14 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Waxavi, Today, 02:00 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X