Can you tell me how to pass one dimension from a two-dimensional array to a function?
I'm confused about something.
int testarray[5][2] = {1,2,3,4,5,6,7,8,9,10};// хоть так и можно записать, но в уме нужно держать что это ТАБЛИЦА
void testfunc(int &inarray[][]){ // массив нужно передавать "как есть", но обрабатывать можно выбранную часть string out_str="Result: "+inarray[i,0];
for (int i=1;i<5;i++){// еще нужно учитывать, что счет в массивах начинается с НУЛЯ. "первый - нулевой" out_str += (", "+inarray[i,0]); // здесь бы использовал строковую функцию конкатенации } Print(out_str); } //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- Print("Call first:"); testfunc(testarray); Print("Call second:"); testfunc(testarray); //---- return(0); } //+-----------
It's me again... Don't scold me too much... I have about two weeks of experience with EAs...
I have created my Expert Advisor based on fractals but it keeps showing OrderModify error 1 in my log during the test, although my moose is moving correctly based on fractals. I used Kim's FindNearFractal function. The code is as follows:
for( cnt=0; cnt< total; cnt++){OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES);if(OrderType()<=OP_SELL&&// check for opened positionOrderSymbol()==Symbol())// check for symbol{if(OrderType()==OP_BUY)// long position is opened{// check for trailing stopif( TrailFractal){OrderModify(OrderTicket(),OrderOpenPrice(), FindNearFractal(NULL,0,MODE_LOWER),0,0,Green);return(0);}}else// go to short position{// check for trailing stopif( TrailFractal){OrderModify(OrderTicket(),OrderOpenPrice(), FindNearFractal(NULL,0,MODE_UPPER),0,0,Red);return(0);}}}
And on additions another question. The code is as follows:
for(int i =0; i <OrdersTotal(); i++){// выбор ордераif(OrderSelect( i, SELECT_BY_POS)==false)continue;// not current symbolif(OrderSymbol()!=Symbol())continue;}if(OrderType()==OP_SELL){//при профите >20 pips добавится или докупится ...if(OrderProfit()>20)//////если поставить другое условие открывает много позицийOrderSend(Symbol(),OP_SELL, Lots,Bid,3, sl_sell,0,"Ma+Fr",16384,0,Red);
PeriodForSleep=((Time[0]-Time[1])-(TimeCurrent()-Time[0]))*1000;Sleep( PeriodForSleep);}if(OrderType()==OP_BUY){//при профите >20 pips добавится или докупится ...if(OrderProfit()>20)//////если поставить другое условие открывает много позицийOrderSend(Symbol(),OP_BUY, Lots,Ask,3, sl_buy,0,"Ma+Fr",16384,0,Lime);Sleep( PeriodForSleep);}
If I set a fractal breakthrough (or any other signal) instead of OrderProfit()>20 in the add condition, it opens many positions. I tried to add Sleep()-it does not help. What is the problem here?
обычно OrderModify error 1 бывает, когда новые параметры точно соответствуют тем, что в ордере..
Thank you, keekkenen! The parameters are different. The answer is found here. The advice (in the thread) is to nail this error...NormalizeDouble doesn't help either.
And what can you say about the second error (on additions)?
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.
Can you tell me how to pass one dimension from a two-dimensional array to a function?
I'm confused about something.
int testarray[5][2] = {1,2,3,4,5,6,7,8,9,10};// хоть так и можно записать, но в уме нужно держать что это ТАБЛИЦА
void testfunc(int &inarray[][]){ // массив нужно передавать "как есть", но обрабатывать можно выбранную часть
string out_str="Result: "+inarray[i,0];
for (int i=1;i<5;i++){// еще нужно учитывать, что счет в массивах начинается с НУЛЯ. "первый - нулевой"
out_str += (", "+inarray[i,0]); // здесь бы использовал строковую функцию конкатенации
}
Print(out_str);
}
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
Print("Call first:");
testfunc(testarray);
Print("Call second:");
testfunc(testarray);
//----
return(0);
}
//+-----------
I have two copies of the same broker's platform. Each has its own demo account and a shared folder called experts.
If I open the first one, then close it, then open the second one, I need to enter the password again in the second one.
I close the second and open the first one - now I need password for the first one. Is it supposed to be like this?
Thank you!
high=iHigh(NULL,60,1); Or is something wrong?
Everything is correct. But if you want to use multiple timeframes or symbols, you need to make corresponding logic in your EA.
Все правильно конечно. Но если нужно использовать несколько таймфреймов или инструментов, то нужно делать соотвествующую логику в советнике.
OK, I'll look into it. Thank you!
It's me again... Don't scold me too much... I have about two weeks of experience with EAs...
I have created my Expert Advisor based on fractals but it keeps showing OrderModify error 1 in my log during the test, although my moose is moving correctly based on fractals. I used Kim's FindNearFractal function. The code is as follows:
And on additions another question. The code is as follows: If I set a fractal breakthrough (or any other signal) instead of OrderProfit()>20 in the add condition, it opens many positions. I tried to add Sleep()-it does not help. What is the problem here?OrderModify error 1 usually happens when the new parameters exactly match those in the order...
обычно OrderModify error 1 бывает, когда новые параметры точно соответствуют тем, что в ордере..
Thank you, keekkenen! The parameters are different. The answer is found here. The advice (in the thread) is to nail this error...NormalizeDouble doesn't help either.
And what can you say about the second error (on additions)?
how do you find out how much paper profit, i.e. profit on unclosed positions, is currently in the EA?
KimIV has the GetProfitOpenPosInPoint() function.
У KimIV есть функция GetProfitOpenPosInPoint().
can I do it this way, and will it work?
or would it be better to insert the script code into the EA?