Hi, I tried to implement some simple RSI strategy in QuantConnect, targeting MSFT and Interactive Brokers, and got stuck with order management. Strategy itself goes long only.
1. I need to open Market Order + Stop Loss, so I execute MarketOrder() and then StopMarketOrder() from OnData, how to make sure that Market Order will not be rejected I will have only Stop Loss filled?
2. how to implement Trailing Stop, or in other words, how to move stop loss orders for all open positions?
3. can't figure out difference between TotlProfit, UnrealizedProfit, etc, how to define condition, like "close all positions when profit is more than 1% or initial balance", when I say balance I mean amount of money with all positions closed
4. in some reason I can use only SPY as a benchmark, how can I compare my strategy equity to original MSFT chart as a benchmark?
Artemiusgreat
5. how to detect exact moment when RSI crosses Level 30, not when it's above this level, but when it's crossing it?
Artemiusgreat
6. Tried to implement Bracket Orders, Market + Stop Loss + Take Profit, synchronous version works but incredibly slow, anf if I try to place Stop Loss and Limit orders from separate thread they are placed at price 0, why?
Synchronous version - works fine but slow:
var order = MarketOrder(iSymbol, iVolume);
Transactions.WaitForOrder(order.OrderId);
var orderSL = StopMarketOrder(iSymbol, -iVolume, price - iSL);
var orderTP = LimitOrder(iSymbol, -iVolume, price + iTP);
Asynchronous - place order at price 0:
var order = MarketOrder(iSymbol, iVolume);
iOrders[order.OrderId] = order;
var process = new Thread((data) => {
Log("#### " + data + " : " + iSL + " : " + iTP + " : " + price + " : " + iSymbol);
Transactions.WaitForOrder(order.OrderId);
var orderSL = StopMarketOrder(iSymbol, -iVolume, price - iSL);
var orderTP = LimitOrder(iSymbol, -iVolume, price + iTP);
});
process.Start(price);
Results:
Artemiusgreat
I think I figured out my question #6 about order at zero price, reason - I was using order incorrectly above or below the price, now I'm trying to use StopMarketOrder for my Stop Loss and Take Profit orders and have another issue - they all execute as simple Market Orders at the moment of placing.
According to the logs, orders should use these values.
2017-11-21 00:00:00 :### Price : 82.54000000000 vs SL : 77.54000000000 vs TP : 92.54000000000
2017-11-22 00:00:00 :### Price : 83.73000000000 vs SL : 78.73000000000 vs TP : 93.73000000000
Meanwhile, both, SL and TP gets executed at current prices, 82.54 and 83.73
Artemiusgreat
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!