Today I woke up to my strategy hitting its profit target which is always good news. However, there was an issue.
my code:
if --- and ---- and ---- and --- and ---- then buy this bar ;
setstoploss( --- ) ;
setprofittarget( --- ) ;
My buy order was 7 contracts. My profit target was filled with 7 contracts. However, my stop-loss order changed to 2 contracts once my profit target was filled. So I had a random 2 contract stop order sitting in the live market.
I turned off SA, and tried to cancel the order. It said "precanceled" but stayed in the market. I closed MC and canceled the order with ease from Rtrader.
Because of trying to stay out of harms way, I restarted MC so I believe my logs are gone?
My questions:
1. What happened? and what's a "saved" order? I've been running this code and similar code for quite some time. This has never happened to me.
2. Why would it use a random 2 contracts order when all I do is 7 contracts?
3. Is there any code that can protect me from sitting stoplosses and profit targets that aren't supposed to be there?
Left over orders
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: Left over orders
Hello MAtricks,
- More information about orders statuses can be found here.
- Without logs (that are deleted on restart of the software) we can only guess.
- As i mentioned above, without logs i cannot tell you for sure what happened and what can be done to prevent this. if you are auto-trading this symbol in SA mode and only from one chart, you can add logic to compare inner strategy market position in MC and market position at broker; when they are different for a relatively continuous time, it means something went wrong (like an order status is lost for example).
- Right-click on the chart -> Format Signals... -> Properties -> Auto-Trading -> make a screenshot of this tab.
- Export of “Orders” tab (make sure filters are set to show all the trades) from Order and Position Tracker window: https://www.multicharts.com/trading-sof ... a_to_Excel
- Export of “Logs” tab from Order and Position Tracker window: https://www.multicharts.com/trading-sof ... a_to_Excel
- Complete code of your strategy or a simplified version (i need to see each line where an order is generated).