Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
- 2022.08.16
- www.mql5.com
MQL5: язык торговых стратегий для MetaTrader 5, позволяет писать собственные торговые роботы, технические индикаторы, скрипты и библиотеки функций
Learn to code.
//+------------------------------------------------------------------+ //| BreakevenEA.mq4 | //| Igor Muratov | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Igor Muratov" #property link "https://www.mql5.com" #property version "1.00" #property strict #property description "TEST ON DEMO THEN ON REAL ACCOUNT TO OBTAIN ASCENDING PROFIT CURVE. LET'S SMASH THE MARKET." #define MAGICMA 22813379 extern double BreakEvenProfit = 25; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- Comment(StringFormat("Equity is %f", AccountEquity())); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- for(int i=0; i<=OrdersTotal()-1; i++) { if(!OrderSelect(i, SELECT_BY_POS)) { continue; } // EA HASN'T BEEN MADE YET. JUST SENDING YOU THE PART OF THE CODE WHICH HAS 11 ERRORS. RefreshRates(); } } //+------------------------------------------------------------------+
Just reading the book and decided to practice. I copied the code from here. So is it not true?
Files:
Screenshot_4.png
15 kb
IgorFX Trading #:
Just reading the book and decided to practice. I copied the code from here. So is it not true?
Your code differes from the one in the book, at least related to the first post.
Checking the result of your "OrderSelect" statement should be done. - This way you continue to check all orders by position, even if a call fails.
Also, you should change the for-loop as follows, as the amount of open orders could shrink while processing.
for(int cnt = OrdersTotal() - 1; (cnt >= 0) && !_StopFlag; cnt--) { if(!OrderSelect(cnt, SELECT_BY_POS)) { continue; } // EA HASN'T BEEN MADE YET. JUST SENDING YOU THE PART OF THE CODE WHICH HAS 11 ERRORS. RefreshRates(); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register