Limit orders

Viewing 7 posts - 1 through 7 (of 7 total)
  • #253794

    Hi everyone.

    I’ve written a code for algorithmic trading of the US Tech 100 1 Euro contract on daily charts. Orders are placed when the first bar after the signal day opens, and as I understand it, they are automatically cancelled if they’re not filled that same day. It works well with “buy 1 contract at market.” I’m trying to achieve a lower entry by buying at, for example, open * 0.996. In the backtest it appears to work, but when I check specific transactions I see that it’s incorrect. Some orders are filled in the backtest even though the limit was never reached. Anyone with long experience who has dealt with this? Thanks in advance.

    #253796

    The code I’m using is

    buy 1 contract at MARKET

    and

    buy 1 contract at open * 0.996 LIMIT

    #253797

    Hi,

    Your code is read at candle close (and therefore before start of the candle on which the order will be executed).

    So, if the code decides at candle close to place an order for next candle, and you use your “buy 1 contract at market” line, it places the order and executes it, so far so good.

    But, when you use the line “buy 1 contract at open * 0.996 LIMIT”, the value used for open cannot be the open of the next candle it doesn’t know yet, it is the open of the candle just closed. If you took this into account when seeing orders you think shouldn’t be taken, then the problem is not this. But, in case you looked at open value of the candle where the order is executed instead of the open value of the previous candle the code has been read on to be able to send its order, then this would be the issue?

    4 users thanked author for this post.
    #253935

    Here is a precise English translation:


    Thanks for your reply, JC_Bywan.

    I wrote “buy at open” and thought it would use the open of the next candle. Let’s say the signal comes on Monday’s close — then the order is placed on Tuesday, and I want to use Tuesday’s open to calculate the limit. Is there a code I can use to achieve that? Thanks in advance 🙂

    #253939

    Hi, no there isn’t, because to be executed “when the candle opens” (horizontal axis), the limit order has to be placed before the value of the open (vertical axis) is known to be able to specify such  limit rather than timing.

    1 user thanked author for this post.
    #253947

    @ JC

    Maybe if he uses multi time frame with shorter time to calculate the open it will work, isn’t it?

    1 user thanked author for this post.
    #253966

    It would raise other questions (list not necessarily exhaustive):

    – how much daily history would be needed for the code to work, this didn’t matter maybe when running in daily, but considering a multitimeframe choice it would now be the small timeframe defining max history available

    – what is the “biggest” small timeframe acceptable to capture the daily open, and send order only from small timeframe second candle

    – what is the multiplying coefficient between these 2 timeframes, and is this coefficient small enough to allow enough history for the bigger timeframe (the daily one) defined at top of the list

    – and should all above be ok, how to handle the case of the 0.996*open possibly occuring during the small timeframe first candle of the day, should it not occur later.

Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login