I have an strategy that I usually trade manually, the following is the code for its automatisation. I tested in 100K bar with no WF, I do not use WF because this scenario happens very seldom. Since now I will activated for trading live.
Here is the description for short entries (long entries are opposite):
- The markets is overbought at 17:29 (european last minute market). I define overbought market when the market is moving with a very strong trend: one moving average has been above another one for a long period of time without crossing each other
- Many traders are willing to close positions in the last minutes for not let open positions overnight
- We short entry in the last minute.
I know that this strategy is catching a knife that is falling but very reliable somehow.
These are the settings for DAX, FTSE and DOW JONES:
For DAX:
- P1=5 //period for the fist moving average. From 3 to 15
- P2=33 //period for the second moving average. From 20 to 30
- Pi=70 // numbers of periods without crossing the moving average
- maxrisk0=12 //pips per trade to risk
- Kp=3 // risk-reward ratio from 1 to 3
- Kt=0 // extra time for closing positions. From 0 to 3
For FTSE:
- P1=2 //period for the fist moving average. From 3 to 15
- P2=25 //period for the second moving average. From 20 to 30
- Pi=60 // numbers of periods without crossing the moving average
- maxrisk0=7 //pips per trade to risk
- Kp=3 // risk-reward ratio from 1 to 3
- Kt=0 // extra time for closing positions. From 0 to 3
For Dow Jones (another time):
- P1=8 //period for the fist moving average. From 3 to 15
- P2=17 //period for the second moving average. From 20 to 30
- Pi=40 // numbers of periods without crossing the moving average
- maxrisk0=12 //pips per trade to risk
- Kp=3 // risk-reward ratio from 1 to 3
- Kt=0 // extra time for closing positions. From 0 to 3
Hope you like it and improved. Since now I will activate it for trading live.
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 |
//LAST MINUTE BAR //Autor: LEO DEFPARAM CumulateOrders = false // Cumulating positions deactivated DEFPARAM PreLoadBars = 5000 //cargar informacion //VARIABLES TO BE OPTIMIZED P1=6 //period for the fist moving average. From 3 to 15 P2=23 //period for the second moving average. From 20 to 30 Pi=50 // numbers of periods without crossing the moving average maxrisk0=6 //pips per trade to risk Kp=2 // risk-reward ratio from 1 to 3 Kt=0 // extra time for closing positions. From 0 to 3 IF time > 150000 and time < 180000 then SMA1=average[P1](close) SMA2=average[P2](close) a0= SMA1 > SMA2 a1= lowest[Pi](a0) =1 b0= SMA1 < SMA2 b1= lowest[Pi](b0) =1 myATR=average[Pi](range)+2*STD[Pi](range) IF time=172900 then IF b1 Then stoplosslong=min( (close-low+myATR)/pipsize , maxrisk0) BUY 1 CONTRACTS AT MARKET SET STOP pLOSS stoplosslong SET TARGET pPROFIT Kp*stoplosslong ENDIF IF a1 then StopLossShort=min( (high-close+myATR)/pipsize , maxrisk0) SELLSHORT 1 CONTRACTS AT MARKET SET STOP pLOSS StopLossShort SET TARGET pPROFIT Kp*StopLossShort ENDIF ENDIF // ---> exit long IF longonmarket then IF (Barindex-TRADEINDEX)>5+Kt and (close-TRADEPRICE)/pipsize > stoplosslong THEN SELL AT MARKET ENDIF IF (Barindex-TRADEINDEX)>7+Kt and (close-TRADEPRICE)/pipsize > 0.5*stoplosslong THEN SELL AT MARKET ENDIF IF (Barindex-TRADEINDEX)>9+kt and (close-TRADEPRICE)/pipsize > 0 THEN SELL AT MARKET ENDIF IF (Barindex-TRADEINDEX)>11+Kt and (close-TRADEPRICE)/pipsize < 0 THEN SELL AT MARKET ENDIF endif // ---> exit short IF shortonmarket then IF (Barindex-TRADEINDEX)>5+Kt and (TRADEPRICE-close)/pipsize > StopLossShort THEN EXITSHORT AT MARKET ENDIF IF (Barindex-TRADEINDEX)>7+Kt and (TRADEPRICE-close)/pipsize > 0.5*StopLossShort THEN EXITSHORT AT MARKET ENDIF IF (Barindex-TRADEINDEX)>9+Kt and (TRADEPRICE-close)/pipsize > 0 THEN EXITSHORT AT MARKET ENDIF IF (Barindex-TRADEINDEX)>11+Kt and (TRADEPRICE-close)/pipsize < 0 THEN EXITSHORT AT MARKET ENDIF ENDIF 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
Hi Leo, thank you for sharing yuor TS, wich TF we have to use?
I just optimise in one minute frame. But let me know if this concept works in other time frames but be sure to set time for the last candle in open markets.
Thanks in advance.
How has the results of applying this strategy been live? Thank you for your feedback and possible improvements to your initial strategy. Thank you
One win and one lost. So a tie. I do not have further improvements.
Cheers
No penultimo minuto do Dow (20:58h) a simulação apresenta melhores resultados que no ultimo minuto (20:59h) 😉
Hello Leo. Good evening. Being a programming apprentice and in the PRT I would appreciate a more detailed explanation of your code. Global and what specifically about b1 = lowest [Pi] (b0) what does (b0) in this case? and that part of the code (Barindex-TRADEINDEX)> 7 + Kt and (close-TRADEPRICE) / pipsize> 0.5 * stoplosslong and the evolution of those parts of the code? Thank you
Hi Luminario,
b0 is a condition that the curve SMA1 is below SMA2. As long as this condition is met, then b0 is equal 1.
b1 means that the minimum value for b0 is equal 1 it means , b0 neves was cero for a period of time Pi. That the condition for trade i.e. The curve SMA1 was below SMA2 during a period of time Pi. For me that’s oversold just before markets are closing and it is time for buy.
I always notice that this quick rebound do not last so much therefore I add a condition that if ( Barindex- tradeindex) is more than 7 minutes and something Kt, and trading is already wining half of the stoploss I add, better to close the trade.
Hope you get the meaning of the code. Than write us, we are eager to reply you
Last statements for closure seem incorrect in my opinion:
– “IF (Barindex-TRADEINDEX)>11+Kt and (close-TRADEPRICE)/pipsize 11+Kt THEN”
– “IF (Barindex-TRADEINDEX)>11+Kt and (TRADEPRICE-close)/pipsize 11+Kt”
You want the trade to close after 11 minutes whether in profit or in loss. Currently after 11 minutes if you are in profit it will wait until it is in loss before it closes the trade. This does imply your trade needs to go from negative to positive between the 9th and 11 minute after the trade is entered, and the chance of this happening is limited, but possible. Worst even if that happens and the trade continues beyond 18:00 after which the trade is controlled by SL and TP.
This is a 1 min strategy where the markets has been very oversell / overbought and this code opens a position in opposite direction trying to catch the carry trade from all intraday trades who closes position at the very end of the markets close, if after 11 minutes I am losing better I close the trade because it means the future markets will still pushing the markets in his previous trend.
You can always modify the strategy for better results.
Cheers
hi Leo, are you still using thoses strategy right now?
Any improvements of this?
hi my name is prince i need help