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 WHICKED, Today, 12:56 PM
    0 responses
    2 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Spiderbird, Today, 12:15 PM
    2 responses
    10 views
    0 likes
    Last Post Spiderbird  
    Started by WHICKED, Today, 12:45 PM
    0 responses
    7 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by FrazMann, Today, 11:21 AM
    2 responses
    6 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by rjbtrade1, 11-30-2023, 04:38 PM
    2 responses
    80 views
    0 likes
    Last Post DavidHP
    by DavidHP
     
    Working...
    X