Execution of the first one outputs an empty string:
int start()
{
Comment(SymbolOK());
return(0);
}
But the second function outputs a string ID "EURUSD" (well, depends on the chart, but outputs, although according to the logic of the function it should be an empty string):
int start()
{
Comment(SymbolPROBLEM());
return(0);
}
You do not have an order selected in the Trade () function.
By the way. What is the point of selecting an order in the Trade() function? I am calling the functionOrdersModifying() where the order is selected and it is modified there. I.e., the initial variant was correct!
History, History_Draw - they work like Expert Advisors during testing.
You need something like this to watch corrections in history by given parameters
In the history or on the chart? If yes, then what kind of data do you want to see in the chart window, in a separate window, printed as a table, in the form of different coloured candles, or as a line connecting the start and end of the movement?
OrderSelect(g_ticket,SELECT_BY_TICKET) before the line if(OrderStopLoss() == 0 || OrderTakeProfit() == 0)
That's what I did:
bool Trade (int signal)
{
int total = OrdersTotal() - 1;
FindOrders();
if(signal == SIGNAL_BUY) // Если сигнал на покупку и открытых ордеров нет..if(!OpenBuy()) // открываем лимитный ордер на покупкуreturn(false);
if(signal == SIGNAL_SELL) // Если сигнал на продажу и открытых ордеров нет..if(!OpenSell())
return(false); // открываем лимитный ордер на продажуif(OrderSelect(g_ticket,SELECT_BY_TICKET,MODE_TRADES) == true)
{
if(OrderStopLoss() == 0 || OrderTakeProfit() == 0)
OrdersModifying(); // Модифицируем ордер, добавим SL и TP
}
// if(UseBU == true)// MovingStopLossToBU(); // Перевод в б.у. по достижению некоторого значения TPreturn(true);
}
There are no stops and takeovers. The log says error 130, saying the stops are wrong. I do not see the reason.
Execution of the first one outputs an empty string:
But the second function outputs a string ID "EURUSD" (well, depends on the chart, but outputs, although according to the logic of the function it should be an empty string):
Help me understand what is wrong? Thank you
You cannot use reserved names(value) when declaring your variables, call _value
Vitaly, I did as you said, but nothing has changed. Apparently the bug is buried somewhere else.
Before I had everything (opening orders - modification and transfer to b.w. when the set price level is reached) and everything worked. It was like this:
bool Trade (int signal)
{
FindOrders();
double sl = 0, tp = 0;
if(signal == SIGNAL_BUY) // Если сигнал на покупку и открытых ордеров нет...if(!OpenBuy()) // открываем лимитный ордер на покупкуreturn(false);
if(signal == SIGNAL_SELL) // Если сигнал на продажу и открытых ордеров нет..if(!OpenSell()) // Открываем лимитный ордер на продажуreturn(false);
int total = OrdersTotal() - 1;
for(int i=total; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true) // Если ордер есть и он выбран..
{
if(g_type == OP_BUY)
{
if(i_sl != 0) // Если входной параметр стоп-лосса не равен 0, то..
sl = NormalizeDouble(OrderOpenPrice() - i_sl*pt,Digits); // Получаем значение стоп-лосса для выбранного ордераif(i_tp != 0) // Если входной параметр тейкпрофита не равен 0, то..
tp = NormalizeDouble(OrderOpenPrice() + i_tp*pt,Digits); // Получаем значение тейкпрофита для выбранного ордера
}
if(g_type == OP_SELL)
{
if(i_sl != 0) // Если входной параметр стоп-лосса не равен 0, то..
sl = NormalizeDouble(OrderOpenPrice() + i_sl*pt,Digits); // Получаем значение стоп-лосса для выбранного ордераif(i_tp != 0) // Если входной параметр тейкпрофита не равен 0, то..
tp = NormalizeDouble(OrderOpenPrice() - i_tp*pt,Digits); // Получаем значение тейкпрофита для выбранного ордера
}
if(sl != 0 || tp != 0) // Если полученные значения sl и tp не равныы 0, то..
{
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,OrderOpenTime() + 86400,Lime); // Модифицируем ордер
}
}
}
return(true);
}
Now, as I've broken everything down into specific specialised functions, it's all stopped working soooo much. I've tried it both ways, nothing works. no stops are set.
double sl = 0, tp = 0; // тут присвоили по нулямfor(int i=total; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true) // Если ордер есть и он выбран..
{
if(g_type == OP_BUY)
{
if(i_sl != 0) // замените на if(sl == 0) // Если входной параметр стоп-лосса не равен 0, то..
sl = NormalizeDouble(OrderOpenPrice() - SL*pt,Digits); // Если по нулям, тогда выполнится условие!
Where's the logic in that? I'd like to understand... Here is the function:
void OrdersModifying()
{
int total = OrdersTotal() - 1;
double sl = 0, tp = 0;
for(int i=total; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true) // Если ордер есть и он выбран..
{
if(g_type == OP_BUY)
{
if(i_sl != 0) // Если входной параметр стоп-лосса не равен 0, то..
sl = NormalizeDouble(OrderOpenPrice() - i_sl*pt,Digits); // Получаем значение стоп-лосса для выбранного ордераif(i_tp != 0) // Если входной параметр тейкпрофита не равен 0, то..
tp = NormalizeDouble(OrderOpenPrice() + i_tp*pt,Digits); // Получаем значение тейкпрофита для выбранного ордера
}
if(g_type == OP_SELL)
{
if(i_sl != 0) // Если входной параметр стоп-лосса не равен 0, то..
sl = NormalizeDouble(OrderOpenPrice() + i_sl*pt,Digits); // Получаем значение стоп-лосса для выбранного ордераif(i_tp != 0) // Если входной параметр тейкпрофита не равен 0, то..
tp = NormalizeDouble(OrderOpenPrice() - i_tp*pt,Digits); // Получаем значение тейкпрофита для выбранного ордера
}
if(sl != 0 || tp != 0) // Если полученные значения sl и tp не равныы 0, то..
{
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,OrderOpenTime() + 86400,Lime); // Модифицируем ордер
}
}
}
}
If the input variables i_sl and i_tp are not equal to zero, we get the stop and take prices that will already be in the order - sl andtp. After that I will check if we have calculatedsl andtp here (if for shorts):
if(i_sl != 0) // Если входной параметр стоп-лосса не равен 0, то..
sl = NormalizeDouble(OrderOpenPrice() + i_sl*pt,Digits); // Получаем значение стоп-лосса для выбранного ордераif(i_tp != 0) // Если входной параметр тейкпрофита не равен 0, то..
tp = NormalizeDouble(OrderOpenPrice() - i_tp*pt,Digits); // Получаем значение тейкпрофита для выбранного ордера
}
If the values are obtained, then they cannot be zero... because they will be changed! These are variables that we get sequentially by code context.
And here, I checked if we found the values of stop and take. How can they be zero after all the conditions?
if(sl != 0 || tp != 0) // Если полученные значения sl и tp не равныы 0, то..
{
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,OrderOpenTime() + 86400,Lime); // Модифицируем ордер
}
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.
Problem with Symbol() MT4:
2 functions to illustrate:
Execution of the first one outputs an empty string:
But the second function outputs a string ID "EURUSD" (well, depends on the chart, but outputs, although according to the logic of the function it should be an empty string):
Help me understand what is wrong? Thank you
You do not have an order selected in the Trade () function.
By the way. What is the point of selecting an order in the Trade() function? I am calling the function OrdersModifying() where the order is selected and it is modified there. I.e., the initial variant was correct!
There is such a thing. Here's the fix.
And the modification function is here:
Strange But there are no stops and takes on the output again.
OrderSelect(g_ticket,SELECT_BY_TICKET) before the line if(OrderStopLoss() == 0 || OrderTakeProfit() == 0)
History, History_Draw - they work like Expert Advisors during testing.
You need something like this to watch corrections in history by given parameters
In the history or on the chart? If yes, then what kind of data do you want to see in the chart window, in a separate window, printed as a table, in the form of different coloured candles, or as a line connecting the start and end of the movement?
OrderSelect(g_ticket,SELECT_BY_TICKET) before the line if(OrderStopLoss() == 0 || OrderTakeProfit() == 0)
That's what I did:
There are no stops and takeovers. The log says error 130, saying the stops are wrong. I do not see the reason.
That's what I did:
There are no stops and takeovers. The log says error 130, saying that the stops are wrong. I don't see the reason.
Without ifs, justOrderSelect(g_ticket,SELECT_BY_TICKET,MODE_TRADES);, and you can leave it in OrdersModifying()
//+------------------------------------------------------------------+
void OrdersModifying()
{
OrderSelect(g_ticket,SELECT_BY_TICKET,MODE_TRADES);
if(g_type == OP_BUY)
{
if(i_sl != 0)sl = NormalizeDouble(OrderOpenPrice() - i_sl*pt,Digits); // If the stop loss input parameter is not 0
// Get the value of Stop Loss for the selected order
if(i_tp != 0)tp = NormalizeDouble(OrderOpenPrice() + i_tp*pt,Digits); // If the TakeProfit input parameter is not equal to 0, then...
// obtain the TakeProfit value for the selected order
}
if(g_type == OP_SELL)
{
if(i_sl != 0)sl = NormalizeDouble(OrderOpenPrice() + i_sl*pt,Digits); // If the input parameter of the stop loss is not 0
// Get the value of Stop Loss for the selected order
if(i_tp != 0)tp = NormalizeDouble(OrderOpenPrice() - i_tp*pt,Digits); // If the TakeProfit input parameter is not equal to 0, then...
// obtain the TakeProfit value for the selected order
}
if(sl != 0 || tp != 0) // If the obtained values of sl and tp are not equal to 0, then..
{
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,OrderOpenTime() + 86400,Lime); // Modify order
}
}
Problem with Symbol() MT4:
2 functions to illustrate:
Execution of the first one outputs an empty string:
But the second function outputs a string ID "EURUSD" (well, depends on the chart, but outputs, although according to the logic of the function it should be an empty string):
Help me understand what is wrong? Thank you
You cannot use reserved names(value) when declaring your variables, call _value
That's what I did:
There are no stops and takeovers. The log says error 130, saying that the stops are wrong. I don't see the reason.
And they won't!
Vitaly, I did as you said, but nothing has changed. Apparently the bug is buried somewhere else.
Before I had everything (opening orders - modification and transfer to b.w. when the set price level is reached) and everything worked. It was like this:
Now, as I've broken everything down into specific specialised functions, it's all stopped working soooo much. I've tried it both ways, nothing works. no stops are set.
And they won't!
Where's the logic in that? I'd like to understand... Here is the function:
If the input variables i_sl and i_tp are not equal to zero, we get the stop and take prices that will already be in the order - sl andtp. After that I will check if we have calculatedsl andtp here (if for shorts):
If the values are obtained, then they cannot be zero... because they will be changed! These are variables that we get sequentially by code context.
And here, I checked if we found the values of stop and take. How can they be zero after all the conditions?