How to find Limit Order has been executed or not

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #105248 quote
    Parimal Patel
    Participant
    New

    Hi

    I am creating sell order into auto trading system, when trading system start.

    SELLSHORT 1 contract at mySellPrice limit

    Sell order will not in position tab, Until system reach to mySellprice. It will take some time to reach to my indicated (mySellPrice) price.

    Meanwhile how can I detect that sell order is executed or not?

    #105252 quote
    robertogozzi
    Moderator
    Master

    Check if OnMarket or not OR, if not, if StrategyProfit <> StrategyProfit[1].

    #105254 quote
    Parimal Patel
    Participant
    New

    So when I place the sell order using limit, OnMarket condition will be false. And when sell order will be executed in future OnMarket condition will return true.

    #105262 quote
    robertogozzi
    Moderator
    Master

    Yes, sometimes if a trade enters and exits on a single bar ONMARKET will not be able to update its status, so you’ll have to compare STRATEGYPROFIT.

    #105271 quote
    Vonasi
    Moderator
    Master

    Parimal Patel – I have moved this topic to the ProOrder forum as it is strategy related and not a general discussion. Please try to post future topics and questions in the correct forum.

    #105549 quote
    Parimal Patel
    Participant
    New

    i have tried above suggestion, but doesn’t work 100%.

    When first condition is hit , I am executing first order (could be limit or market). When second condition hit, I am placing another order. In 90% case my 2nd order executed successfully but 10% case system don’t pick up the order. I don’t know why its happening. So I have to check in next bar or next execution point that my order has been executed or not.

    STRATEGYPROFIT value change every time (or on every bar) due to first order is already there. ONMARKET doesn’t work as first order is already there.

    Is there anyway I can check and fix this issue?

    #105551 quote
    Vonasi
    Moderator
    Master

    STRATEGYPROFIT will not be updated until a position is closed. You should compare POSITIONPERF <> 0 for trades that are open.

    #105552 quote
    robertogozzi
    Moderator
    Master

    STRATEGYPROFIT is updated only when a trade is closed, so it cannot change each bar, unless your trades only last one bar.

    The only workaround would be checking if the entry price of the pending order has been hit, if it is then you may assume the order has been triggered, unless rejected for some reasons.

    #105732 quote
    Nicolas
    Keymaster
    Master

    You can check if you were on market or not on the previous bar with this snippet: (useful if the order opened and closed in the same bar)

    if ( (not onmarket and onmarket[1]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) )  and lastcheck<>barindex then
    lastcheck = barindex
     wasonmarket=1
    else
     wasonmarket=0
    endif
    Vonasi thanked this post
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

How to find Limit Order has been executed or not


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by Nicolas
6 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/22/2019
Status: Active
Attachments: No files
Logo Logo
Loading...