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

Exposing Boolean variables from Indicator for a strategy

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

    Exposing Boolean variables from Indicator for a strategy

    Okay, so I have a very dumb and hopefully simple question to answer:

    I'm trying to expose two true/false variables to a strategy that calls my custom indicator. What I can't figure out is how I should code it from the indicator-side of things.

    1. How should user variables be set for two Boolean values within the indicator?
    2. If called out in an 'if' statement in the indicator, how should I properly set that variable (true/false)
    3. How should this variable be referenced in the strategy?

    Thanks in advance for any replies.

    #2
    Hello Spiderbird,

    Thank you for your note.

    You would want to use a Boolseries for this case.
    http://www.ninjatrader.com/support/h...ries_class.htm

    This will work like a DataSeries except that it only uses True/False and you can index it like a DataSeries as well.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      That was it!

      Hi Cal,

      Thanks for that! I was on the right track originally, but was setting my variables incorrectly. This is what my code eventually looked like in cliff-noted form (for others to reference JIC)

      Code:
      #region Variables
      	public BoolSeries UpArrow;
      	public BoolSeries DownArrow;
      #endregion
      
      protected override void Initialize()
      {
              UpArrow = new BoolSeries(this);
      	DownArrow = new BoolSeries(this);
       }
      
      protected override void OnBarUpdate()
      {
      
      if (Trend [0] && !Trend[1])
      {     UpArrow.Set(true);    }
      
      else
      {     DownArrow.Set(true);     } 
      
      }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      6 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X