• 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

Coffee (KC) futures EOD auto close

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

  • RedDuke
    started a topic Coffee (KC) futures EOD auto close

    Coffee (KC) futures EOD auto close

    Hello,

    We currently testing our strategy in coffee futures (KC symbol on ICE exchange) in market replay. I am coming accords a weird issue. Coffee closes for trading at 1:30pm Eastern Time. If I have a open position, Ninja closes it. Every strategy has standard setting to close at end day, and I have it set to false. It is my custom strategy, but the trade is closed by ninja since my custom logic writes tons of things to output window when it closes the trade. And there is nothing there apart from standard ninja things. Same exact strategy on oil (CL) has no issues, but oil does not close midday, it just does not trade between 5-6pm EST like the rest of products on CME.

    Any help with this issue is very much appreciated.

    Thanks,
    redduke

  • RedDuke
    replied
    Josh,

    I sent the email.

    Thanks,
    redduke

    Leave a comment:


  • RedDuke
    replied
    Josh,

    I am using MarketReplay recorded live of IQFeed datafeed. I just had the same issue happening today live (on sim), and this time it was not on the last bar of the session. Something triggered profit limit, with the price no where near it, resulting in huge "fake" profit.

    So the issue seem profit limit trigger with price nowhere near. Is it perhaps IQFeed bad data? This behavior now happened in both Replay and Live.on Sim.

    Will send logs later today.

    Thanks

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    RedDuke,

    I was not able to see the same order behavior. Are you using Market Replay or Historical Replay data?

    Please write in to PlatformSupport(AT)NinjaTrader(DOT)com and reference ticket ID 2098586 with RE:JOSH in the subject line. Please attach your Log and Trace files to your email so that I may investigate this matter further. You may follow the steps below to attach those files.
    • Open your NinjaTrader folder under My Documents.
    • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    • Send the 2 compressed folders as attachments to this email.
    • Once complete, you can delete these compressed folders.

    Leave a comment:


  • RedDuke
    replied
    Please see attached sample strategy. Load 2 hour chart, KC 05-19, fast forward Replay to March 4th at 1pm. The strategy will submit short trade and exits 40 tick away from filled price. 2 seconds before 1:30pm Profit limit gets triggered with Market price nowhere near it.

    Thank you,
    redduke
    Attached Files
    Last edited by RedDuke; 03-11-2019, 05:25 PM.

    Leave a comment:


  • RedDuke
    replied
    Hi Josh,
    Let me develop is quickly, as mine has tons of things. Will post a bit later today.
    Thanks

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    bltdavid,
    You are correct. The TIF would not have any concept of a position. It would only be for limit orders.

    RedDuke,
    Can you post a sample script here? I would like to test on my end.

    Leave a comment:


  • RedDuke
    replied
    SampleMACrossover only places a trade and has no exit orders for it. I always have stop loss and profit orders on. Something triggered my profit limit, but the price was nowhere near it.

    Leave a comment:


  • RedDuke
    replied
    With trace on, nothing at all was printed in output window. I added custom output in OnOrderUpdate method, below are the result that were triggered 2 seconds before market closes at 1:30pm EST.

    4 lines came out, the format is Method Name, Current Price, Order Status, iOrder object to string

    OnOrderUpdate: 97.15 Profit PartFilled Order='1648558ddaed4a86bfcdb835ddaeb4cd/Replay101' Name='KCShortProfit' State=PartFilled Instrument='KC 05-19' Action=BuyToCover Limit price=83.65 Stop price=0 Quantity=2 Type=Limit Tif=Gtc OverFill=False Oco='' Filled=1 Fill price=0 Token='1648558ddaed4a86bfcdb835ddaeb4cd' Gtd='1/1/0001 12:00:00 AM'

    OnOrderUpdate: 97.15 Loss PendingCancel Order='fd770218b03a4babbcfb392af324f4c8/Replay101' Name='KCShortLoss' State=PendingCancel Instrument='KC 05-19' Action=BuyToCover Limit price=0 Stop price=98.65 Quantity=2 Type=Stop Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='fd770218b03a4babbcfb392af324f4c8' Gtd='1/1/0001 12:00:00 AM'

    OnOrderUpdate: 97.15 Loss Cancelled Order='fd770218b03a4babbcfb392af324f4c8/Replay101' Name='KCShortLoss' State=Cancelled Instrument='KC 05-19' Action=BuyToCover Limit price=0 Stop price=98.65 Quantity=2 Type=Stop Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='fd770218b03a4babbcfb392af324f4c8' Gtd='1/1/0001 12:00:00 AM'

    OnOrderUpdate: 97.15 Filled Order='1648558ddaed4a86bfcdb835ddaeb4cd/Replay101' Name='KCShortProfit' State=Filled Instrument='KC 05-19' Action=BuyToCover Limit price=83.65 Stop price=0 Quantity=2 Type=Limit Tif=Gtc OverFill=False Oco='' Filled=2 Fill price=0 Token='1648558ddaed4a86bfcdb835ddaeb4cd' Gtd='1/1/0001 12:00:00 AM'

    This is a short trade. I always have take profit and stop loss orders for every position. As you can see my profit target exit limit price is 83.65, the market last traded price was 97.15, and somehow it got triggered. The execution then cancelled stop loss. SampleMACrossover only had open position and no exit orders, where my strategy always has exit orders on. Totally out of ideas.

    Thank you,
    redduke
    Last edited by RedDuke; 03-09-2019, 11:42 AM.

    Leave a comment:


  • RedDuke
    replied
    The output is always "False 30" for Print(ExitOnClose+" "+ExitOnCloseSeconds);

    It is False all the way to the end. I will clean up the output to not display my own "crap" and will post it here a bit later, so only Ninja Trace is displayed

    Leave a comment:


  • bltdavid
    replied
    Originally posted by NinjaTrader_JoshG View Post
    TIF would certainly apply here or anywhere else there was an open position. That position was opened with an order, and that order had a TIF setting. With a time in force of GTC though it should not exit on close.
    Ok, thanks.

    I thought after the order was Filled it reached a terminating state and the TIF setting would be moot.
    Why does the TIF setting affect an active position?

    Seems like I could build a position from X number of orders, some of which could be DAY and some
    of which could be GTC ... if all these orders Filled are you saying the aggregate position is somehow
    subject to the various TIF settings of the orders that made up the position?

    I thought TIF applied to orders only, ie, the TIF was effective until the order was executed or cancelled.
    Are you saying the TIF setting also has an effect after the order has executed?
    Last edited by bltdavid; 03-08-2019, 11:43 AM. Reason: Better summary question

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    If the 'SampleSMACrossover' strategy worked we know that the issue is something with your specific strategy. I'm with bltdavid that you should try printing ExitOnCloseSeconds from your strategy.

    bltdavid,
    TIF is for active entry & exit orders, not active positions, so it should not apply here.
    TIF would certainly apply here or anywhere else there was an open position. That position was opened with an order, and that order had a TIF setting. With a time in force of GTC though it should not exit on close.

    RedDuke,
    Every strategy has standard setting to close at end day, and I have it set to false. It is my custom strategy, but the trade is closed by ninja since my custom logic writes tons of things to output window when it closes the trade.
    What all does NinjaTrader write to your output window when it closes the trade? Please copy/paste that information here.

    Leave a comment:


  • bltdavid
    replied
    Originally posted by RedDuke View Post
    ExitOnClose is false
    Where can I see ExitOnCloseSeconds?
    Did you try printing it?

    Add these lines to OnStartUp,
    Code:
    Print("ExitOnClose="+ExitOnClose);
    Print("ExitOnCloseSeconds="+ExitOnCloseSeconds);
    See also:
    https://ninjatrader.com/support/help...xitonclose.htm
    https://ninjatrader.com/support/help...oseseconds.htm
    Last edited by bltdavid; 03-08-2019, 10:55 AM. Reason: Added ExitOnClose for completeness

    Leave a comment:


  • RedDuke
    replied
    Trace did not help. There was nothing in output window apart form line form cancelled take profit order. Completely surprised.

    SampleMACrossover had multiple entries and exits but it kept position on at close , however it has no take profit or SL orders.

    Leave a comment:


  • RedDuke
    replied
    Originally posted by bltdavid View Post
    TIF is for active entry & exit orders, not active positions, so it should not apply here.

    What is the value of ExitOnClose?
    What is the value of ExitOnCloseSeconds? <-- less important
    ExitOnClose is false
    Where can I see ExitOnCloseSeconds?

    Thanks

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by uiwislth, Yesterday, 11:25 PM
0 responses
4 views
0 likes
Last Post uiwislth  
Started by Steve L, Yesterday, 10:04 PM
0 responses
3 views
0 likes
Last Post Steve L
by Steve L
 
Started by marianfed, Yesterday, 09:47 PM
0 responses
4 views
0 likes
Last Post marianfed  
Started by hir04068, Yesterday, 09:29 PM
0 responses
2 views
0 likes
Last Post hir04068  
Started by iq200, 03-11-2018, 07:49 PM
24 responses
1,018 views
0 likes
Last Post mrlucky1x  
Working...
X