Improving trading systems...

 

Hi, just thought id add a note on how you can improve your trading systems...

I think it's best to put the OrderClose and OrderSend functions in a critical section - ie. lock them when they are being executed as, in general, they can take longer to execute.

Here's how to add a critical section to your code; it's mutual exclusion:

bool is_locked = false;

void lock(){

is_locked = true;

}

void unlock(){

is_locked = false;

}

bool isLocked(){

return (is_locked);

}

[/PHP]

Then to use it, just do the following:

[PHP]

if(isLocked() != true){

lock();

OrderSend(....);

unlock();

}

Many of you will find that this improves backtesting results. And it's good practice for critical sections, especially for live trade. Hope it helps!

TraderDavid.

 

btw...

btw... you can use the locks on any section you think is critical - not just ordersend, etc.

any section which should execute atomicly should be locked executed, then unlocked - to ensure it executes as a whole before being interfered with again.

traderdavid.