Yes, phoentzs is right, you should use a Trailing Stop code snippet,you can search this forum or the Snippet Library.
Hi, murre87 I thought I would write you a tweaked BOT, modified around stop and entry to improve with a little 5 min direction to help!
Anyone feel free to use or improve, I am going to post this to the library
My results are a little bit diffrent. The spread in that program is wrong. Spread is 1.2 (for german user). But also with 1p spread, the results are diffrent.
smpParticipant
Average
Thanks for the feedback, guys. I reviewed and adjusted the code to include a 1.2 spread (Thanks, VinzentVega for the reminder), so don’t add more spread when testing!
I have reduced the losses, improved the risk management.
Again tested on V10.3 using 100,000 units
Test pic of tick by tick on and off
//Early Bird Breakout Strategy v1.0, updated with active risk code v1.2
//November 10th 2021
//www.harkoltd.com
//==========================================================
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Cancel all pending orders and close all positions at the "FLATAFTER" time
DEFPARAM FLATAFTER = 120000
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 110000
timeEnterAfter = time < noEntryAfterTime
//==========================================================
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
//==========================================================
//Stake limited to 1.0% bank risk and topping at 1.7% return using active risk management code. Bank Risk Stop =1% and Target >2% (based on £10k account)
Stake=16
Spread=1.2
maxstop=6
Takeprofit=15
//==========================================================
//Limit to one trade
Trade = Barindex - TradeIndex(1) > IntradayBarIndex
//==========================================================
//Trading spread, entry of half spread
If Spread = 1.2 THEN
SpreadEntry = 0.6
ELSE
SpreadEntry = Spread
ENDIF
//==========================================================
//Active Risk management rules (To help the longs, shorts when wrong go straigh stop)
BreakevenAt =6
takeprofit =12
startBreakeven = takeprofit *(BreakevenAt/80)
PointsToKeep =4
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
IF ONMARKET AND close-tradeprice(1)>=startBreakeven THEN
breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
ENDIF
IF breakevenLevel>0.5 THEN
SELL AT breakevenLevel STOP
ENDIF
//==========================================================
//Leading breakout direction
Timeframe (5 MINUTE)
EMA1 = ExponentialAverage[22](close)
EMA2 = ExponentialAverage[3](close)
IF EMA1 > EMA2 AND EMA1 > EMA1[1] AND EMA2 > EMA2[1] THEN
LongNotShort = 1
ENDIF
IF EMA1 < EMA2 AND EMA1 < EMA1[1] AND EMA2 < EMA2[1] THEN
LongNotShort = 0
ENDIF
IF abs(EMA1 - EMA2) < 1 THEN
LongNotShort = 0.5
ENDIF
//==========================================================
//Entry timeframe
Timeframe (1 minute)
OpenUK = 080000
Start = time >=OpenUK
if openTime = 070000 then
myHighest = high
myLowest = low
endif
if openTime >= 070000 and openTime <=075955 then
myHighest = max (myHighest,high)
myLowest = min (myLowest,low)
endif
//==========================================================
If Start and Trade and timeEnterAfter and not daysForbiddenEntry then
// Conditions to enter long positions (0.5pt break)
IF LongNotShort = 1 THEN
BuyPrice = myHighest + SpreadEntry + 0.6
BUY stake PERPOINT AT BuyPrice stop
ENDIF
// Conditions to enter short positions
IF LongNotShort = 0 THEN
SellPrice = myLowest - SpreadEntry - 0.6
SELLSHORT stake PERPOINT AT SellPrice stop
ENDIF
SET STOP LOSS Maxstop
SET TARGET pPROFIT TakeProfit
endif
1m bar backtest, stake = 1 (for easier comparison to other algos)
TBT, no additional spread
€ 1 per trade profit on average?
smpParticipant
Average
I don’t see that as relevant at all. Risk and therefore should be based on the bank size and not on pip size. My bench for testing is £10k bank size and my base risk is 1% of the bank.
The 1% is a constant.
Pip size is not
I don’t see that as relevant at all. Risk and therefore should be based on the bank size and not on pip size. My bench for testing is £10k bank size and my base risk is 1% of the bank. The 1% is a constant.
Yes, but for backtesting and for the comparability its allays better to use 1 pip/point. I can immediately see how many points the setup is generating, and don´t have to convert. Its more usefull for all viewers
I meant something else. You invest 10 € and with a 50% hit rate you get 11 € … so one euro profit per trade. that’s not much when you consider that this is a back test and the slippage is on top of that.
smpParticipant
Average
That’s not what the back says. Plus your hypothesis is flawed, sorry. It’s all-around risk management and ROI.
The correct backtesting identifies over a 69% hit rate with a return of over 1:1.7
If I gave someone £1 and they gave me back £2.7 I would take that all day (don’t forget the £1 you risk you don’t spend
The strategy is from someone else, it did not work and so I wrote a programme to deliver one that would work and based on the loose requirement – let’s not forget this.
Personally, my BOTs deliver… worst case 20% *12 trades per year (88% win rate) to high frequently BOTs delivering 45% per year. Mixing these bots (over 12 active BOTs these do very nicely)
This early bird bot potentially trades 144 per year (roughly) with a potential outturn of 80%+ On a £10k account that’s £8k or £55 per trade! No matter what you are doing
Can you trade manually, and consistently with these ratios, most cannot!
smpParticipant
Average
VinzentVega 2 minutes does look good 👍🏻
I never looked at that time frame
smpParticipant
Average
2 mins, interesting. Can you post your code as MTF does not support 2 mins
It would be interesting to see what you have done?
2 mins, interesting. Can you post your code as MTF does not support 2 mins
It would be interesting to see what you have done?
Pls find attached the file.
smpParticipant
Average
Thanks for the file. The strategy actually loses money!
Also, it’s a completely different strategy! The strategy is a break put of 8:00, not 9 am! We are discussing the 8:00 breakout using the 7am to 8am timeframe, and not the 8am to 9am as you have! I thought something was wrong.! Thanks for sharing anyway.
I wrote a 9am breakout also like yours and has 100% trading record at 5 trades per 3-month cycle, happy to stick with this
Thanks for sharing though
EricParticipant
Master
For those that are not afraid of slippage, take a look at Hang Seng at the open
Did some breakouts testing on that beast, but gave it up
Too brutal for me