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
You must be logged in to post a comment.
Hi FULVIO09, Nice piece of work. It seems to work very well. Does only work for INDEXES?? Have you tried it on commodities or FOREX??? Many thanks,
FULVIO09 • 25 days ago # At line 15 establish the value of “period”. For example: AA = 180 avatar FULVIO09 • 25 days ago # Sorry for lines 39 and 62 we need to set the ABS value: 39 ST = ABS ((LOWEST [10] (LOW)) – OPENBUY) / PXT 62 ST = ABS (OPENSELL- (HIGHEST [10] (HIGH))) / PXT Même après cette manipulation , ça ne fonctionne pas pour moi . Pouvez vous expliquer en détail ?
Hi @FULVI09, I understand the instructions however I'm not too sure how to determine the "period" that generate the best performance, you mentioned 180 in the previous post, could you kindly explain where you got it from and what method you use to determine the "period" that generate the best performance. Thanks for your contribution and looking forward to read your response. Regards, Johann.
Avec le file notrendstrategy.itf, vous pouvez exécuter un probacktest sur l'instrument financier et la période que vous préférez et trouver la valeur de la variable "period" qui vous offre les meilleures performances. Si vous souhaitez démarrer le processus de négociation automatique sur l'instrument et la période choisie, vous devez fixer la valeur de period à la ligne 15 (par exemple AA = 180) et cliquer sur l'icône en forme de clé en haut à droite "optimisation variables" effacer la variable "period" à optimiser (cliquez sur la x rouge).
Con il file notrendstrategy.itf che hai scaricato puoi eseguire un probacktest sullo strumento finanziario e timeframe che preferisci e trovare il valore della variabile "period" che ti dà la migliore performance. Se vuoi avviare l'autotrading proorder sullo strumento e time frame prescelto devi fissare alla linea 15 il valore di period (ad es. AA = 180) e cliccare sull'icona a forma di chiave inglese in alto a destra "ottimizzazione variabili" cancellare le variabili da ottimizzare (clicca sulla x rossa).
Good piece of work. I've tried trading in live but always falls over suggesting I haven't loaded enough bars. I changed code to set DEFPARAM to 2000 and still suggests not enough bars on the 10 minute time frame. Any ideas as to what might be wrong? The period of linear regression is set to 240.
Bonjour merci BEAUCOUP !!! cela fonctionne!!!
Merci pour cette stratégie. comment remplacez les variables par les valeurs fixes ? à quel endroit dois je remplacer ? c'est le pro order qui me le demande.
Thank you for sharing this strategy. Although I think the optimization should be done with Walk Forward to test its robustness, I salute the work and the idea. This strategy deserves to attract more attention than in a topic "lost" in the forum, it has its place in the library :) PS: I changed your illustration picture with another one (it was too small :) )
Hello, It doesn't work with me either. However, I changed AA to 180 on line 15, added the abs functions to the 2 lines indicated 39 and 62, preloaded 2000 bars and deleted the variable to be optimized. Has anyone found the fault since? Thank you.