Cancel()

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Add On > Account >

Cancel()

Previous page Return to chapter overview Next page

Definition

Cancels specified Order object(s).

 

Syntax

Cancel(IEnumerable<Order> orders)

 

Parameters

orders

Order(s) to cancel

 

 

Examples

ns


private Account myAccount;
Order stopOrder = null;

 
protected override void OnStateChange()
{
  if (State == State.SetDefaults)
  {
      // Initialize myAccount
  }

}

 

private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
{
  // Cancel the stop order if an execution results in a long position
  if(e.MarketPosition == MarketPosition.Long)
      myAccount.Cancel(new[] { stopOrder });
}