Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X