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 Barry Milan, Today, 10:35 PM
          0 responses
          2 views
          0 likes
          Last Post Barry Milan  
          Started by DJ888, Yesterday, 06:09 PM
          2 responses
          9 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          40 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Today, 08:51 AM
          2 responses
          16 views
          0 likes
          Last Post bill2023  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          167 responses
          2,260 views
          0 likes
          Last Post jeronymite  
          Working...
          X