How do you attach a trade management function to pending orders

Posted By: swingtraderkk

How do you attach a trade management function to pending orders - 08/01/13 16:20

Hi all,

Can someone explain the syntax for attaching a tick by tick trade management function to a pending trade. e.g. for cancelling other trades as soon as one is hit, or for pyramiding in once a trade has moved in your direction?

Or is there another method to respond to events mid bar, events such as when pending trades are opened or when open trades are closed?
Posted By: jcl

Re: How do you attach a trade management function to pending orders - 08/05/13 08:36

For cancelling other trades, use a global variable "CancelOtherTrades" that is set and evaluated by the TMF.

Code:
int MyTMF()
{
  if(TradeIsPending and CancelOtherTrades == 1)
    return 1;
  if(TradeIsOpen) {
    CancelOtherTrades = 1;
    ThisTrade->manage = 0; // terminate the TMF
  }
  return 0;
}

© 2024 lite-C Forums