Magic Trend Indicator

Category: Indicators By: robertogozzi Created: September 14, 2021, 9:59 AM
September 14, 2021, 9:59 AM
Indicators
32 Comments

Magic Trend Indicator may help identifying the correct trend direction.
It is plotted on the price chart, like any moving average, though it is faster, more accurate
and reliable than other trend following indicators.

The calculation of indicator is based on ATR, current price direction and some more complex
logic.

Magic Trend Indicator changes its color based on the direction of the trend, so if the line
is green then the trend is up and if it is red then the trend is down.
The value of Magic Trend indicator can be used as trend reversal trigger on closing basis.
If you are on long position and on any bar price closes below the indicator value then the
indicator turns red from the next bar to indicate the reversal of trend, so the trader can
exit his long position and take short position at the same time.
The opposite rules apply to the short positions.

A buy signal is also triggered when the closing price crosses above the Magic Trend line and
a short signal is triggered when the closing price crosses below the Magic Trend line.

//cciP = 20
//atrP = 14
//atrM = 1
//smaP = 5
cciP   = max(1,min(999,cciP))
atrP   = max(1,min(999,atrP))
atrM   = max(0.0000001,min(999,atrM))
smaP   = max(1,min(999,smaP))
//
IF BarIndex > max(cciP,atrP) THEN
   lastCCI = thisCCI
   thisCCI = CCI[cciP](typicalPrice)
   myATR   = AverageTrueRange[atrP](close)
   //
   temp1   = myATR * atrM
   upT     = low  - temp1
   downT   = high + temp1
   //
   temp2   = Average[smaP,0](myATR) * atrM
   buffDN  = high + temp2
   buffUP  = low  - temp2
   //
   IF (thisCCI >= 0) AND (lastCCI  < 0) THEN
      buffUP = buffDN[1]
   ENDIF
   IF (thisCCI <= 0) AND (lastCCI  > 0) THEN
      buffDN = buffUP[1]
   ENDIF
   IF (thisCCI >= 0) THEN
      IF (buffUP < buffUP[1]) THEN
         buffUP = buffUP[1]
      ENDIF
   ELSIF (thisCCI <= 0) THEN
      IF (buffDN > buffDN[1]) THEN
         buffDN = buffDN[1]
      ENDIF
   ENDIF
   IF thisCCI >= 0 THEN
      MagicTrend = buffUP
   ELSIF thisCCI <= 0 THEN
      MagicTrend = buffDN
   ENDIF
ELSE
   thisCCI    = 0
   lastCCI    = 0
   myATR      = 0
   buffUP     = 0
   buffDN     = 0
   buffDN     = 0
   buffUP     = 0
   MagicTrend = 0
ENDIF
RETURN MagicTrend AS "MagicTrend"

Download
Filename: Magic-Trend-custom.itf
Downloads: 761
robertogozzi Master
Roberto https://www.ots-onlinetradingsoftware.com
Author’s Profile

Comments

Logo Logo
Loading...