This system trades counter-trend within Bollinger Bands.
The center of the Bollinger Band is defined by an Simple Moving Average of the closing prices using a number of days defined by the parameter Close Average Days. The top and bottom of the Bollinger Band are defined using a fixed-multiple of the standard deviation from the moving average specified by the parameter Entry Threshold.
The system sells short when the price drops below the entry threshold after having exceeded the trigger threshold. It then exits using a profit target limit order at the price defined by the parameter Exit Threshold.
The system buys long when the price rises above the entry threshold after having gone below the trigger threshold. It then exits using a profit target limit order at the price defined by the parameter Exit Threshold.
The trigger is deactivated if the price crosses to the other size of the band and triggers in the opposite direction before a trade is entered. This might occur due to risk, equity, or volume constraints.
The Bollinger Counter-Trend System includes six parameters that affect the entry and exit:
Close Average
The number of days in the moving average which forms the center of the Bollinger Band channel.
Trigger Threshold
The amount of standard deviation above or below the moving average which the price must reach before triggering a possible entry.
Entry Threshold
Expressed in terms of standard deviation from the moving average, the point below which the system will initiate a short position. When the price hits the trigger threshold and then subsequently goes below the entry threshold a short position is entered, vice versa for long entries.
Exit Threshold
The profit target for winning trades. The system will exit if the price reaches the exit threshold.
Stop Threshold
The number of standard deviation which will result in a stop loss.
For example, a Trigger Threshold of 4, Entry Threshold of 3, Exit Threshold of 1, and Stop Threshold of 4 would cause the system to enter the market on a stop when the price hit the 3 standard deviations above the moving average after having previously exceeded 4 standard deviations above the moving average. The system would exit when the price subsequently dropped below 1 standard deviation above the moving average or once again reached the 4 standard deviation level resulting in a stopped out loss..
NOTE: Exit Threshold can be a negative number which will cause the system to exit only after the price comes some amount through the moving average.
Hold Initial Stops
If set to True, stops will remain at the value on entry. This will prevent stops from moving as the Bollinger Band moves up and down with the moving average. If set to False, then the stop moves to the current value of the Stop Threshold multiplied by the current standard deviation and added to (or subtracted from) the current Close Average value.
Entry Script
' ---------------------------------------------
' Enter orders if triggered
' ---------------------------------------------
IF instrument.position <> LONG AND
longTriggered THEN
broker.enterlongonstop( channelBottom, stopBottom )
ENDIF
IF instrument.position <> SHORT AND
shortTriggered THEN
broker.entershortonstop( channelTop, stopTop )
ENDIF
Exit Script
' ---------------------------------------------
' Reset the triggers if we are in a position
' ---------------------------------------------
IF instrument.position = LONG THEN
' Reset triggers
longTriggered = FALSE
shortTriggered = FALSE
' exit on limit order
broker.ExitAllUnitsAtLimit( exitBottom )
ENDIF
IF instrument.position = SHORT THEN
' Reset triggers
longTriggered = FALSE
shortTriggered = FALSE
' exit on limit order
broker.ExitAllUnitsAtLimit( exitTop )
ENDIF
Adjust Stops
' ---------------------------------------------
' Enter stop if "holdstops" is true
' ---------------------------------------------
IF holdStops THEN
broker.ExitAllUnitsOnStop( instrument.unitExitStop )
ENDIF
After Instrument Day
' ---------------------------------------------
' Check the triggers
' ---------------------------------------------
' Check the short trigger.
IF NOT shortTriggered AND
instrument.position = OUT AND
instrument.high > triggerTop THEN
shortTriggered = TRUE
longTriggered = FALSE
ENDIF
' Check the long trigger.
IF NOT longTriggered AND
instrument.position = OUT AND
instrument.low < triggerBottom THEN
shortTriggered = FALSE
longTriggered = TRUE
ENDIF
Edit Time: 2/18/2022 3:35:42 PM |
Topic ID#: 114 |