Combined Supertrend EURUSD 4Hr

Category: Strategies By: juanj Created: January 24, 2018, 5:35 PM
January 24, 2018, 5:35 PM
Strategies
7 Comments

Here is a 4Hr EURUSD strategy where I decided to combine 4 different supertrend indicators to filter out weaker trends.

The parameters are mostly standard (as originally found) with the exception of a variable named ‘margin’ that defines the minimum distance between two of the specific trend lines.

Defparam cumulateorders = false

possize = 1

//////////////////////////////////////////////////////////////
//Andrew Abraham Trend Trader
//Posted by @Nicolas in PRC Library
/////////////////////////////////////////////////////////////

Length = 21
Multiplier = 3

avrTR = weightedaverage[Length](AverageTrueRange[1](close))
highestC = highest[Length](high)
lowestC = lowest[Length](low)
hiLimit = highestC[1]-(avrTR[1]*Multiplier)
lolimit = lowestC[1]+(avrTR[1]*Multiplier)
 
if(close > hiLimit AND close > loLimit) THEN
 ret = hiLimit
ELSIF (close < loLimit AND close < hiLimit) THEN
 ret = loLimit
ELSE
 ret = ret[1]
ENDIF

/////////////////////////////////////////////////////////////
//Simplified supertrend (without volatility component ATR)
//Posted by @verdi55 in PRC Library
/////////////////////////////////////////////////////////////

ONCE direction = 1
ONCE STlongold = 0
ONCE STshortold = 1000000000000
 
factor = 0.005
 
indicator1 = medianprice
 
indicator3 = close
 
indicator2 = indicator3 * factor
 
STlong = indicator1 - indicator2
 
STshort = indicator1 + indicator2
 
If direction = 1 and STlong < STlongold then
 STlong = STlongold
endif
 
If direction = -1 and STshort > STshortold then
 STshort = STshortold
endif
 
If direction = 1 and indicator3 < STlong then
 direction = -1
endif
 
If direction = -1 and indicator3 > STshort then
 direction = 1
endif
 
STlongold = STlong
STshortold = STshort
 
If direction = 1 then
 ST = STlong
else
 ST = STshort
endif

/////////////////////////////////////////////////////////////
//PRC_adaptive SuperTrend (r-square method) | indicator
//Posted by @Nicolas in PRC Library
/////////////////////////////////////////////////////////////
 
Period = 10
mult = 2
 
Data = customclose
 
SumX  = 0
SumXX = 0
SumXY = 0
SumYY = 0
SumY  = 0
 
if barindex>Period then
 
// adaptive r-squared periods
 for k=0 to period-1 do
  tprice = Data[k]
  SumX  = SumX+(k+1)
  SumXX = SumXX+((k+1)*(k+1))
  SumXY = SumXY+((k+1)*tprice)
  SumYY = SumYY+(tprice*tprice)
  SumY  = SumY+tprice
 next
   
 Q1  = SumXY - SumX*SumY/period
 Q2  = SumXX - SumX*SumX/period
 Q3  = SumYY - SumY*SumY/period
 
 iRsq=((Q1*Q1)/(Q2*Q3))
 
 avg = supertrend[mult,round(Period+Period*(iRsq-0.25))]

EndIf

//////////////////////////////////////////////////////////////////
OriginalST = Supertrend[3,5]
/////////////////////////////////////////////////////////////////

margin = 7*pointsize

If countofposition = 0 and abs(ret[1]-ST[1]) > margin and abs(ret-ST) > margin Then
 If close > ret and close > ST and close > avg Then
  Buy possize contract at market
 ElsIf close < ret and close < ST and close < avg Then
  Sellshort possize contract at market
 EndIf
ElsIf longonmarket and ((abs(ret[1]-ST[1]) < margin and abs(ret-ST) < margin) or ((close < ret and close < ST and close < avg and close < OriginalST) and (close[1] < ret[1] and close[1] < ST[1] and close[1] < avg[1] and close[1] < OriginalST[1]))) Then
 Sell at market
ElsIf shortonmarket and ((abs(ret[1]-ST[1]) < margin and abs(ret-ST) < margin) or ((close > ret and close > ST and close > avg and close > OriginalST) and (close[1] < ret[1] and close[1] < ST[1] and close[1] > avg[1] and close[1] < OriginalST[1]))) Then
 Exitshort at market
EndIf

Download
Filename: Combined-Supertrend.itf
Downloads: 673
Download
Filename: CombinedSupertrend.png
Downloads: 292
juanj Master
My name is Juan Jacobs and I am an algorithmic trader and trading coach. After 7 years of corporate work as a Systems Analyst, I have decided to pursue my passion of trading on a full-time basis. My current focus area is that of 'smart' strategies based on 'Machine Learning'. You can find me at www.FXautomate.com or visit my PRC Marketplace Store here: https://market.prorealcode.com/store/fxautomate/
Author’s Profile

Comments

Logo Logo
Loading...