Exits the specified unit for the current instrument on the next bar if the market goes lower than the stop price for long positions or higher than the stop price for short positions. This function is generally used by an Exit Block to lighten up a position.



broker.ExitUnitOnStop( unitNumber, stopPrice, [ quantity ] )





Unit to exit


A price at which the next bar must exceed (above/below) to trigger this order


Exit option to remove a partial quantity from the unit.  When left blank, entire unit will be removed.



When a broker function succeeds it will place a True in the system.orderExists() and when it fails to this property will return a False.  Before attempting to access any order information expected from a broker order, consider checking to confirm an order was created with a conditional statement similar to this:

  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  When New Order is Created,...
  If system.OrderExists() THEN
    '  Apply Order Detail To Trade Information
    order.SetRuleLabel( sRuleLabel)
    '  Apply Order Details To Order Information
    order.SetOrderReportMessage( sRuleLabel)
  ENDIF '  s.OrderExists
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



' Exit the first unit if the market hits our stop.
broker.ExitUnitOnStop( 1, exitStop )



Broker, Exit Order Functions

See Also:



Edit Time: 6/19/2018 11:48:28 AM

Topic ID#: 329


Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software