I paste my code below, and if others could do the same, it would be very much appreciated!

Any general comments on order handling issues you've ran into, or general order handling tips, are also appreciated.

I would ideally like to be able to apply multiple signals on the same instrument, but because of MY MAIN PRIORITY described below, it seems I will have to settle for running them simultaneously, BUT with only one of them being able to have a position open at each time.

MY MAIN PRIORITY is to never be left with an open position without stop order. That's why I always send related stoploss and take profit orders (OCO) at the same time as entry order. (That way I'm protected by native stoploss at broker in case of connectivity issues, order rejections, errors in my code generating multiple orders, etc.)

Below is the code of 2 separate signals (A and B), merged into one signal code. They function independently, but none of them can open a position if the other one is already in position. So far this is the best I've been able to do. Any comments very wellcome!

For those unfamiliar with the topic, here is a link to some basics:

http://www.multicharts.com/trading-software/index.php/Trading_from_Multiple_Charts_on_One_Instrument

Code: Select all

`vars:`

intrabarpersist SignalAstation(0),

intrabarpersist SignalBstation(0);

[IntrabarOrderGeneration = True];

//SignalA///////////////////////////////////////

if SignalAstation=0 then begin

if close >10 {Just some random logic for the example} then SignalAstation=1;

end;

if SignalAstation=1 and marketposition=0 then begin

buy 1 contracts next bar market;

setstoploss(5);

setprofittarget(10);

SignalAstation=2;

end else SignalAstation=0;

if SignalAstation=3 then begin

if marketposition=0 then SignalAstation=0;

end;

//SignalB////////////////////////////////////////

if SignalBstation=0 then begin

if close <20 {Just some random logic for the example} then SignalBstation=1;

end;

if SignalBstation=1 and marketposition=0 then begin

sell 1 contracts next bar market;

setstoploss(5);

setprofittarget(10);

SignalBstation=2;

end else SignalBstation=0;

if SignalBstation=3 then begin

if marketposition=0 then SignalBstation=0;

end;