# Problem with Stop Limit Order

Questions about MultiCharts and user contributed studies.
ppan
Posts: 106
Joined: 31 Jan 2007
Has thanked: 2 times

### Problem with Stop Limit Order

I have a 1 min chart with the following code:
-----------------------------------------------------------------
if marketposition <> 1 then buy 100 contracts next bar at high stop high + 1 limit;
if marketposition <> -1 then sell 100 contracts next bar at low stop low - 1 limit;
-----------------------------------------------------------------
After the price is above high, MC buy 100 contracts at high+1 limit price.
However when the broker is executing the limit order, MC issue the next sell stop limit order to the broker. The previous buy order is stopped even the total contracts bought is not 100.

Is there any way to solve this problem?

Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 300 times

### Re: Problem with Stop Limit Order

Your code is saying the following:

If market position does not equal 1 then buy 100 contracts at the "high+1" price or lower, with the condition that price is "high" or higher.

If market position does not equal -1 then sell 100 contracts at the "Low-1" price or higher, with the condition that price is "low" or lower.

Is IOG turned on? What's the symbol, which data provider?

ppan
Posts: 106
Joined: 31 Jan 2007
Has thanked: 2 times

### Re: Problem with Stop Limit Order

I'm using IB and the symbol is HSIJ11.
The procedure is:
1. After the market price is higher than high, the IB will buy 100 contracts at the price of high + 1 using limit order.
2. While IB is buying the 100 contracts and not yet finished, the new 1 min bar is produced. Then a new sell stop limit order is send to IB.
3. For example, while IB bought 30 contracts and still buying the remaining 70 contracts, the new sell order is send to IB.
4. Then IB will stop buying the remaining 70 contracts and the buy order is canceled and replaced with the new sell order.

The problem is how to let the buy order continue to buy all 100 contracts even the new sell order is existed.

Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 300 times

### Re: Problem with Stop Limit Order

Try this

if marketposition <> 1 then buy 100 contracts next bar at high stop high + 1 limit;
if MarketPosition_at_Broker_for_The_Strategy = 100 then sell 100 contracts next bar at low stop low - 1 limit;