Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order execution

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

    order execution

    int NTBuyLimit(string orderId, int quantity, double limitPrice)
    Sends a buy limit order. A return value of 0 indicates success and -1 indicates an error. Success indicates success in submitting the command NOT that the order was successfully submitted.

    1) I'm running this on tradestation.

    Here's my code:
    if condition1 then
    begin
    value1 = NTBuyLimit(ACCOUNT_NUM, 100, currentask + .05);
    end;

    Then... I notice that when there is a buy order tradestation does not recognize than an order was taken place. So in order to keep tradestation up to par with what is going on I write.

    if condition1 then
    begin
    value1 = NTBuyLimit(ACCOUNT_NUM, 100, currentask + .05);
    buy this bar 100 shares at currentask + .05 limit;
    end;


    So now tradestation thinks that it is in the trade and is able to look for exit conditions, however will I get a multiple order? I only want to buy 100 shares, but in order to keep tradestation knowing what the market position is I have to write the code "buy this bar 100 shares ..." in order to get tradestation on the same page as my market position.

    So in the second code will get buy 100 or 200 shares?

    #2
    This is another example of what I'm getting at. Keeping TradeStation up to date with ninja trader

    { Copyright (c) 2005, NinjaTrader LLC [email protected] }
    inputs: FastLength(9), SlowLength(18) ;
    variables: FastAvg(0), SlowAvg(0), Success(0);
    if LastBarOnChart and NTConnected(1) then begin
    if NTMarketPosition("") = 0 then begin
    { place an order, if there is no position yet }
    if AverageFC(Close, FastLength) > AverageFC(Close, SlowLength) then begin
    Success = NTBuyMarket("MyOrderId", 1); { buy 1 unit at market, assign order id (optionally) }
    end else begin
    Success = NTSellMarket("MyOrderId", 1); { sell 1 unit at market, assign order id (optionally) }
    end;
    end else begin
    { print some information on the current position and order }
    Print("Position size: " + NumToStr(NTMarketPosition(""), 0));
    Print("AvgEntryPrice: " + NumToStr(NTAvgEntryPrice(""), 2));
    Print("OrderStatus: " + NTOrderStatus("MyOrderId"));
    Print("Filled #: " + NumToStr(NTFilled("MyOrderId"), 0));
    Print("AvgFillPrice: " + NumToStr(NTAvgFillPrice("MyOrderId"), 2));
    end;
    end;



    Okay, imagine that this is your code. and you would like to exit in 10 bars. Tradestation has a function BarsSinceEntry. Because in the following code there is no code like, "buy this bar on close" trade station wouldn't know there is an order so it won't be keeping a running tab of the "bars since entry".

    So in order to keep trade station up to date with NT, you'd have to write buy this bar on close; but if you have
    if condition1 = true then
    NTBuyMarket("MyOrderId", 1);
    buy this bar on close;
    end

    now you have 2 orders.

    I hope what I want to know is clear now

    Comment


      #3
      Unfortunately we can not provide support for TS EL code. Here are some generals hints:
      - orders are placed in NT right away as you call the respective ATI methods
      - there is no "protection" in place to prevent "redundant" order placement through ATI (unlike in NinjaScript)
      - order are not canceled out next bar (unlike in NinjaScript)
      - you probably should consider coding your strategy in NinjaScript

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      61 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      40 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      21 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      23 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      51 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X