Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

calling EnterLong()

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

    calling EnterLong()

    Hi, I'm developing a class that'd handle the flow of trade and could handle complex orders. I declare this class with other variables in the strategy file and instantiate it in OnInitialize() routine. To be able to call EnterLong() method in the context of the strategy file I need to call it as a method of that particular strategy class. However, it is inconvenient to pass reference to host class as a parameter in a general case as it has a different type every time. Can you suggest any NT tools to resolve this? Here's snippet of the code I'm implementing:

    /////////////////// strategy file ////////////////////////
    public class myStrategy : Strategy
    {

    ......
    // class declaration - see below
    .......

    protected override void Initialize() {
    .......
    trade = new Trade( 10, true );

    }

    protected override void OnBarUpdate() {
    .............
    trade.placeOrder( 1, this );
    }

    }
    /////////////////// class declaration //////////////////////////

    private class Trade : Strategy {
    .............

    public placeOrder( int amount, myStrategy that ) {
    that.EnterLong( amount, "myTrade" );
    // "that" references the host strategy class here
    }

    }
    }

    I forgot to mention, other methods from this class are working fine in the same context.
    Last edited by billitin; 06-28-2008, 07:37 PM.

    #2
    Unfortunately not. May I ask why you are using your own class though? There are IOrder objects and the OnOrderUpdate() and other advanced methods that offer you extreme flexibility over the standard EnterLong() ordering already available to you in NT6.5.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I like the elegance and semantics of calling actions in single liners if I place that class in a separate file. When using multiple strategies this also save for the amount of coding and makes adjustments easier. For example, if I need to flatten my market position I need to find out if my market position is flat, and then submit an order, not counting for checking some values for validity. If I need to place a bracket order things get messier: I need at least three lines of code instead of one. It's not critical, but makes life of a programmer comfier. At least Print() doesn't require particular environment, that's already good for debugging. Thanks for the info.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by geddyisodin, Today, 05:20 AM
      4 responses
      28 views
      0 likes
      Last Post geddyisodin  
      Started by geotrades1, Today, 10:02 AM
      2 responses
      5 views
      0 likes
      Last Post geotrades1  
      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
      10 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X