• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 chrismcdermut, Yesterday, 01:46 PM
      3 responses
      17 views
      0 likes
      Last Post MojoJojo  
      Started by Bricolico, Yesterday, 09:28 PM
      0 responses
      5 views
      0 likes
      Last Post Bricolico  
      Started by Tradwell385, Yesterday, 08:51 PM
      0 responses
      7 views
      0 likes
      Last Post Tradwell385  
      Started by dvcpro4, Yesterday, 07:08 PM
      0 responses
      19 views
      0 likes
      Last Post dvcpro4
      by dvcpro4
       
      Started by pennywise, Yesterday, 06:40 PM
      0 responses
      8 views
      0 likes
      Last Post pennywise  
      Working...
      X