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 geotrades1, Today, 10:02 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by ender_wiggum, Today, 09:50 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by rajendrasubedi2023, Today, 09:50 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by bmartz, Today, 09:30 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by geddyisodin, Today, 05:20 AM
      3 responses
      26 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X