[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 402

 

Hi all!

I tried to make up a function, who can tell me what mistakes are made here?

//попытка сделать функцию: отключение всех  индикаторов и разрешение только Бай или Селл в зависимости от того, 
//что закуплено, когда баланс снижается на заданный процент
bool fOffInd(){
int i, b, s;
   if( UT_AutoOf==1){
   //если баланс снизился на LossIndikator процентов
       if( gProfit<=((-1.0)* LossIndikator*AccountBalance())/100.0){
          Print ("Индикаторы выключен автоматически!");
          UT_ON=0; //выключатель индикатора, 0-контроль отключен
          VRF_ON=0;//выключатель индикатора, 0-контроль отключен
   //выбираем открытые ордера Бай       
   for( i=1; i<=OrdersTotal(); i++){        
      if(OrderSelect( i-1, SELECT_BY_POS)==true){   
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol()){ b= b+1;}
        }   
        return( b);
        }
   //выбираем открытые ордера Селл     
   for( i=1; i<=OrdersTotal(); i++){        
      if(OrderSelect( i-1, SELECT_BY_POS)==true){   
           if(OrderType()==OP_SELL && OrderSymbol()==Symbol()){ s= s+1;}
        }   
        return( s);
        }
   //если открытых Бай больше чем Селл, то включаем запрет торговли Бай     
       if( s<= b){ CloseAllBuyNow  = true;
         Print ("Работаем только Селл!");
          }
       else{
   //если открытых Селл больше чем Селл, то включаем запрет торговли Селл    
       if( b<= s){ CloseAllSellNow = true;
         Print ("Работаем только Бай!");
             }
           }
            return(false);
         }
       }
       else{
       //все индикаторы должны быть включены и запрет на Бай и Селл снят
          UT_ON=1;
          VRF_ON=1;
          CloseAllBuyNow  = false;
          CloseAllSellNow = false;
//          return(false);
    }
   return(0);    
} 

 
 

So, the solution for you is for the EA to read the information from the indicator, the iCustom function is used for this, read its description in the documentation. It writes the value from the indicator array for the corresponding bar to the variable you need in your EA.

Here is the description of this function https://docs.mql4.com/ru/indicators/iCustom

Thanks, I will look at it.

I now try to order the indicator to create a global variable and then to read its value into the EA as described in the tutorial.

I have not come across iCustom function in this manner.

 

Hello, please advise how to act I opened a demo account of $ 100 and wanted to make a deal and changed the lot size to 0.10 or 0.05, but the program does not allow to do so, not lit buy and sit buttons.

 
Arius писал(а) >>

Good afternoon please advise how to act I opened a demo account of 100 dollars and wanted to make a deal while changing the lot size to 0.10 or 0.05, but the program does not let this be done, not lit buy and sit buttons.

Buddy it can not fix anything, it all depends on the company in which you opened the account, if it can trade lots less than 0.10, then the button will be lit, otherwise you can not affect anything.

 
Stanislav.exe писал(а) >>

There's no way to fix it, it all depends on the company you opened your account with, if they allow you to trade with lots less than 0.10, then the buttons will light up, otherwise you can't influence it.

>> Thank you.

 

Hello all!!! Please help a newbie.

I need to write the following code, alas I can't figure it out myself yet.

"The EA should open only one trade during the time from crossing two MAs to their back crossing."

Question: "Of course, the code itself and where to place it? "Thanks in advance.

 
Stanislav.exe писал(а) >>

Hello all!!! Please help a newbie.

I need to write the following code, alas I can't figure it out myself yet.

"The EA should open only one trade during the time from crossing two MAs to their reverse crossing."

Question: "Of course, the code itself and where to place it? " Thanks in advance.

Have a look at CodeBase. It's already there.

 
Vinin писал(а) >>

Look in CodeBase. It's already there.

Thank you, I'll look for it now.
 
Nail_Saby >>:

всем привет!

Вот попытался состряпать одну функцию, кто сможет сказать, какие тут ошибки допущены?

is this a clever task or what? Well then, why do you need for loops, if on the first iteration of each one you already have a return() call from the program?

 
alsu писал(а) >>

is this a clever task or what? Well then, why do you need for loops, if on the first iteration of each one you are already being called from the program by return()?

I took a piece of code with for from a ready-made function http://fxnow.ru/blog.php?user=Yuriy&blogentry_id=66...

But should I remove return() from the very bottom one? To make it work?