[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 416

 
VladimirR:

That option doesn't work either



I wonder what you are looking for. There are other options for finding the maximum area. For example analytical
 
Vinin:

I wonder why the counter values need to be changed twice in the loop. And for some reason there is no (preliminary) assignment of S2. This value at the start is 0, and only on the second iteration (more precisely on the third) goes real value comparison (it depends on how to count from zero or from one).
There is no assignment, because the enumeration starts with the minimum value of the area it is strictly positive, so 0 is good enough. Where do the counter values change for the second time?
 
Vinin:

I wonder what you are looking for, too. There are other options for finding the maximum area. Like the analytical one.
It's not the problem at all. It's a simple task used as an example of how the break operator works. I need to know why you can't write for(int i=1, j=499; i<500; i++,j--) if you don't commit the i,j variables before the loop in order to write correct programs later!
 
VladimirR:
That's not the problem at all. This is a simple task used as an example of how the break operator works. I need to know why you cannot write for(int i=1, j=499; i<500; i++,j--) if you don't commit the i,j variables before the loop in order to write the right programs later!

It's probably a bug in the compiler.

It doesn't compile that way:

for( int i=1, j=499; i<500; i++,j--) //последовательный перебор значений площади

This is how it compiles:

int i, j;
for( i=1, j=499; i<500; i++,j--) //последовательный перебор значений площади

And this is how it compiles:

int i=1, j=499;
for( ; i<500; i++,j--) //последовательный перебор значений площади
 

Hello all!!!

Please help me get the RiskReward number out of the indicator. I can't get it into my Expert Advisor.

 
demlin:

Hello all!!!

Please help me get the RiskReward number out of the indicator. I can't get it into my Expert Advisor.


Where is the source code?
 

People, why is it so hard to answer me or you just don't want to? You are sorting out such crap here, but you're too lazy to help write part of the code. I will try to ask you one more time, if you don't help me, I'll go to courses, I'm sick of begging you here.


Once again: after the EA has been attached to the chart with the first tick, it fixes the Ask price. Then, during trading, as soon as the price increases by, say, 10% (it is clear that it cannot be, it is figurative), the EA should notify a trader with the message "The price has increased by 10%".

 
demlin:

Hello all!!!

Please help me get the RiskReward number out of the indicator. I can't get it into my Expert Advisor.

Go through all objects on the chart, find an object named lbl, take out from it the string FXRanger: Risk:Reward=x.xxx, parse it and convert x.xxx to double.
 

Help fix if orders open with SL, and if there are two opposite orders, for the second one it removes SL.... but this is not needed

Thanks

void Trailing()
{
//-----
  double Up = iCustom(NULL,0,"NLO",TrailPeriod,0,1);
  double Dn = iCustom(NULL,0,"NLO",TrailPeriod,1,1);
//-----
  int Orders = OrdersTotal();
  for (int i=0; i<Orders; i++)
  {
    if(!(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))) continue;
    if(OrderSymbol() != Symbol()) continue;
    {
      if(OrderType() == OP_BUY && OrderMagicNumber()==Magic && Up > OrderOpenPrice()
      && OrderStopLoss() != Up && (OrderStopLoss() == 0 || Up > OrderStopLoss()))
      {
        OrderModify(OrderTicket(),OrderOpenPrice(),Up,OrderTakeProfit(),0,CLR_NONE);
      }
      if(OrderType() == OP_SELL && OrderMagicNumber()==Magic && Dn < OrderOpenPrice()
      && OrderStopLoss() != Dn && (OrderStopLoss() == 0 || Dn < OrderStopLoss()))
      {
        OrderModify(OrderTicket(),OrderOpenPrice(),Dn,OrderTakeProfit(),0,CLR_NONE);
      }
    }
  }
}
 

Hello. Once again I cannot solve the example from the tutorial.

Task 17. There are 1,000 sheep on the first farm. Every day the number of sheep on the first farm increases by 1%. On the day that the number of sheep on the first farm reaches 50,000, 10% of the sheep are transferred to the second farm. How long will it take for the number of sheep on the second farm to reach 35,000? (Assume that there are 30 working days in the month.)

//--------------------------------------------------------------------
// othersheep.mq4
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
int start()                               // Специальная ф-ия start()
  {
//--------------------------------------------------------------------
   int
   day,                                   // Текущий день месяца
   Mons;                                  // Искомое количест. месяцев
   double
   One_Farm    =1000.0,                   // Количество на 1 ферме
   Perc_day    =1,                        // Ежедневный подъём, %
   One_Farm_max=50000.0,                  // Пороговое значение
   Perc_exit   =10,                       // Разовый вывод, %
   Purpose     =35000.0,                  // Необх. колич. на 2 ферме
   Two_Farm;                              // Количество на 2 ферме
//--------------------------------------------------------------------
   while(Two_Farm < Purpose)              // До достижения цели
     {                                    // Начало тела внешн. цикла
      //--------------------------------------------------------------
      for(day=1; day<=30 && Two_Farm < Purpose; day++)// Цикл по дням 
        {
         One_Farm=One_Farm*(1+Perc_day/100);//Накопл. на 1 ферме
         if (One_Farm < One_Farm_max)     // Если меньше допустимого,.
            continue;                     // .. то овец не переводим
         Two_Farm=Two_Farm+One_Farm*Perc_exit/100;//Накопл. на 2 ферме
         One_Farm=One_Farm*(1-Perc_exit/100);     //Остаток на 1 ферме
        }
      //--------------------------------------------------------------
      if (Two_Farm>=Purpose)              // Если цель достигнута,..
         continue;                        // .. то месяцы не считаем
      Mons++;                             // Считаем месяцы
     }                                    // Конец тела внешнего цикла
//--------------------------------------------------------------------
   Alert("Цель будет достигнута через ",Mons," мес. и ",day," дн.");
   return;                                // Выход из функции start()
  }
//-------------------------------------------------------------------

In this example, the exit from the loop

 for(day=1; day<=30 && Two_Farm < Purpose; day++)// Цикл по дням 

The "extra day" is always added, i.e. a day for which no calculation is performed is added, but as the cycle is nested, the "extra day" remains.

every time the control returns to it, the days are recounted again, so it's not essential. But when the loop is exited

while(Two_Farm < Purpose)              // До достижения цели

the "extra day" remains. And as a result the wrong answer will be printed.

Can you tell me if my reasoning is correct or did I get something wrong?