Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 96
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hello!
Please help me write an EA.
The essence of the Expert Advisor: opens 4 orders of 1 lot.
2 to sell: usdchf; eurusd;
2 to buy: gbpusd; usdjpy;
Upon reaching a total profit of 5 pips, close all trades. And start again.
4 lots in total?
What if there is no profit?
Hello!
Please help me write an EA.
The essence of the Expert Advisor: opens 4 orders of 1 lot.
2 to sell: usdchf; eurusd;
2 to buy: gbpusd; usdjpy;
Upon reaching a total profit of 5 pips, close all trades. And start all over again.
There is no need to duplicate your question in different threads.
Please contact Freelance.
Greetings.
Can you tell me how to write the condition so that the action will be performed at the opening of a new candle on the current chart?
Hello! Help me understand arrays!
I need to fill an array with the MASD indicator. As I understand it, there is data: bar index,MODE_MAIN value,MODE_SIGNALvalue, i.e. the array should be of three-dimensional type ( a [] [] []), or what? If you can give an example.
https://www.mql5.com/ru/articles/159
Sergey, have you ever used this code yourself?
The article is generally good, but it's
very dangerous. To make it work, you have to, as recommended by the drummer, "jerk" the history periodically. I did not specify what place.
In general, after much suffering, I've come to the conclusion that it's better to use CopyRates() function
Messages about possible errors are filled in by each of us if we want to.
{
static datetime timeLastBar;
MqlRates mqlRates[];
int s = 0;
do
{
s++;
}
while(CopyRates(_Symbol, PERIOD_CURRENT, 0, 1, mqlRates) < 0 && s < 7);
bool ret = timeLastBar != mqlRates[0].time;
if(ret)
timeLastBar = mqlRates[0].time;
return(ret);
}/*******************************************************************/
Sergey, have you ever used this code yourself?
The article is generally good, but it's
very dangerous. To make it work, you have to, as the drummer recommended, "jerk" the history periodically. Which place was not specified.
Alexey, tell me, when did you ran into errors using it? Have you ever had one?
I just use this method myself, and have not run into trouble. Well, maybe I still have to?
I would like some explanations - so to say... :)
Where did the drummer say that?
Alexei, tell me, when have you ever run into errors with this use? Have you ever?
Because I use this method myself, and have not yet run into any trouble. Well, maybe I still have to.
I would like some explanations - so to say... :)
Where did drubashka say such a thing?
https://www.mql5.com/ru/forum/89213
There's eight pages of bickering. And not only drubashka, but Slawa says that
Where do you see inadequate behavior of this function? Have you read the documentation carefully?
Returns information about state of historical data. Doesn't update the information, doesn't initiate data swapping. Just returns what is there at the moment.
Alexei, tell me, when have you ever run into errors with this use? Have you ever?
Because I use this method myself, and have not yet run into any trouble. Well, maybe I still have to.
I would like some explanations - so to say... :)
Where did the drummer say that?
And here's the twitching.
It didn't work on one symbol in one terminal (on M15 timeframe) - I'm 99% sure the problem is that using another timeframe I need to "jerk" the history all the time. I think it's better to do it through CopyTime().
Alexei, tell me, when have you ever run into errors with this use? Have you ever?
For example, in the MT5 terminal there are some Expert Advisors (MACD Sample and Moving Averages), but if I try to put a specific TF in their code, for example PERIOD_H4, instead of "_Period", then in the test on the open prices of higher TF, the following indicator loading error occurs: cannot load indicator 'MACD' [4805] and as a result: tester stopped because OnInit failed. What are your opinions? Maybe I'm doing something wrong? Is it possible to code the Expert Advisor so that it is tested for the open prices of any TF?
I have tried to use the indicator as a custom one, the error is the same.
Thank you in advance for your feedback.
int OnInit(void)
{
//--- prepare trade class to control positions if hedging mode is active
ExtHedging=((ENUM_ACCOUNT_MARGIN_MODE)AccountInfoInteger(ACCOUNT_MARGIN_MODE)==ACCOUNT_MARGIN_MODE_RETAIL_HEDGING);
ExtTrade.SetExpertMagicNumber(MA_MAGIC);
ExtTrade.SetMarginMode();
//--- Moving Average indicator
ExtHandle=iMA(_Symbol,PERIOD_H4,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE);
if(ExtHandle==INVALID_HANDLE)
{
printf("Error creating MA indicator");
return(INIT_FAILED);
}
//--- ok
return(INIT_SUCCEED);
}