This system uses two moving averages, one short and one long. The system trades when the short moving average crosses the long moving average.

 

DualMovingAverage

The system optionally uses a stop based on Average True Range (ATR). If the ATR stop is used, the system will exit the market when that stop is hit.

 

If the ATR stop is not used, the system does not have an explicit stop and will always be in the market, making it a reversal system. It will exit a position only when the moving averages cross. At that point, it will exit and enter a new position in the opposite direction. In this case, the positions are sized based only on ATR using a custom money manager.

 

If an ATR stop is not used, then the entry risk is essentially infinite. This will cause the R-Multiple™s relatively meaningless since all gains will be less than the infinite risk of entering without any stop.

 

 

The Dual Moving Average System includes five parameters that affect the entries:

 

DMA

 

Long Moving Average

The number of days in the long moving average.

 

Short Moving Average

The number of days in the short moving average.

 

Use ATR Stops

If set to TRUE then the system will enter a stop based on a certain number of ATR from the entry point.

 

ATR Days

The number of days used for the ATR calculation. This parameter is visible and active only if Use ATR Stops is TRUE.

 

Stop

The stop width expressed in terms of ATR. This parameter is visible and active only if Use ATR Stops is TRUE.

 

If the Use ATR Stops is FALSE there are no stops, but the system uses a theoretical 1 ATR stop for the purposes of position sizing.

 

 

Entry Script

VARIABLES: currentclose, stopPrice TYPE: Price
 
' Get the current close.
currentClose = instrument.close
 
' If we are not long and the faster moving averages are above the slower one.
IF   instrument.position <> LONG AND
   shortMovingAverage > longMovingAverage THEN
 
  ' If we are using ATR stops...
  IF useATRStops THEN
      ' Compute the stop price.
       stopPrice = currentClose - (stopInATR * averageTrueRange)
       
      ' Enter a long on the open using this stop.
      broker.EnterLongOnOpen( stopPrice )
       
  ' NOT using ATR stops...
  ELSE
      ' Enter a long on the open with no stop.
      broker.EnterLongOnOpen
  ENDIF
ENDIF
 
' If we are not short and the faster moving averages are below the slower one.
IF   instrument.position <> SHORT AND
   shortMovingAverage < longMovingAverage THEN
 
  ' If we are using ATR stops...
  IF useATRStops THEN
      ' Compute the stop price.
       stopPrice = currentClose + (stopInATR * averageTrueRange)
       
      ' Enter a short on the open using this stop.
      broker.EnterShortOnOpen( stopPrice )
       
  ' NOT using ATR stops...
  ELSE
      ' Enter a short on the open with no stop.
      broker.EnterShortOnOpen
  ENDIF
ENDIF

 

 

Exit Script

' Exit position on open if moving averages cross
IF instrument.position = LONG AND
   shortMovingAverage < longMovingAverage THEN
      broker.ExitAllUnitsOnOpen
ENDIF
 
IF instrument.position = SHORT AND
   shortMovingAverage > longMovingAverage THEN
      broker.ExitAllUnitsOnOpen
ENDIF

 

 

Adjust Stops

' ---------------------------------------------
' Enter stop if "Use ATR Stop" is true
' ---------------------------------------------
 
IF useATRStops THEN
 
  broker.ExitAllUnitsOnStop( instrument.unitExitStop )
ENDIF

 


Edit Time: 9/20/2017 07:56:26 AM


Topic ID#: 130

 

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