I originally found this code on internet.
To go “long” : when meeting a Harami with a black (or red) candle above the 50 days moving average, we buy the next day at the opening.
We close days later, no matter what happens !
The procedure is the opposite for the “short” trades.
The strategy is profitable on EUR/USD.
WARNING :
The test exclude Sunday candles (included in Mondays).
If you view the candle of Sunday (from 23H to 00H), then the test will be completely distorted !
This code is certainly not a panacea, but it deserves to be refined and improved, no doubt.
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 |
DEFPARAM CUMULATEORDERS = false n = 15 MM50 = average[50](close) REM Définition du Harami c1= high[0] < high[1] c2= low[0] > low[1] harami = c1 and c2 // Prise de position IF harami and close > MM50 and close < open THEN buy n shares at market nextbaropen ENDIF IF harami and close < MM50 and close > open THEN sellshort n shares at market nextbaropen ENDIF // Clôture IF barindex - tradeindex = 1 THEN sell at market exitshort at market 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!Why do I get a result which is -92% and only one trade in daily?
What do you think is wrong?
Hello,
Strange.
Use it on EUR/USD, with NO CANDLE on Sunday.
I use prorealtime.com (free daily data).
Okey thank you. How do I set “NO CANDLE on Sunday” ?
It depends of your broker.
Or you can use the command “dayofweek”
Maybe you can also change the hourly beginning of the day (not 23PM but 12AM, OOH in french). It must be possible.
Hi Doctrading,there is a way to control the max loss of the positions in this code?
For example, if I wanted that the positions do not lose more than 200 euro what kind of code I cat try?
Thank you
Hello,
Yes, there is a command I think, but I don’t know it. Nicolas knows it.
You can also use less leverage.Best regards,