Hello forum, good day.
I'm an MQL5 newbie and I have started with the Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners tutorial, but when I run the code I get a message about Invalid stops and an error 4756. I started to modify it but still continue to get the same errors. Could someone with more experience in MQL5 point me in the right direction or help me with a couple freelance classes/jobs in order to complete this EA please? Help will be much appreciated.
What I'm trying to do in my first EA is:
1. Check ADX indicator values when a new bar is created (right at 00:00 hours).
2. If +DI > -DI it should be Buy position, else, if +DI < -DI should be a Sell position.
3. Once determined if it is a Buy or Sell position:
3.1. If it is a Buy position and the previous bar is black (Bear), the order should be placed as a pending order (Buy Stop) with the Opening price of the previous bar; Stop Loss should be placed at the Lowest price from previous bar - 0.1 cents. If the previous bar is not black, then the order shuld not be placed.
3.2. If it is a Sell position and the previous bar is white (Bull), the order should be placed as a pending order (Sell Stop) with the Opening price of the previous bar; Stop Loss should be placed at the Highest price from previous bar + 0.1 cents. If the previous bar is not white, then the order will not be placed.
4. Stop Loss should be moved every day.
5. When the latest price of the product (ask/buy, or bid/sell) reaches Stop Loss, the position is closed.
For now I'm trying to do this with a Market order, but I need to do it with a Pending order. Here is the code I'm using:
Regards and thank you in advance,
codeMolecules
Hello forum, good day.
I'm an MQL5 newbie and I have started with the Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners tutorial, but when I run the code I get a message about Invalid stops and an error 4756. I started to modify it but still continue to get the same errors. Could someone with more experience in MQL5 point me in the right direction or help me with a couple freelance classes/jobs in order to complete this EA please? Help will be much appreciated.
What I'm trying to do in my first EA is:
1. Check ADX indicator values when a new bar is created (right at 00:00 hours).
2. If +DI > -DI it should be Buy position, else, if +DI < -DI should be a Sell position.
3. Once determined if it is a Buy or Sell position:
3.1. If it is a Buy position and the previous bar is black (Bear), the order should be placed as a pending order (Buy Stop) with the Opening price of the previous bar; Stop Loss should be placed at the Lowest price from previous bar - 0.1 cents. If the previous bar is not black, then the order shuld not be placed.
3.2. If it is a Sell position and the previous bar is white (Bull), the order should be placed as a pending order (Sell Stop) with the Opening price of the previous bar; Stop Loss should be placed at the Highest price from previous bar + 0.1 cents. If the previous bar is not white, then the order will not be placed.
4. Stop Loss should be moved every day.
5. When the latest price of the product (ask/buy, or bid/sell) reaches Stop Loss, the position is closed.
For now I'm trying to do this with a Market order, but I need to do it with a Pending order. Here is the code I'm using:
Regards and thank you in advance,
codeMolecules

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello forum, good day.
I'm an MQL5 newbie and I have started with the Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners tutorial, but when I run the code I get a message about Invalid stops and an error 4756. I started to modify it but still continue to get the same errors. Could someone with more experience in MQL5 point me in the right direction or help me with a couple freelance classes/jobs in order to complete this EA please? Help will be much appreciated.
What I'm trying to do in my first EA is:
1. Check ADX indicator values when a new bar is created (right at 00:00 hours).
2. If +DI > -DI it should be Buy position, else, if +DI < -DI should be a Sell position.
3. Once determined if it is a Buy or Sell position:
3.1. If it is a Buy position and the previous bar is black (Bear), the order should be placed as a pending order (Buy Stop) with the Opening price of the previous bar; Stop Loss should be placed at the Lowest price from previous bar - 0.1 cents. If the previous bar is not black, then the order shuld not be placed.
3.2. If it is a Sell position and the previous bar is white (Bull), the order should be placed as a pending order (Sell Stop) with the Opening price of the previous bar; Stop Loss should be placed at the Highest price from previous bar + 0.1 cents. If the previous bar is not white, then the order will not be placed.
4. Stop Loss should be moved every day.
5. When the latest price of the product (ask/buy, or bid/sell) reaches Stop Loss, the position is closed.
For now I'm trying to do this with a Market order, but I need to do it with a Pending order. Here is the code I'm using:
Regards and thank you in advance,
codeMolecules