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 SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      29 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      17 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      9 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      15 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      18 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X