Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 72
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
If you compare it to the balance, that's how it is:
Thank you.
OK, then as I understand it, we get three different custom functions with the return of the right one (if we look for three different parameters)
ArraySort
then
ArrayBsearch by the right number
and then how to deal with it?
Exactly the transition from an array to a structure elementYou don't understand.
You need to make a single function that will populate and sort the array declared globally. The array will need to be passed to the function by reference.
And you need additional functions that will take out the data you need from this array.
You don't understand.
You need to make a single function that fills and sorts the array declared globally. The array will need to be passed to the function by reference.
And you need additional functions that will take the data you need from this array.
ok, can you demonstrate how to take something out of an array of structures? let's say it's full and sorted
how to transfer by reference and write
Please advise how the condition should look like. If a stop loss is triggered, then the lot is multiplied by 2, and if the next order triggers a take profit, the lot would return to the original lot, which was before the stop loss.
I understand it like this, but I don't know how to go on...
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
{
if (OrderMagicNumber()==magic)
{
if (OrderStopLoss()==OrderClosePrice())
{
lot=lot*4;
}
}
}
}
another question, what did I write wrong in the block on deleting orders? it does not always delete orders, in the log it says
market order #1 cannot be deleted
{
for(int n=OrdersTotal()-1;n>=0;n--)
{
if(OrderSelect(n,SELECT_BY_POS))
{
if(OrderMagicNumber()==magic)
{
bool del=OrderDelete(OrderTicket());
if (del==true)
{
otl_b=0; otl_s=0; //обнуляем переменные отложек
}
}
}
}
}
Another question, what did I write wrong in the block to delete orders? It doesn't always delete orders, in the log it says
market order #1 cannot be deleted
{
for(int n=OrdersTotal()-1;n>=0;n--)
{
if(OrderSelect(n,SELECT_BY_POS))
{
if(OrderMagicNumber()==magic)
{
bool del=OrderDelete(OrderTicket());
if (del==true)
{
otl_b=0; otl_s=0; //обнуляем переменные отложек
}
}
}
}
}
You are trying to delete a market order, they are not deleted, they are closed using the OrderClose() function. For the loop to delete or close correctly, we have to distinguish the order by its type.
if(OrderType()<=OP_SELL) - for market orders, if(OrderType()>OP_SELL) - for pending orders.
There's a thing calledCHARTEVENT_MOUSE_MOVE
Question: does this work on mobile devices where there is no mouse?
Please advise how the condition should look like. If a stop loss is triggered, then the lot is multiplied by 2, and if the next order triggers a take profit, the lot would return to the original lot, which was before the stop loss.
I understand it like this, but I don't know how to go on...
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
{
if (OrderMagicNumber()==magic)
{
if (OrderStopLoss()==OrderClosePrice())
{
lot=lot*4;
}
}
}
}
Please advise how the condition should look like. If a stop loss is triggered, then the lot is multiplied by 2, and if the next order triggers a take profit, the lot would return to the original lot, which was before the stop loss.
I understand it like this, but I don't know how to go on...
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
{
if (OrderMagicNumber()==magic)
{
if (OrderStopLoss()==OrderClosePrice())
{
lot=lot*4;
}
}
}
}
The solution to this problem depends on the Expert Advisor's full logic, you can trace the triggering of stoploss or takeprofit by its comment.
if(StringFind(OrderComment(),"tp")>=0)// сработал тейкпрофит
...
You don't understand.
You need to make a single function that fills and sorts the array declared at global level. The array will need to be passed to the function by reference.
And you need additional functions that will take out the data you need from this array.