Triple Moving Average System

This system uses three moving averages, one short, one medium, and one long. The system trades long when the short moving average is higher than the medium moving average and the medium moving average is higher than the long moving average. When the short moving average is back below the medium moving average, the system exits. The reverse is true for short trades.

 

TripleMovingAverage

For this reason, unlike the Dual Moving Average system, this system is not always in the market. The system is out of the market when the relationship between the short MA and medium MA does not match the relationship between the medium MA and long MA.

 

For example, considering Long trades, if the short MA is over the medium MA but the medium MA is under the long MA, the system is out of the market. Likewise if the medium MA is over the long MA but the short MA is not over the medium MA the system is out of the market.

 

This means that the system can initiate trades due to either:

 

Short MA is above the medium MA for Long entries or to below for Short entries. This is the most common case.

Medium MA is above the long MA where the short MA is already over the medium MA for Long entries, or to below the long MA where the short MA is already under the medium MA for Short entries . This will happen when the market has been descending or ascending for a long time and then reverses direction. It takes longer for the medium MA to move to the other side of the long MA since they are both slower moving averages than the short MA.

 

The system optionally uses a stop based on Average True Range (ATR). If the ATR stop is not used, the system uses the value of the long moving average as the stop for the purpose of position sizing.

 

In the event of a stop out, the system will reenter whenever the above conditions are true, even if this is the following day's open.

 

 

The system includes seven parameters that affect the entries:

 

TMA

 

Long Moving Average

The number of days in the long moving average.

 

Medium Moving Average

The number of days in the medium 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 Average

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 the system computes a stop at the price of the long moving average for the purposes of position sizing. In this case, the stop is active only for the first day.

 

Close through Short MA

If set to True, Trading Blox won't take a trade unless the close is also on the right side of the short moving average. For example, with this parameter set to True, in addition to the short moving average being over the medium moving average and the medium moving average being over the long moving average, the close must be above the short moving average in order to trigger a Long position entry.

 

 

 

Entry Script

' Get the current close.
currentClose = instrument.close
 
' If we are not long and the faster moving averages are above the slower ones.
IF  mediumMovingAverage > longMovingAverage AND
   shortMovingAverage > mediumMovingAverage AND
  ((NOT closeThroughShortMA) OR currentClose > shortMovingAverage) AND
  instrument.position != LONG THEN
   
  ' Compute the stop.
  IF stopType = ATR_STOP THEN
       stopPrice = currentClose - (stopInATR * averageTrueRange)
  ELSE
       stopPrice = longMovingAverage
  ENDIF
 
  ' Enter a long at the open using this stop.
  broker.EnterLongOnOpen( stopPrice )  
ENDIF
 
' If we are not short and the faster moving averages are below the slower ones.
IF  mediumMovingAverage < longMovingAverage AND
   shortMovingAverage < mediumMovingAverage AND
  ((NOT closeThroughShortMA) OR currentClose < shortMovingAverage) AND
  instrument.position != SHORT THEN
 
  ' Compute the stop.
  IF stopType = ATR_STOP THEN
       stopPrice = currentClose + (stopInATR * averageTrueRange)
  ELSE
       stopPrice = longMovingAverage
  ENDIF
 
  ' Enter a short at the market using this stop.
  broker.EnterShortOnOpen( stopPrice )
ENDIF

 

 

Exit Script

' If we are long and the short moving average crosses the medium.
IF instrument.position = LONG AND
   shortMovingAverage < mediumMovingAverage THEN
 
  ' Exit on the open
  broker.ExitAllUnitsOnOpen
ENDIF
 
' If we are short and the short moving average crosses the medium.
IF instrument.position = SHORT AND
   shortMovingAverage > mediumMovingAverage THEN
 
  ' Exit on the open
  broker.ExitAllUnitsOnOpen
ENDIF

 

 

Adjust Stops

' ---------------------------------------------
' Enter stop if "holdstops" is true
' ---------------------------------------------
IF holdStops THEN
 
  broker.ExitAllUnitsOnStop( instrument.unitExitStop )
ENDIF

 


Edit Time: 2/18/2022 3:35:42 PM


Topic ID#: 229

 

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