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

Any shortcut to EnterLong/EnterShort?

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

    Any shortcut to EnterLong/EnterShort?

    `SubmitOrder` has a nice feature, to pass variables, like



    oAction= condition ? orderAction.Buy : orderAction.Sell;
    SubmitOrder(.... oAction ... )..

    I want to achieve similar with managed orders, so, there should be need to use separate functions (like I am using at this moment):
    Code:
    if( Condition) {
        EnterLong(....); // <------  "long" appears inside FUNCTION name
    }
    else {
        EnterShort(....); // <------ "short" appears inside FUNCTION name
    }
    is there any built-in function to solve that (i know that i can create a hard-coded my custom method, but i wish built-in alternative), like i could:

    i.e.
    action = "enter";
    direction= "short";
    ExecuteTrade(action , direction ) ; // instead of EnterShort()
    Last edited by ttodua; 09-10-2017, 07:30 AM.

    #2
    Hello selnomeria,

    OrderAction is an enum. Use this as you would any other enum.

    Code:
    OrderAction  ordersAction = OrderAction.Buy;
    
    SubmitOrder(0, [B]ordersAction[/B], OrderType.Market, 1, 0, 0, string.Empty, string.Empty);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello selnomeria,

      OrderAction is an enum. Use this as you would any other enum.

      Code:
      OrderAction  ordersAction = OrderAction.Buy;
      
      SubmitOrder(0, [B]ordersAction[/B], OrderType.Market, 1, 0, 0, string.Empty, string.Empty);
      But i say that I want to do like that variable with MANAGED orders, and SubmitOrder is for Unmanaged orders, right?

      Comment


        #4
        Hi selnomeria,

        Yes, SubmitOrder() is used for the unmanaged approach and cannot be used with the managed approach.

        With the managed approach the OrderAction is not used at all.

        Simply call the method you want to use to place an order with such as EnterLong() or EnterShort().

        Below are publicly available links to the help guide.



        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          i know them, thanks.
          i just wanted to know if there was available what i wanted, however, you could simple say "no", and that could be enough for me. thanks! I will create a custom method, which will execute specific function with passed string argument, like: MyOrdderFunc("long",....)

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          4 responses
          21 views
          0 likes
          Last Post alifarahani  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by PhillT, Today, 02:16 PM
          2 responses
          7 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by Kaledus, Today, 01:29 PM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frankthearm, Yesterday, 09:08 AM
          14 responses
          47 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X