[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 404

 
Vinin писал(а) >>

Crossing is easier and quicker to check in another way

The speed is higher. Logical complex expressions take longer to execute than simple ones. Multiplication is faster than logical

Thanks Vinin, what about the number of trades, can you write them to be only 1.2...N, after crossing the MA.

 
Vinin >>:

Пересечение проще и быстрее проверять по другому

Скорость работы выше. Логические сложные выражение выполняются дольше простых. Умножение быстрее логического

another option, but I don't think the questioner will understand it yet

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

Thanks Vinin, what about the number of trades, is it possible to write them only 1.2...N, after MA crossing.

Apparently we need to consider additional conditions for entry.

And count the number of open positions.

But it will have little relation to crossovers.

Because maybe in one case there was only one signal, in the second case there were 10.

But we should determine the conditions for an additional entry first.

 
Vinin писал(а) >>

Apparently there are additional entry conditions to consider.

And count the number of open positions.

But it has little relation to the crossover.

Because maybe in one case there was only one signal, in the second case - 10.

But first we should define the conditions for the additional entry

OK, I will try to look deeper, many thanks to Vilin and sanyooooook for the help.

 

double Lots;
double m = 0.1;


for (m = 0.1; AccountFreeMarginCheck(Symbol(),OP_SELL,m)>150; m = m + 0.1)
{
Lots = m;
}

Why do my Lots always turn out to be zero?

 
Noterday >>:

double Lots;
double m = 0.1;


for (m = 0.1; AccountFreeMarginCheck(Symbol(),OP_SELL,m)>150; m = m + 0.1)
{
Lots = m;
}

Почему у меня Lots всегда оказывается равен нулю?


Is the loop executed or is it immediately exited by the condition?

https://docs.mql4.com/ru/basis/operators/for

Expression1 describes the loop initialization. Expression2 is a check for the loop termination condition. If it is true, the loop body for is executed. Everything repeats until expression2 is false. If it is false, the loop is terminated and control is given to the next operator. Expression3 is calculated after each iteration.
for(expression1; expression2; expression3)
operator;

 
Apparently it comes right out... Put an alert in the loop - nothing...
 

Good evening. I have a problem with the terminal, I can't fix it in any way:

I load MT4, load a template, draw trend lines, and when I switch TFs, the lines disappear, incl. they are not displayed on the original timeframe either. At the same time, the rest of the chart (horizontal, vertical lines, channels, all the Fibos, etc.) works fine. On a clean ("template-less") chart, the layout is preserved completely, everything worked fine before on the same indulators. Expert Advisors and Expert Advisors have been disabled. I work mainly on the chart, help me out!!!

 

Hello,

How do I make my EA not close a trade before 3 min?

Can anyone advise what and where to prescribe?

 
Vinin писал(а) >>

You have to start with logic. What you wanted to get and how you wanted to get it.

Well, I think the logic is explained in the comments...

I took out the returns and it went like this:

//попытка сделать функцию: отключение всех  индикаторов и разрешение только Бай или Селл в зависимости от того, 
//что закуплено, когда баланс снижается на заданный процент
//второй вариант:

bool fOffInd(){
int i, b, s;
   if( UT_AutoOf==1){
   //если баланс снизился на LossIndikator процентов
       if( gProfit<=((-1.0)* LossIndikator*AccountBalance())/100.0){
          Print ("Включен автореверс UT_!");
          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;}
          }   
        }
   //выбираем открытые ордера Селл     
   for( i=1; i<=OrdersTotal(); i++){        
      if(OrderSelect( i-1, SELECT_BY_POS)==true){   
           if(OrderType()==OP_SELL && OrderSymbol()==Symbol()){ s= s+1;}
          }   
        }
   //если открытых Бай больше чем Селл, то включаем запрет торговли Бай     
       if( s>= b){ CloseAllBuyNow  = true;
        MaxCount = b;
         Print ("Автореверс. Работаем только Селл!");
          }
       else{
   //если открытых Селл больше чем Селл, то включаем запрет торговли Селл    
       if( b>= s){ CloseAllSellNow = true;
        MaxCount = s;
         Print ("Автореверс. Работаем только Бай!");
             }
           }
           return(false);
         }
       }
       else{
       //все индикаторы должны быть включены и запрет на Бай и Селл снят
          UT_ON=1;
          VRF_ON=1;
          CloseAllBuyNow  = false;
          CloseAllSellNow = false;
    }
   return(0);    
} 
It seems to work, but I don't know if the code is correct... If anything is wrong, can someone correct it?
Reason: