IOG and stop orders

Questions about MultiCharts and user contributed studies.
tozwp
Posts: 145
Joined: 15 Apr 2011
Has thanked: 16 times
Been thanked: 8 times

IOG and stop orders

Postby tozwp » 19 Apr 2014

Working on a strategy and have some questions regarding trade closing orders. The strategy operates with Intrabar Order Generation on so it operates on every price tick. The strategy calculates the exit price on every tick and then sets up an exit order for the next tick. My questions are: Will this order reside at the broker written like this? If it does, will it issue an order on every tick? Is this code equivalent to using the SetStopLoss command or should it be used instead? Is it better to use SetStopLoss instead of this code and if so, why or why not? I'm pretty sure that SetStopLoss creates orders held at the broker (IB) but not sure if my code will do the same. If either or both of these methods generates an order on each tick, is that excessive and is that a problem for the broker? The strategy operates on hourly bars so it is not trying to scalp ticks. It has to run IOG to adjust stops within the bar and take partial profits. Thanks!

Code: Select all

If Condition1 then exit = some logic;
If Condition2 then exit = some logic
If Condition3 then exit = some logic;
If Condition4 then exit = some logic;

If MP = 1 and Condition2 and PartProfit = false then begin
PartProfit = true;
sell from entry("Long") .25*size shares next bar at market;
end;

if MP = 1 then sell from entry("Long") next bar at exit Stop;

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: IOG and stop orders

Postby Andrew MultiCharts » 21 Apr 2014

Hello tozwp,
Will this order reside at the broker written like this?
Interactive Brokers supports stop orders natively. It means that if your code generates a stop order and it is sent from MC, the stop orders are held on your broker end.
If it does, will it issue an order on every tick?
It will "generate" the order on every tick if the conditions are met. If you already have the same order pending at broker end, the order will be "maintained" (no new orders will be sent).
Is this code equivalent to using the SetStopLoss command or should it be used instead?
The exiting piece of your code is almost equivalent. In your code you check MP condition and as soon as it is satisfied you place the exit order. If you put the SetStopLoss without any conditions, it will not check MP itself, so the exit order will be sent to broker as soon as you have an open market position (with MP checking as you have it in your code, it will wait for additional calculation to do that).
Is it better to use SetStopLoss instead of this code and if so, why or why not?
Assuming the generated order price is the same, the following 2 lines of code are the same:

Code: Select all

if MP = 1 then sell from entry("Long") next bar at exit Stop;
//or
if MP = 1 then SetStopLoss(X);
I'm pretty sure that SetStopLoss creates orders held at the broker (IB) but not sure if my code will do the same.
It should do the same and in both cases the stop orders are held at broker end.
If either or both of these methods generates an order on each tick, is that excessive and is that a problem for the broker?
No, as i said previously, the previous order is maintained.


Return to “MultiCharts”