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 Tim-c, Today, 02:10 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Taddypole, Today, 02:47 PM
      0 responses
      2 views
      0 likes
      Last Post Taddypole  
      Started by chbruno, 04-24-2024, 04:10 PM
      4 responses
      50 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      10 responses
      400 views
      1 like
      Last Post beobast
      by beobast
       
      Started by lorem, Yesterday, 09:18 AM
      5 responses
      25 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X