Code: Select all
If Date = 1101005 then Begin
If Time = 0835 then
Buy 3 contracts next bar at the market;
If Time = 0900 then
Buy 2 contracts next bar at the market;
If Time = 0930 then
sell 1 contracts next bar at the market;
If Time = 1000 then
Sell 4 contracts next bar at the market;
As you can see, if the day is today's date, the system will buy and sell based upon what time it is. It first buys 3 contracts, then buys 2 contracts, then sells 1 contract and then sells 4 contracts.
However, when I actually run this code, it does the buys correctly but then when it comes to the first sell (at 9:30 am) it sells 2 contracts and then it sells 3 contracts at 10:00 am. I've attached a chart showing this.
Right now, the system is configured to allow 10 entry orders in the same direction as the currently held position regardless of the entry that generated the order. I'm not sure how this impacts the execution of the strategy but that's how it is currently configured.
If anyone has any idea on how to correctly have these buys and sells executed by MultiCharts, it would be greatly appreciated.