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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      168 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      322 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      247 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X