Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code works in Sim, but not live.

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

    Code works in Sim, but not live.

    Code:
    //UPDATE STOP ORDER
    if time < 1500
    and NTOrderStatus(NTStopOrderID) = "Accepted"
    and LStopPr > CurrentLStopPr
    then begin
    value1 = NTChange(NTStopOrderID,0,0,LStopPr);
    CurrentLStopPr = LStopPr;
    end;
    
    //PLACE STOP ORDER
    if NTFilled(NTEntOrderID) > 0
    and NTOrderStatus(NTStopOrderID) = ""
    then begin
    value1 = NTCommand("PLACE",NTAcct,"Sell",NTCon,"Stop",0,min list(low - 1,LStopPr),"Day","",NTStopOrderID,"","");
    CurrentLStopPr = minlist(low - 1,LStopPr);
    end;
    
    //UPDATE ENTRY ORDER
    if NTFilled(NTEntOrderID) = 0
    and NTOrderStatus(NTEntOrderID) = "Working"
    then begin
    value1 = NTChange(NTEntOrderID,0,0,close);
    end;
    
    If condition1
    And condition2
    And condition3
    And condition4
    And condition5
    Then begin
    LEPrice = close;
    value1 = NTCommand("PLACE",NTAcct,"Buy",NTCon,"Limit",LEPri ce,0,"Day","",NTEntOrderID,"","");
    end;
    
    if time = 1512
    and NTOrderStatus(NTExitOrderID) = "Working"
    then value1 = NTChange(NTExitOrderID,0,0,close - 5);
    
    if time > 1500
    and time < 1512
    and NTOrderStatus(NTExitOrderID) = "Working"
    then value1 = NTChange(NTExitOrderID,0,0,close);
    
    
    if time = 1500
    and NTFilled(NTEntOrderID) = 1
    and NTFilled(NTStopOrderID) = 0
    and NTOrderStatus(NTStopOrderID) = "Accepted"
    then begin
    value1 = NTCancel(NTStopOrderID);
    value1 = NTCommand("PLACE",NTAcct,"Sell",NTCon,"Limit",clos e,0,"Day","",NTExitOrderID,"","");
    end;
    I ran this code today on two machines, one trading in a sim account, and the other in a live account. In the sim account, everything worked. In the live account, the initial order was placed and filled.
    Following that, the stop order was placed. However, the stop price never updated as it did in the sim trading, and the 1500 exit order was never sent.

    At the end of the day, I still had an open position, which I closed manually.
    Last edited by NinjaTrader_Jim; 06-05-2019, 06:51 AM.

    #2
    Hello Atomic,

    This is not NinjaScript that I can tell and is likely EasyLanguage from tradestation.

    Our support can read the log and trace and tell you what orders were generated in NinjaTrader if you would like to send these in.
    Send an email to platformsupport [at] ninjatrader [dot] com with a link to this forum thread.

    However, our NinjaScript Support team will not be able to assist with the EasyLanguage code or any non-NinjaScript code.
    This thread will remain open for any community members that would like to assist with the non-NinjaTrader code.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Atomic,

      This is not NinjaScript that I can tell and is likely EasyLanguage from tradestation.

      Our support can read the log and trace and tell you what orders were generated in NinjaTrader if you would like to send these in.
      Send an email to platformsupport [at] ninjatrader [dot] com with a link to this forum thread.

      However, our NinjaScript Support team will not be able to assist with the EasyLanguage code or any non-NinjaScript code.
      This thread will remain open for any community members that would like to assist with the non-NinjaTrader code.
      Yes, sorry, this code is Easylanguage, but I am using the NtDirect dll and related EL functions to pass orders from a Tradestation chart to my NinjaTrader platform. I have been doing this for years, but mostly in sim. I send the code to a broker who does the live trading. It turns out the problem was due to testing the order status for "Accepted" rather than "Working". When I change this code:
      NTOrderStatus(NTStopOrderID) = "Accepted" to NTOrderStatus(NTStopOrderID) = "Working",
      it corrects the problem. I don't know why the "Accepted" works in sim, but not in live trading.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by selu72, Today, 02:01 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by WHICKED, Today, 02:02 PM
      2 responses
      9 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by f.saeidi, Today, 12:14 PM
      8 responses
      21 views
      0 likes
      Last Post f.saeidi  
      Started by Mikey_, 03-23-2024, 05:59 PM
      3 responses
      50 views
      0 likes
      Last Post Sam2515
      by Sam2515
       
      Started by Russ Moreland, Today, 12:54 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X