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 argusthome, Yesterday, 10:06 AM
      0 responses
      20 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      18 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      9 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      38 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X