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 josh18955, 03-25-2023, 11:16 AM
          6 responses
          435 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          3 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          18 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frslvr, 04-11-2024, 07:26 AM
          9 responses
          126 views
          1 like
          Last Post caryc123  
          Started by selu72, Today, 02:01 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Working...
          X