Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling a strategy from an indicator

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

    Calling a strategy from an indicator

    I have a strategy that inherits from Strategies:
    Code:
    namespace NinjaTrader.NinjaScript.Strategies
    {
    	public class MyStrategy : Strategy
    	{
    	}
    }
    I also have an indicator that makes use of this strategy:
    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
    	public class MyIndicator : Indicator
    	{
      		[XmlIgnore()]
            	public Strategies.MyStrategy myStrat;  // public MyStrategy myStrat worked in NT7
    	}
    }
    The first thing is that I have to declare my strategy variable as Strategies.MyStrategy (Instead of just plain MyStrategy like I did in NT7) or I get the compiler error: “The type or namespace “MyStrategy” could not be found…”

    That shouldn’t be since I just created it so I know it does exist but fine – I’ll declare it like it wants.

    But in the implementation where I want the indicator to call the strategy to put a stop order, I have:
    Code:
    Order newOrder = flagStrat.ExitShortStop( 0, true, qty, price, "Stop loss", entrySignal );
    This gives me the compiler error “NinjaTrader.NinjaScript.Strategies.MyStrategy” does not contain a definition for “ExitShortStop”…”

    Yes it does! MyStrategy "isa" Strategies, therefore it should see Strategies methods. But for some reason it doesn't.

    This is a port from functionality that worked in NT7 so something tells me this is a simple thing I’m overlooking.

    What am I missing?

    Thanks guys!
    Last edited by traderpards; 01-08-2016, 01:22 PM.

    #2
    Hello traderpards,

    Would you be able to provide a sample or the script you use in NT 7 that works and we can try to find the equivalent in NT8 ?

    Comment


      #3
      Well, of course when you make me do that, I figure out my problem...

      Code:
      using  NinjaTrader.NinjaScript.Strategies;
      Thanks Patrick - I knew it was something stoooooopid..

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      673 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      577 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X