Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      605 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      351 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      560 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      561 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X