Strategy TrendImpulse v1

Category: Strategies By: Dow Jones Created: April 28, 2020, 8:24 AM
April 28, 2020, 8:24 AM
Strategies
21 Comments

Here is a new strategy on Wall Street/DJI 5 min TF that utilize Perfect Trend Line as entry/exit and Trend Impulse Filter as trend direction. All credits to the original author.

DLS code is added to avoid high spread period. Time Zone used is UTC+08:00.

Forum for discussion https://www.prorealcode.com/topic/strategy-trendimpulse-v1/

DEFPARAM CumulateOrders = false
DEFPARAM PRELOADBARS = 1000

// ---------   US DAY LIGHT SAVINGS MONTHS      ---------------- //
mar = month = 3 // MONTH START
nov = month = 11 // MONTH END
IF (month > 3 AND month < 11) OR (mar AND day>14) OR (mar AND day-dayofweek>7) OR (nov AND day<=dayofweek AND day<7) THEN
 USDLS=010000
ELSE
 USDLS=0
ENDIF

timeok = NOT(time >051500- USDLS AND time <053000 - USDLS) AND NOT(time >060000 - USDLS AND time <070000 - USDLS)

timeframe(5 minute)
thigh1 = Highest[SlowLength](high)+ SlowPipDisplace*pointsize
tlow1  = Lowest[SlowLength](low)- SlowPipDisplace*pointsize
thigh2 = Highest[FastLength](high)+ FastPipDisplace*pointsize
tlow2  = Lowest[FastLength](low)- FastPipDisplace*pointsize

if barindex>2 then
 if Close>line1[1] then
  line1 = tlow1
 else
  line1 = thigh1
 endif
 if Close>line2[1] then
  line2 = tlow2
 else
  line2 = thigh2
 endif
endif

if (Close[0]<line1[0] and Close[0]<line2[0]) then
 trend =  1
endif
if (Close[0]>line1[0] and Close[0]>line2[0]) then
 trend = -1
endif
if (line1[0]>line2[0] or trend[0] =  1) then
 trena =  1
endif
if (line1[0]<line2[0] or trend[0] = -1) then
 trena = -1
endif
if trena<>trena[1] then
 if trena=1 then
 //bear
  prefecttrend = 2
 else
 //bull
  prefecttrend = 1
 endif
endif

timeframe(default)

once bb = src
if barindex>length then
 src = (highest[length](high)+lowest[length](low))/2
 rising = src-src[length]>0
 falling = src-src[length]<0
 aa = rising or falling
 bb = exponentialaverage[centertrend](aa*src+(1-aa)*bb[1])
//—-

 if bb>bb[1] then
  //bull
  trendimpulse = 1
 elsif bb<bb[1] then
  //bear
  trendimpulse = 2
 endif

endif


//====== Enter market - start =====

//  LONG  side
C1 = trendimpulse = 1 AND prefecttrend[1] = 2 AND prefecttrend = 1

IF timeok AND Not OnMarket AND C1 THEN
 BUY 1 CONTRACT AT MARKET
 SET STOP   pLOSS   SL

ENDIF

//  SHORT side
C2 = trendimpulse = 2 AND prefecttrend[1] = 1 AND prefecttrend = 2

IF timeok AND Not OnMarket AND C2 THEN
 SELLSHORT 1 CONTRACT AT MARKET
 SET STOP   pLOSS   SL

ENDIF


//====== Enter market - end =====

//====== Exit market - start =====

X1 = prefecttrend[1] = 1 AND prefecttrend = 2
IF LONGONMARKET AND X1 THEN
 SELL AT MARKET
ENDIF


X2 = prefecttrend[1] = 2 AND prefecttrend = 1
IF SHORTONMARKET AND X2 THEN
 EXITSHORT AT MARKET
ENDIF


//====== Exit market - end =====

Download
Filename: XXXDJI-M1-TrendImpulsev1-1.itf
Downloads: 1127
Download
Filename: DJI-5-minutes-2020_04_27-04h47_Result.png
Downloads: 560
Dow Jones Veteran
Currently debugging life, so my bio is on hold. Check back after the next commit for an update.
Author’s Profile

Comments

Logo Logo
Loading...