Guys, this is a question for which I have not found an answer anywhere. What function to write in the indicator so that new bars do not open and ticking in the zero bar, until it works my condition, please answer me in private))
I set numbers extern int a =2; extern int b =3; extern int c =4; how do I now set the number abcto change its value when changing a, or b, or c to compare it to some given d (e.g.d=344)?
I set numbers extern int a =2; extern int b =3; extern int c =4; how do I now set the number abcto change its value when changing a, or b, or c to compare it to some given d (e.g.d=344)?
Hello, 2020.10.03_13:33 GMT+3. I took the standard Moving Average EA for MetaTrader 4. And started changing it so that it became profitable. When trying to describe the closing conditions using the OrderProfit() function in the strategy tester, the Expert Advisor stopped closing trades at that condition. It does not go as far as closing a trade. However, I doubt that I have written closing conditions correctly. The Expert Advisor would close trades otherwise. I will probably try to write the deal opening price and the last prices. Once the maximum difference between the opening price and the last price is reached and this difference is reduced -- close the trade. I am attaching the Expert Advisor file. 13:50 GMT+3.
Николай Никитюк: Hello, 2020.10.03_13:33 GMT+3. I took the standard Moving Average EA for MetaTrader 4. And started changing it so that it became profitable. When trying to describe the closing conditions using the OrderProfit() function in the strategy tester, the Expert Advisor stopped closing trades at that condition. It does not go as far as closing a trade. However, I doubt that I have written closing conditions correctly. The Expert Advisor would close trades otherwise. I will probably try to write the deal opening price and the last prices. Once the maximum difference between the opening price and the last price is reached and this difference is reduced -- close the trade. I am attaching the Expert Advisor file. 13:50 GMT+3.
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//--- check order type// if(OrderType()==OP_BUY)
{
/*
if(OrderProfit()>0.0)
{ProfitMax=OrderProfit(); break;} // Здесь у вас прерывается цикл, если сделка в плюсе
if(OrderProfit()>ProfitMax)
{ProfitMax=OrderProfit(); break;}
if((ProfitMax-DiffProfit)<0.0) break;
if((ProfitMax-DiffProfit)>OrderProfit())
*/if(DiffProfit<OrderProfit()) // Исходя из ваших условий, то вот
{
if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
Print("OrderClose error ",GetLastError());
}
elsebreak;
break;
}
if(OrderType()==OP_SELL)
{
/*
if(OrderProfit()>0.0)
{ProfitMax=OrderProfit(); break;} // Здесь у вас прерывается цикл, если сделка в плюсе
if(OrderProfit()>ProfitMax)
{ProfitMax=OrderProfit(); break;}
if((ProfitMax-DiffProfit)<0.0) break;
if((ProfitMax-DiffProfit)>OrderProfit())
*/if(DiffProfit<OrderProfit()) // Исходя из ваших условий, то вот
{
if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
Print("OrderClose error ",GetLastError());
}
elsebreak;
break;
}
}
//+------------------------------------------------------------------+
I've started to write a function to normalise the input data. But I can't "replace" the original values with the normalized ones. I.e. I cannot update values in Open timeseries buffer with new values from Temp array. What is my error? I have a feeling that I'm trying to cross OOP and non-OOP)).
Open=new CiOpen();
if(CheckPointer(Open)==POINTER_INVALID || !Open.Create(Symb.Name(),PERIOD_CURRENT))
return;
//---int bars=10;
double Temp[]; //Создаем массив для временного хранения входных данныхArraySetAsSeries(Temp,true); //Устанавливает флаг AS_SERIES
Open.GetData(0,bars,Temp); //Копируем необходимые данные в массив Temp
InputNormalize(Temp,bars); //Нормализуем данные в массиве
//---Как заменить значения в Open значениями из Temp?---
}
//+------------------------------------------------------------------+//| функция нормализации входных данных |//+------------------------------------------------------------------+void InputNormalize(double &buffer[],int bars)
{
double d1=-1;
double d2=1;
double x_min=buffer[ArrayMinimum(buffer,0,bars)];
double x_max=buffer[ArrayMaximum(buffer,0,bars)];
for(int i=0; i<bars; i++)
{
buffer[i]=(((buffer[i]-x_min)*(d2-d1))/(x_max-x_min))+d1;
}
return;
}
I'm sure it can be done in a simpler way! In this case please teach me)
I've started to write a function to normalise the input data. But I can't "replace" the original values with the normalized ones. I.e. I cannot update values in Open timeseries buffer with new values from Temp array. What is my error? I have a feeling that I'm trying to cross OOP and non-OOP)).
I'm sure it can be done in a simpler way! In this case please teach me)
Read the language documentation
The value of predefined variables is set by the client terminal before starting an mql4-program for execution. Predefined variables are constant and cannot be changed from the mql4-program.
Для каждой выполняющейся mql4-программы поддерживается ряд предопределенных переменных, которые отражают состояние текущего ценового графика на момент запуска программы - эксперта, скрипта или пользовательского индикатора. Значение предопределенным переменным устанавливает клиентский терминал перед запуском mql4-программы на выполнение...
Alexey, thank you! It's clear now that it's not possible.
It's true, I'm not exactly mql4. I'm trying to change data through the CiOpen class. I'm confused by the Update method, which should change the element at a specified position of the array.
Alexei, thank you! It's clear now that it's not possible.
It's true, I don't have exactly mql4. I'm trying to change data through the CiOpen class. I'm confused by the Update method, which should change the element at a specified position of the array.
Since the question is posed in the mql4 section, I answered regarding mql4. There are no hints to mql5 in your question. But the result is the same.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello!
I am confused in three pines:
I set numbers extern int a =2; extern int b =3; extern int c =4; how do I now set the number abcto change its value when changing a, or b, or c to compare it to some given d (e.g.d=344)?
Thank you!
Hello!
I am confused in three pines:
I set numbers extern int a =2; extern int b =3; extern int c =4; how do I now set the number abcto change its value when changing a, or b, or c to compare it to some given d (e.g.d=344)?
Thank you!
x = c + b*10 + a*100
x = c + b*10 + a*100
Oh, my God! I'm racking my brains! Thank you!
Hello, 2020.10.03_13:33 GMT+3. I took the standard Moving Average EA for MetaTrader 4. And started changing it so that it became profitable. When trying to describe the closing conditions using the OrderProfit() function in the strategy tester, the Expert Advisor stopped closing trades at that condition. It does not go as far as closing a trade. However, I doubt that I have written closing conditions correctly. The Expert Advisor would close trades otherwise. I will probably try to write the deal opening price and the last prices. Once the maximum difference between the opening price and the last price is reached and this difference is reduced -- close the trade. I am attaching the Expert Advisor file. 13:50 GMT+3.
Hello!
I've started to write a function to normalise the input data. But I can't "replace" the original values with the normalized ones. I.e. I cannot update values in Open timeseries buffer with new values from Temp array. What is my error? I have a feeling that I'm trying to cross OOP and non-OOP)).
I'm sure it can be done in a simpler way! In this case please teach me)
Hello!
I've started to write a function to normalise the input data. But I can't "replace" the original values with the normalized ones. I.e. I cannot update values in Open timeseries buffer with new values from Temp array. What is my error? I have a feeling that I'm trying to cross OOP and non-OOP)).
I'm sure it can be done in a simpler way! In this case please teach me)
Read the language documentation
Read the language documentation
Alexey, thank you! It's clear now that it's not possible.
It's true, I'm not exactly mql4. I'm trying to change data through the CiOpen class. I'm confused by the Update method, which should change the element at a specified position of the array.
Alexei, thank you! It's clear now that it's not possible.
It's true, I don't have exactly mql4. I'm trying to change data through the CiOpen class. I'm confused by the Update method, which should change the element at a specified position of the array.
Since the question is posed in the mql4 section, I answered regarding mql4. There are no hints to mql5 in your question. But the result is the same.