juanj

Combined Supertrend EURUSD 4Hr

Category: Strategies By: juanj Created: January 24, 2018, 5:35 PM
January 24, 2018, 5:35 PM
Strategies
7 Comments
Combined Supertrend EURUSD 4Hr

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: 677
Download
Filename: CombinedSupertrend.png
Downloads: 294
juanj
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

verdi55
9 years ago
#

You can find me at www.FXautomate.com Ahh. So i got it ? 4 different supertrends without thinking will solve all problems sure nothing is promising here

Nicolas
9 years ago
#

Advertising is allowed,as long as people are helping others and if provided services are about prorealtime.

juanj
9 years ago
#

What? This has nothing to do with the website. The site is simply a service to help people without coding skills or time to automate their own manual trading strategies. If I find it is no good I will tell them. I don't even sell my strategies although I do trade them live myself. I simply created the site as many people have asked me to assist them with automating their trading strategies in the past.

Juanan71
9 years ago
#

made some changes to your code Made some changes to your code..please check https://screencast.com/t/uP5yAY375uN https://screencast.com/t/DJ8rKyOzxO

juanj
9 years ago
#

Looks promising, you can share the code here and maybe explain a bit more on what exactly you changed. https://www.prorealcode.com/topic/combined-supertrend-further-discusion/

Vonasi
9 years ago
#

You could just try running my Seasonality In Sample and Out Of Sample with Rating indicator and then use each months rating as variables that you use as a position size multiplier - similar to Reiner's pathfinder strategy. Unfortunately as the seasonality ratings change as each year passes by backtesting is impossible - you would have to rely on forward testing only to prove it as at the moment the indicator only gives ratings from the present day back through to the beginning of the sampling period.

juanj
9 years ago
#

Does anyone have some ideas suche regards to a seasonality filter perhaps? Maybe too stay out of the market during certain periods of even take larger/smaller positions during others.

ProRealCode ProRealCode
Loading...