Hi all,
I wanted to share this simple but effective strategy. It is only for 5 min time frame until multi timeframe is working in the platform, I also tested in different forex markets but not in index nor in commodities. Here is the set up for long position (for short position is the opposite).
- Price is near and above the SMA200 hourly (i.e SMA 2400 period for 5min timeframe and a bollinger bands for definition of “near” by using the variable BB2400).
- Contraction of Bollinger Bands of period 200 and SMA200 is upwards, contraction defined by the upper band below a maximum of its value in very short term.
- Open Stop Order at the near term resistance by using a pseudo Donchian Channel customized by me.
- Exit at my dynamic SAR (you can check information in a forum of me about this topic) also if close is below support. No profit target.
- Capital management is deactivated but can be activated in the code if needed.
Have a good trade and just tell us your best setup or if you improve the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
//BOLLINGER CONTRACTION v1.0 DEFPARAM CumulateOrders = false // Cumulating positions deactivated DEFPARAM PreLoadBars = 5000 //cargar informacion //VARIABLES TO BE OPTIMIZED //P1= 30 //Kperiod=0.3 //BB200=1.4 //BB2400=0.5 Ksar=0.001 once T0=030000 once T1=210000 once MaxRisk0=30 //ROBOT CONFIGURATION once Ktotalrisk=10 //number of times of maxrirk0 for lossing trade spread=0.9 //Lowest spread for the market once n=1 //initial size of contracts // RISK CONTROL IF THINGS ARE GOING WONDERFULL //n = 1 + (strategyprofit / (34*pipvalue)) //n=SQRT(n) //n = round(n * 100) //n = n / 100 //n = min(max(1,n),20) //SPREAD APROXIMATION IF TIME < 063000 THEN //(germany time) spread=1.7*spread ELSIF TIME>210000 THEN //(germany time) spread=1.7*spread ENDIF //ROBOT WORKING TIME (Germany) IF TIME>T0 and TIME < T1 THEN ontime=1 ELSE ontime=0 ENDIF //RISK CONTROL IF WE NEED TO LEARN OF THIS ROBOT maxrisk=maxrisk0 totalrisk=Ktotalrisk*maxrisk*PIPVALUE //for stop the robot if things are going bad //------------------------------------------------ //>>>>>>>>>> SOPORTES Y RESISTENCIAS <<<<<<<<<<<< //------------------------------------------------ //SOPORTES Y RESISTENCIAS highest1=highest[P1](high) Px1=round(Kperiod*P1) IF highest1 = highest1[Px1] then R1=highest1 ENDIF lowest1=lowest[P1](low) IF lowest1 = lowest1[Px1] then S1=lowest1 ENDIF //------------------------------------------------ //>>>>>>>>>> BOLLINGER CONTRACTION <<<<<<<<<<<< //------------------------------------------------ SMA200=average[200](close) STD200=STD[200](close) BBupper200=SMA200+BB200*STD200 BBlower200=SMA200-BB200*STD200 SMA2400=average[2400](close) STD2400=STD[2400](close) BBupper2400=SMA2400+BB2400*STD2400 BBlower2400=SMA2400-BB2400*STD2400 Contraction200=0 IF SMA200 > SMA200[1] THEN IF BBupper200 < highest[P1](BBupper200) then contraction200=1 ENDIF ELSE IF BBlower200 > lowest[P1](BBlower200) then contraction200=-1 ENDIF ENDIF //-------------------------------------------------------- //>>>>>>>>>>>>>>>>>> TRADING <<<<<<<<<<<<<<<<<<<<< //-------------------------------------------------------- a1= contraction200=1 a2= close > SMA2400 a3= close < BBupper2400 IF a1 and a2 and a3 then IF NOT LongOnMarket AND ontime=1 and DayOfWeek <= 5 THEN entrylong= max(R1,high)+1.5*spread*pipsize stoplosslong= (entrylong-lowest1)/pipsize + 3*spread stoplosslong= min(stoplosslong,maxrisk) BUY n CONTRACTS AT entrylong STOP SET STOP pLOSS stoplosslong ENDIF ENDIF b1= contraction200=-1 b2= close < SMA2400 b3= close > BBlower2400 IF b1 and b2 and b3 then IF NOT ShortOnMarket AND ontime=1 and DayOfWeek <= 5 THEN entryshort= min(S1,low)- 1.5*spread*pipsize stoplossshort= (highest1-entryshort)/pipsize+3*spread stoplossshort= min(stoplossshort,maxrisk) SELLSHORT n CONTRACTS AT entryshort stop SET STOP pLOSS stoplossshort ENDIF ENDIF //--------------------------------------------------------- //>>>>>>>>>>>>>>>>>> EXIT POSITIONS <<<<<<<<<<<<<<<<<< //--------------------------------------------------------- Kexit=1 IF longonmarket THEN Kexit=max(1, ( (close-TRADEPRICE)/pipsize )/(0.5*stoplosslong) ) Kexit=Kexit*Kexit //Kexit= Kexit*SQRT(Kexit) ENDIF IF shortonmarket THEN Kexit=max(1, ( (TRADEPRICE-close)/pipsize)/ (0.5*StopLossShort) ) Kexit=Kexit*Kexit //Kexit= Kexit*SQRT(Kexit) ENDIF mySAR=SAR[Ksar*Kexit,Ksar*Kexit,1] // ---> exit long IF longonmarket then IF close < S1[1]-spread*pipsize THEN SELL AT MARKET ENDIF IF close crosses under MySAR THEN SELL AT MARKET ENDIF IF (close-TRADEPRICE) > 0.5*stoplosslong*pipsize and MySAR<close THEN StopPoints=(TRADEPRICE-mySAR)/pipsize+spread StopPoints=round(StopPoints*10)/10 StopPoints=max(0.5,StopPoints) SET STOP pLOSS min(StopPoints,maxrisk) ENDIF IF TIME > 224500 and DayOfWeek=5 then SELL AT MARKET ENDIF ENDIF // --> extit short IF shortonmarket THEN IF close > R1[1]+spread*pipsize THEN EXITSHORT AT MARKET ENDIF IF close crosses over MySAR THEN EXITSHORT AT MARKET ENDIF IF (TRADEPRICE-close) > 0.5*stoplossshort*pipsize and MySAR>close THEN StopPoints=(mySAR-TRADEPRICE)/pipsize+spread StopPoints=round(StopPoints*10)/10 StopPoints=max(0.5,StopPoints) SET STOP pLOSS min(StopPoints,maxrisk) ENDIF IF TIME > 224500 and DayOfWeek=5 then EXITSHORT AT MARKET ENDIF ENDIF //Quit the robot if things are going bad Q=MAX(Q,((STRATEGYPROFIT/n)/pipvalue)) R=Q-(STRATEGYPROFIT/n)/pipvalue IF R > totalrisk THEN QUIT ENDIF IF STRATEGYPROFIT < (-1*totalrisk) THEN QUIT ENDIF |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Added this to live.
The issue I see is that it can have 100$-200$ win without taking the money.
The only thing that happened is waiting the stop to be triggered.
How come?
This strategy does not have a Profit target, instead it has a Modified parabolic SAR which is accelerating by comparing the actual Profit with the initial stoploss (line 127 to 139)
Running this one in demo with CAC40, inte backtest it buys and sell but not when running live. Do you know why?
Does it opens pending orders?… maybe they were not trigger.
Dont know, all i can see is that it opened an order yesterday in backtest but not live.
The strategie has only made one trade so far maybe it will open the next.
Hello Leo, when running the strategy from 29/12/2015 to 31/08/2018 on ProRealTime Premium, I noticed that the system stops automatically on 27/04/2016.
I analyzed the performance (32 months of historical data):
– There is a loss for Year 2016
– Results are good from early 2017 till now as describded in your screenshot