Back

Limit Order Gets Filled Immediately when placed

MarketOrder("USDJPY",10000);

//Take Profit (Sell) at 50 pips above
var takeProfit = LimitOrder("USDJPY", -10000, data["USDJPY"].Close +
Securities["USDJPY"].SymbolProperties.MinimumPriceVariation*50*10);

Hi,

I have the above code where I'm trying to set a take profit of 50 pips on a buy market order.
What I expect to happen:

Market order gets filled immediately. Limit Order gets "submitted" immediately and then later gets filled when price reaches 50 pips above the current price.

What happens:

Market order and Limit order both get filled immediately.

Shouldnt the limit order be filled after some time when price has moved by 50 pips? Am I doing Limit Orders wrong? A sell limit order gets filled at the limit price or higher right? Then why does it get filled immediately?

Update Backtest








can't see anything on the picture :)

i think they dont have ask and bid prices why you would have to implement something to test the spread....

0

Did you try to log the time the orders get exectued with the TIME variable?

sorry no info for me provided by the picture..... :)

post the time in a table or something like this:

https://www.quantconnect.com/docs#Logging-and-Debug-Debug-Messages

0

Firstly, Thank you for responding. Sorry for taking this long to reply. I've attached the backtest.

Here are the trades that get reported:

2013-10-07 00:00:00USDJPY¥97.66JPYLimit-10,000ShortFilled 2013-10-07 00:00:00USDJPY¥97.162JPYMarket10,000LongFilled
0


i only inserted the onorder event so you see whats happening:

2013-10-07 00:00:00 : Launching analysis for bdada492d187a8c85c822d96d6498b3a with LEAN Engine v2.4.0.1.3231
2013-10-07 00:00:00 : Order 1: 10/7/2013 12:00:00 AM: Market: Time: 10/7/2013 4:00:00 AM OrderID: 1 Symbol: USDJPY Status: Submitted
2013-10-07 00:00:00 : Order 1: 10/7/2013 12:00:00 AM: Market: Time: 10/7/2013 4:00:00 AM OrderID: 1 Symbol: USDJPY Status: Filled Quantity: 10000 FillPrice: 97.162 JPY
2013-10-07 00:00:00 : Order 2: 10/7/2013 12:00:00 AM: Limit: Time: 10/7/2013 4:00:00 AM OrderID: 2 Symbol: USDJPY Status: Submitted
2013-10-07 00:00:00 : Current : 97.160
2013-10-07 00:00:00 : Increased price : 97.660
2013-10-09 21:19:00 : Order 2: 10/9/2013 9:19:00 PM: Limit: Time: 10/10/2013 1:19:00 AM OrderID: 2 Symbol: USDJPY Status: Filled Quantity: -10000 FillPrice: 97.66 JPY
2013-10-11 18:00:00 : Algorithm Id:(bdada492d187a8c85c822d96d6498b3a) completed in 1.06 seconds at 6k data points per second. Processing total of 6,841 data points.

so its some time than.....  :)

"" Shouldnt the limit order be filled after some time when price has moved by 50 pips? Am I doing Limit Orders wrong? A sell limit order gets filled at the limit price or higher right? Then why does it get filled immediately? ""

0


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed