This script has Automatic Instrument Context by default. This means, when this script section executes, it is given direct access to all IPV Properties and Functions.
When the current instrument in the portfolio is selected and it also has an existing active position this script's access is enabled for execution.
Exit Orders Script section is used to create order that:
oExit a one or more units in a multiple unit position
oExit and entire position
oAdjust a protective price for an entire position
oAdjust the protective any, or only some of the units in a position.
oIncrease a unit or a position quantity
oDecrease a unit or a position quantity
Most of the position's need shown above are created when the Exit Order script is called.
NOTE: This scripts section will not normally execute when a instrument specific date record is not in the instrument's data file.
A current record is a record date for the same test date on which this script is executing. This means a test date must have an instrument date price record in order for this script section to execute.
When it does have a missing instrument record any orders that were active for the active test date, orders will not be filled or expired by the brokerage process. However, when an order is still active after the brokerage process, it will be available to execute an order fill or allowed to expire on the next available instrument date trading session. |
Example: |
---|
' RSI Trend Exit block uses the following code in the Exit Orders script: |
NOTE: |
This sample script has two common features.
1.It is able to check against an active position use resolving the instrument.position property to determine if the active position is LONG or SHORT positions.
2.By assigning its Exit Stop order price to the instrument.unitExitStop price its previously protective price is available as a worse case Exit Price Stop value.
You will need logic like this if you wish to have stops which are in effect for the duration of a trade. Trading Blox Builder requires that you place new orders for stops each day. |
Edit Time: 9/13/2020 3:22:47 PM |
Topic ID#: 323 |