No Trend Strategy

Category: Strategies By: FULVIO09 Created: September 18, 2018, 8:40 AM
September 18, 2018, 8:40 AM
Strategies
15 Comments

This strategy uses the “TrendNoTrend indicator” (see in the library).
Once the “No Trend” phase has been identified (beta = 0), swing trading will take place: BUY MIN and SELL MAX. To do this you can use, for example, a SmoothedStochastic.
A simple SuperTrend [3,10] follows the position.
It seems to have positive results on different indices and different time frames, after optimization of the observation period.

//optimization period:
//period = 20 to 300 (default = 10)

// Definizione dei parametri del codice
DEFPARAM  CumulateOrders = False
TimeStart = time >= 000000
TimeStop  = time <= 240000

// Le giornate come 1 maggio, 24, 25, 26, 30 e 31 dicembre, i sabati e le domeniche sono esclusi
GiornoTrading= NOT((Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31) OR OpenDayOfWeek = 6  OR OpenDayOfWeek = 0))

ONCE SIZE = 2  // nr. contratti
ONCE NDBARLIMIT = 3 //  NR. OF BARS ON WHICH THE ORDER STOP REMAINS VALID
ONCE PXT = Pointsize // es. per EURUSD = 0.00001; per EURJPY = 0.001 per DAX = 1
AA = period // PERIOD OF LINEAR REGRESSION AND 1° PERIOD OF STOCHASTIC --> OTTIMIZZARE FROM 20 TO 300 STEP 10
SSTOC = SmoothedStochastic[AA,AA/4](Close)
SUT = SuperTrend[3,10]

// TREND - NO TREND
t=(LinearRegressionSlope[AA](close)-0)*SQRT(AA-2)/(STE[AA](close)/STD[AA](Barindex))
if t<1.96 then
 beta=0
else
 beta=1
endif

// Condizioni per entrare long
C1 =  SSTOC[1] <= 30 AND SSTOC[0] > SSTOC[1] AND beta = 0 // No Trend = SWING
IF C1 then
 OPENBUY = HIGH[0]+ 2*PXT
 MYINDEX = Barindex
ENDIF
IF Barindex >= MYINDEX + NDBARLIMIT THEN
 OPENBUY = 0
ENDIF
IF OPENBUY > 0 AND NOT LONGONMARKET AND GiornoTrading and TimeStart and TimeStop THEN
 BUY SIZE CONTRACTS AT OPENBUY STOP
 // si fissano stoploss e targetprofit
 ST=((LOWEST[10](LOW))-OPENBUY)/PXT
 IF ST > 150 OR ST <=0 THEN // Max stoploss in point
  ST = 150
 ENDIF
 SET STOP pLOSS ST
ENDIF
// Condizioni per uscire da posizioni Long
IF LongOnMarket AND (Close[1]>SUT[1] AND Close<SUT) then // change color of supertrend = close position
 SELL at Market
ENDIF

// Condizioni per entrare short
C21 = SSTOC[1] >= 70 AND SSTOC[0] < SSTOC[1] AND beta = 0 // No Trend = SWING
IF C21 then
 OPENSELL = LOW[0]- 2*PXT
 MYINDEX = Barindex
ENDIF
IF Barindex >= MYINDEX + NDBARLIMIT THEN
 OPENSELL = 0
ENDIF
IF  OPENSELL > 0 AND NOT SHORTONMARKET AND GiornoTrading and TimeStart and TimeStop THEN
 SELLSHORT SIZE CONTRACTS AT OPENSELL STOP
 // si fissano stoploss e targetprofit
 ST=(OPENSELL-(HIGHEST[10](HIGH)))/PXT
 IF ST > 150 OR ST <= 0 THEN
  ST = 150
 ENDIF
 SET STOP pLOSS ST
ENDIF

//Condizioni per uscire da posizioni Short
IF ShortOnMarket  AND (Close[1]<SUT[1] AND Close>SUT) then // change color of supertrend = close position
 EXITSHORT at Market
ENDIF

 

Download
Filename: NoTrendStrategy.itf
Downloads: 1107
Download
Filename: notrendstrategy-1537183466c4lp8.jpg
Downloads: 536
FULVIO09 Senior
This author is like an anonymous function, present but not directly identifiable. More details on this code architect as soon as they exit 'incognito' mode.
Author’s Profile

Comments

Logo Logo
Loading...