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.