EEUU Tech 100 20minutes MACD Strategy Long
Forums › ProRealTime English forum › ProOrder support › EEUU Tech 100 20minutes MACD Strategy Long
- This topic has 6 replies, 3 voices, and was last updated 6 years ago by GraHal.
-
-
02/23/2018 at 9:46 AM #63592
Hello everyone,
I would like to share with you my first code. What I’m pretending is to know when enter into the market for now only with Long positions.
I took the MACD crossing lines to know when enter over next 20 minutes when this occurs but taking into account the Volume and the RSI.
It is good, but I know that could one of the best 😉 It is why I’m sharing this code, to make it better using maybe another indicators or strategies to know exactly when exit.
The system enter very well….but doesn’t exit properly.
Can you help me to improve it?
Thank you!!!
P.D: It also works over SP500
123456789101112131415161718192021222324252627282930313233343536373839DEFPARAM CumulateOrders = false // Posizioni cumulate disattivateDEFPARAM flatbefore = 153000DEFPARAM flatafter = 224500ncontracts = 50currentRSI = RSI[20](close)volumen = VolumeBlueLineMACD = MACDLINE(close)RedLineMACD = ExponentialAverage[9](BlueLineMACD)//GRAPH BlueLineMACD Coloured(0,0,255) as "Blue Line MACD"//GRAPH RedLineMACD Coloured(255,0,0) as "Red Line MACD"//GRAPH amplitude Coloured(125,125,0) as "Amplitude MACD"// Condiciones para entrada de posiciones largasIF NOT LongOnMarket AND currentRSI[0] > currentRSI[1] AND currentRSI[0] > 50 AND BlueLineMACD[0] >= RedLineMACD[0] AND volumen > 5000 AND close[10] < close[1] AND close[2] - close[1] < 5 THENBUY ncontracts CONTRACTS AT MARKETlongentryrsi = currentRSIlongvolumn = volumenvolumndecresess = 0ENDIFIF volumen < longvolumn THENvolumndecresess = volumndecresess + 1ELSEvolumndecresess = 0ENDIFrsidiff = currentRSI[0] - longentryrsi// Condiciones de salida de posiciones largasIf LongOnMarket AND (rsidiff < 6 AND BlueLineMACD[0] <= RedLineMACD[0]) THENSELL AT MARKETENDIF// Stops y objetivos: introduzca aquí sus stops de protección y objetivos de beneficiosSET STOP $LOSS 2000SET TARGET $PROFIT 200002/23/2018 at 2:09 PM #63682Looks like its got good potential, I got below on the Dow over 10,000 bars at £1 per point spreadbet on 5 Min Timeframe.
I changed only the settings below to as shown
<pre class=”lang:probuilder decode:true”>SET STOP $LOSS 160
SET TARGET $PROFIT 235GraHal
02/27/2018 at 8:28 PM #64069Hi frovira
Might you be considering doing a Short version of this Algo at any time please?
I love the short duration in and out! To my way of thinking this shows the Algo entered at the right time, made the money and then exit … no need to wait around down and up, up and down over many periods until a profit shows up!?
Well Done, Good Work!
GraHal
PS Wow … even trying an optimised time constraint doesn’t improve results! It could be that trades are intrinsically not taken overnight due to conditions not met etc.02/27/2018 at 9:06 PM #64075Lots of the winning Trades have a £0 MAE and loads have a very low MAE, only 8 eventual winning trades have a MAE of any significance (6 at -£20s, 1 at -£33 and 1 at -£65.
Yeah we need that Short version frovira.
I’ll have a try at a better exit strategy, others please feel free to contribute as my coding skills are nowhere near lots on here.
Cheers
GraHal02/27/2018 at 9:09 PM #64076Hello,
thx for the code! Two swift remarks:
- the standard 14 period for RSI works slightly better, so no added value to take 20.
- the variable “volumndecresess” is not used in your code
1 user thanked author for this post.
02/27/2018 at 10:44 PM #64085I guess Volume > 5000 will limit overnight trades, but I’ve put the time constraint below on it anyway with no reduction in gain on DAX @ 15 min over 100,000 bars.
PS / Edit I’ve just remembered … there is no volume on DAX anyway after 16:30 GMT??
1MyTime = Time > 070000 and Time < 210000I’ve also added Nicolas Trailing Stop … full code below. About £100 improvement and with additional safety. also.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182//https://www.prorealcode.com/topic/eeuu-tech-100-20minutes-macd-strategy-long/DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate//DEFPARAM flatbefore = 153000//DEFPARAM flatafter = 224500MyTime = Time > 070000 and Time < 210000ncontracts = 1currentRSI = RSI[14](close)volumen = VolumeBlueLineMACD = MACDLINE(close)RedLineMACD = ExponentialAverage[9](BlueLineMACD)//GRAPH BlueLineMACD Coloured(0,0,255) as "Blue Line MACD"//GRAPH RedLineMACD Coloured(255,0,0) as "Red Line MACD"//GRAPH amplitude Coloured(125,125,0) as "Amplitude MACD"// Condiciones para entrada de posiciones largasIF NOT LongOnMarket AND currentRSI[0] > currentRSI[1] AND currentRSI[0] > 50 AND BlueLineMACD[0] >= RedLineMACD[0] AND volumen > A AND close[10] < close[1] AND close[2] - close[1] < 5 AND MyTime THENBUY ncontracts CONTRACTS AT MARKETlongentryrsi = currentRSIlongvolumn = volumenvolumndecresess = 0ENDIFIF volumen < longvolumn THENvolumndecresess = volumndecresess + 1ELSEvolumndecresess = 0ENDIFrsidiff = currentRSI[0] - longentryrsi// Condiciones de salida de posiciones largasIf LongOnMarket AND (rsidiff < 6 AND BlueLineMACD[0] <= RedLineMACD[0]) THENSELL AT MARKETENDIF// Stops y objetivos: introduzca aquí sus stops de protección y objetivos de beneficiosSET STOP $LOSS 110SET TARGET $PROFIT 110//trailing stop functiontrailingstart = 70 //trailing will start @trailinstart points profittrailingstep = 6 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF//************************************************************************//GRAPH newSL as "trailing"02/28/2018 at 3:33 PM #64137Below Long and Short version (although very few shorts!) for UKX @ 15 Min
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172//https://www.prorealcode.com/topic/eeuu-tech-100-20minutes-macd-strategy-long/DEFPARAM CumulateOrders = false // Posizioni cumulate disattivateMyTime = Time > 070000 and Time < 210000MHist = MACD[12,26,9](close)BlueMACD = MACDline[12,26,9](close)RedMACD = BlueMACD - MHist//GOLONGIF RSI[14](close) > 65 AND BlueMACD crosses over RedMACD AND volume > 2500 AND ADXR[14] > 15 AND Average[7](close) > Average[20](close) AND MyTime THENBUY 1 CONTRACTS AT MARKETENDIF//EXITLONGIf RSI[14](close) < 30 AND BlueMACD crosses under RedMACD THENSELL AT MARKETENDIF//GOSHORTIF Chandle[20](close) < -80 AND BlueMACD < RedMACD AND MyTime THENSellShort 1 CONTRACTS AT MARKETShortChandle = Chandle[20](close)ENDIFChanddiffShort = abs(Chandle[20](close)- ShortChandle)//EXITSHORTIf ChanddiffShort > 24 AND BlueMACD > RedMACD THENExitShort AT MARKETENDIFSET STOP PLOSS 50SET TARGET PPROFIT 100//trailing stop functiontrailingstart = 160 //trailing will start @trailinstart points profittrailingstep = 6 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF -
AuthorPosts