|
Entry Orders Script |
Top Previous Next |
|
Called each day for each instrument at the beginning of the day. The Entry Orders script is the recommended place for creating orders to enter new positions.
The following example Entry Orders script was taken from the Creating a New System tutorial at the beginning of this manual:
IF ( macdIndicator > 0 ) AND ( instrument.position <> LONG ) THEN
' Two conditions must be met - MACD above 0 and we are not long. ' If both are met, we enter long. broker.enterLongOnOpen ENDIF
IF ( macdIndicator < 0 ) AND ( instrument.position <> SHORT ) THEN
' If we are not short and the MACD is below 0, enter short. broker.enterShortOnOpen ENDIF
This script has the broker object enter new long and short positions depending if the macdIndicator is positive or negative.
The script has a common feature of checking for existing positions before entering orders, the check for:
instrument.position <> LONG
and
instrument.position <> SHORT
which is part of the IF statement.
Unless you wish to add to a position and thereby create additional units for your position, you should check if there is already a position before entering orders. |