how to make an expert advisor - page 2

 
juni1122 #:
i got the code for long and short,and it is totally working as i expected it to be, now i will start working on combining it and then adding risk management in it, i will kepp you all posted about my work
The strategy you were writing about is really nothing spevial tbh. But nice to hear that it worked.
 

the best strategies are always the simplest. i use two to three strategies and they are the simplest. 
1- i enter short at upper envelope and long at lower envelope. i tune the envelope for each pair separately, there is one percentage of envelope from where the price rejects or takes supports 70% of the time.

2-my second strategy is even simpler,i wait for a daily crossover of 5 and 8 ema and then i wait for retracement to 8 ema daily. and take enty in the direction of cross over.

3- i simply draw a trendline on 4hr TF and enter on its third testing.


All of these may sound very simple and naive, but they work for 70% of the time. but now i am facing the problem of missing the trades when i am away, and i miss most of the trades because i was not watching. So now i want to make an EA which covers all these three strategies, my first one is the one with the envelope. i believeits not about the strategy but about the risk management.

 
Conor Mcnamara #:

No thanks, people have already made these EAs centuries ago! 

i want to ask one last thing, that if trading is all about setups and following the rules and not involving emotions, then why does everyone do manual trading why does not everyone makes an algorithm of his setup?
 
juni1122 #:
i want to ask one last thing, that if trading is all about setups and following the rules and not involving emotions, then why does everyone do manual trading why does not everyone makes an algorithm of his setup?
I'll tell you exactly why. Having an automated trading algorithm which capitalizes on market opportunities is one thing, but remember that the automated trading system also needs to employ risk management.
If the bot is not programmed to use professional money management mechanisms, then unfortunately it will fail eventually, and backtesting will reveal this. 
Programming a bot to trade when certain conditions are met is easy.
Programming a bot to trade like a professional trader which uses professional risk management is not an easy task.


Some common caveats:

1. Market volatility changed, the SL is too narrow and it is about to get hit, bot doesn't know that it needs to be adjusted. 

2. The broker spread increased, bot made a weak trade, and is now losing money.

3. False signals from the setup causing consecutive losses.

4. The bot makes one risky trade in a bad place, the SL isn't hit, but it's struggling to reach the TP. It takes 2 days to find the TP when it could have made 5 good trades instead.

 

my risk management is also defined, i take 0.01 lots for every 500$ in gold. my tp is 100 pips close half,and full close if its only 0.01 and sl is also 100 pips. remaining half is closed when other side signal,or breakeven sl.i have kept it very simple. the coding the setup part is easy,but coding the risk management is very tough



Conor Mcnamara #:
I'll tell you exactly why. Having an automated trading algorithm which capitalizes on market opportunities is one thing, but remember that the automated trading system also needs to employ risk management.
If the bot is not programmed to use professional money management mechanisms, then unfortunately it will fail eventually, and backtesting will reveal this. 
Programming a bot to trade when certain conditions are met is easy.
Programming a bot to trade like a professional trader which uses professional risk management is not an easy task.


Some common caveats:

1. Market volatility changed, the SL is too narrow and it is about to get hit, bot doesn't know that it needs to be adjusted. 

2. The broker spread increased, bot made a weak trade, and is now losing money.

3. False signals from the setup causing consecutive losses.

4. The bot makes one risky trade in a bad place, the SL isn't hit, but it's struggling to reach the TP. It takes 2 days to find the TP when it could have made 5 good trades instead.

 
It's tough but it's possible, and you'll get there. Small suggestion would be to use smaller stops like 100 pips with a trailing stop mechanism or ATR based stop loss. Otherwise it's better to use 250 - 300 pips SL (in my personal opinion)
 
can i share code here?
 
juni1122 #:
can i share code here?

You can submit your codes here if you wish:

https://www.mql5.com/en/code/my

 
i have completed my EA, attached are the back testing results for 2023 and 2024, can anyone guide me on how to proceed further,if i want to sell it or put it on monthly subscription.how can i upload it to mql5 or how can i share
Reason: