Hello, can you help me write this EA for MT5?

 

Hello, can you help me write this EA for MT5?

  • If the previous candle is a BUY candle, then open a BUY.

  • If the previous candle is a SELL candle, then open a SELL.

  • If there is an existing position that matches the logic => keep it, do not open a new one.

  • If there is no position that matches the logic => close the old position and open a new one.

  • Stop Loss: 100 pips.

 
Bích Ngọc:

Hello, can you help me write this EA for MT5?


Seach the codebase. There are many sites that welcome requests, however they are almost ignored on this forum. If you make an honest try, then, you will get advice on how to fix your issues as you come accross them.

I recommend that you search codebase, where you can learn how to code yourself, and you may even find exactly what you want -- already coded by an expert.

 
Michael Charles Schefe #:

Seach the codebase. There are many sites that welcome requests, however they are almost ignored on this forum. If you make an honest try, then, you will get advice on how to fix your issues as you come accross them.

I recommend that you search codebase, where you can learn how to code yourself, and you may even find exactly what you want -- already coded by an expert.

Thank you so much but where is the codebase? 😔
 
Bích Ngọc #:
Thank you so much but where is the codebase? 😔

on the desktop website, here --


 

Since that's not a complex request, it might be coded 

but if it is because you're interested to learn, I would suggest finding an article that discusses CTrade (the library which abstracts a lot of things)

https://www.mql5.com/en/articles/15299

Introduction to MQL5 (Part 8): Beginner's Guide to Building Expert Advisors (II)
Introduction to MQL5 (Part 8): Beginner's Guide to Building Expert Advisors (II)
  • 2024.07.18
  • www.mql5.com
This article addresses common beginner questions from MQL5 forums and demonstrates practical solutions. Learn to perform essential tasks like buying and selling, obtaining candlestick prices, and managing automated trading aspects such as trade limits, trading periods, and profit/loss thresholds. Get step-by-step guidance to enhance your understanding and implementation of these concepts in MQL5.
 

Hi

It’s quite simple EA so it can be done easily. But if you don’t know how to code you can always find some freelancer who code it for you (this way it can be better coded with some extra functions for tests and check-up conditions).
But you can also try to code it yourself, you can also post here your results, and we can help you if you would have some problems with your code. You can try this at first and develop other functions later:

int signal = getOpenSignal(); //check if last candle is sell or buy
         if(signal>0){
                 if(countSells()>0) closeSell();
            if(countBuys()==0) openBuy();
         }
         
         if(signal<0){
                 if(countBuys()>0) closeBuy();
            if(countSell()==0) openSell();
         }

Best Regards