• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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, 05: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 rouillard, Today, 03:34 PM
      2 responses
      22 views
      0 likes
      Last Post rouillard  
      Started by mquinteroj, Today, 02:41 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by JPPoulin, Today, 01:32 PM
      4 responses
      15 views
      0 likes
      Last Post JPPoulin  
      Started by bltdavid, Today, 01:09 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by pstrusi, Today, 12:50 PM
      2 responses
      8 views
      0 likes
      Last Post pstrusi
      by pstrusi
       
      Working...
      X