Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 76

 
lottamer:


DC is five digits...

what does it mean WITHOUT DoubleToStr(YourPrice,5) ? i have DoubleToStr(YourPrice,5) nowhere

If you just put a double variable somewhere in Print or Alert (Print(doubleVariable)), only four decimal places will be printed; if you put Print(DoubleToStr(doubleVariable,N)) - the program will print N decimal places.
 
Question to the moderators - very often the site sends me back for reauthorisation. When I try to log in, the message "Your access is temporarily restricted or denied" is displayed. Then, after a few hours, access is restored. What could be the problem?
 
Thank you all for the advice, but logically, there is no difference between the two options...
  • for (int i=1; i<=OrdersTotal(); i++)
  • for (int i=OrdersTotal()-1; i>=0; i--)
Or am I wrong ? By the way, this didn't help....


The strange thing is that EA completely deletes all orders under this condition:
  • for (int i=0; i<=OrdersTotal(); i++)
  • for (int i=OrdersTotal(); i>=0; i--)
Can anyone understand why?

 
yosuf:
Question to the moderators - very often the site sends me back for reauthorisation. When I try to log in, the message "Your access is temporarily restricted or denied" is displayed. Then, after a few hours, access is restored. What could be the problem?
Homeostatic Universe. Moderators can't affect authorization. Only ban it permanently.
 
granit77:
Homeostatic Universe. Moderators can't affect authorisation. Only banned permanently.
What to do now? Who to turn to?
 
yosuf:
What to do now? Who to turn to?

To the moderator of the universe.
 
yosuf:
Question to the moderators - very often the site sends me back for reauthorisation. When I try to log in, the message "Your access is temporarily restricted or denied" is displayed. Then, after a few hours, access is restored. What could be the problem?

You are being trolled))) You're a charismatic individual))))
 

Greetings.

Can you tell me how to take into account a price crossing with an indicator line?

the indicator has three lines: bottom, middle and top.

here is an example:

when the price crossed the upper line, I need to fix this moment and use it afterwards, when the price is below the upper line and above the middle line, and when the price is below the middle line, I need to reset the fixed result. I don't need to remember the price where the crossover occurred, I just need to put a checkmark to indicate that the crossover occurred and then clear it.

LineUp //верхняя линия

LineS // средняя линия

LineDown // нижняя линия

Ask >  LineUp // фиксируем

Ask < LineS // сбрасываем

и так же с нижней линией

Bid < LineDown // фиксируем

Bid > LineS //  сбрасываем

I tried it with True and false, it did not work, I cannot understand why.

I tried this:

double LineUp; //верхняя линия индикатора

double LineS; // средняя линия индикатора

double LineDown; // нижняя линия индикатора

bool FiksiruemUp = False;

 bool FiksiruemDown = False;

if ( Ask >  LineUp)  FiksiruemUp = True; // фиксируем

if (Ask < LineS) FiksiruemUp = False; // сбрасываем

// и так же с нижней линией

if (Bid < LineDown)  FiksiruemDown = True; // фиксируем

if (Bid > LineS)  FiksiruemDown = False; //  сбрасываем

 

// дальше в коде я к нему обращаюсь:

if ( FiksiruemUp == True) 

{

то нужно сделать это . . . . . . 

} 

and it doesn't work. Why not? Help me understand.

 
Dear forum users, please help, I can not find a bug in the code of my EA, namely, it can not or does not want to close positions by indicator, only by tp or sl, here, as it seems to me, part of the code, which is associated with this problem, many thanks in advance
int start()
  {
   int
   Total,                           // Количество ордеров в окне 
   Tip,                          // Тип выбран. ордера (B=0,S=1)
   Ticket;                          // Номер ордера
   double
   FT1,                              // Значение 0 буффера Forex Trend
   FT2,                             // Значение 1 буффера Forex Trend
   TL1,                              // Значение 1 буффера Trend Lord
   TL2,                              // Значение 0 буффера Trend Lord                          
   FI,                               // Значен. Force Index текущее 
   Lot,                             // Колич. лотов в выбран.ордере
   Lts,                             // Колич. лотов в открыв.ордере
   Min_Lot,                         // Минимальное количество лотов
   Step,                            // Шаг изменения размера лота
   Free,                            // Текущие свободные средства
   One_Lot,                         // Стоимость одного лота
   Price,                           // Цена выбранного ордера
   SL,                              // SL выбранного ордера 
   TP;                              // TP выбранного ордера
   bool
   Ans  =false,                     // Ответ сервера после закрытия
   Cls_B=false,                     // Критерий для закрытия  Buy
   Cls_S=false,                     // Критерий для закрытия  Sell
   Opn_B=false,                     // Критерий для открытия  Buy
   Opn_S=false;                     // Критерий для открытия  Sell
                                                        
   
//--------------------------------------------------------------- 3 --
   // Предварит.обработка
   if(Bars < Period_FI)                       // Недостаточно баров
     {
      Alert("Недостаточно баров в окне. Эксперт не работает.");
      return;                                   // Выход из start()
     }
   if(Work==false)                              // Критическая ошибка
     {
      Alert("Критическая ошибка. Эксперт не работает.");
      return;                                   // Выход из start()
     }
//--------------------------------------------------------------- 4 --
   // Учёт ордеров
   Symb=Symbol();                               // Название фин.инстр.
   Total=0;                                     // Количество ордеров
   for(int i=1; i<=OrdersTotal(); i++)          // Цикл перебора ордер
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) // Если есть следующий
        {                                       // Анализ ордеров:
         if (OrderSymbol()!=Symb)continue;      // Не наш фин. инструм
         if (OrderType()>1)                     // Попался отложенный
           {   
            Alert("Обнаружен отложенный ордер. Эксперт не работает.");
            return;                             // Выход из start()
           }
         Total++;                               // Счётчик рыночн. орд
         if (Total>1)                           // Не более одного орд
           {
            Alert("Несколько рыночных ордеров. Эксперт не работает.");
            return;                             // Выход из start()
           }
         Ticket=OrderTicket();                  // Номер выбранн. орд.
         Tip   =OrderType();                    // Тип выбранного орд.
         Price =OrderOpenPrice();               // Цена выбранн. орд.
         SL    =OrderStopLoss();                // SL выбранного орд.
         TP    =OrderTakeProfit();              // TP выбранного орд.
         Lot   =OrderLots();                    // Количество лотов
        }
     }
//--------------------------------------------------------------- 5 --
   // Торговые критерии
                          
   TL1=iCustom(NULL, 0, "TrendLord", 1, 1);                          // trend lord синий
   TL2=iCustom(NULL, 0, "TrendLord", 0, 1);                          // красный тренд лорд
   FI=iForce(NULL, 0, Period_FI,MODE_EMA,PRICE_CLOSE,0);            // FI
   FT1=iCustom(NULL, 0, "ForexTrend", 7, 50.6, 999999, 0, 1);                        // forex trend blue
   FT2=iCustom(NULL, 0, "ForexTrend", 7, 50.6, 999999, 1, 1);                        // forex trend red


   if (TL2 == EMPTY_VALUE && FT1 == 1 && FT2 == 0 && FI > 0)
   {
      Opn_B = true;
      
   
      
   }
   while (Opn_B == true)
   {
      if (FI <= 0)
      {
         Cls_B=true;
      }
  break;
   }      
      
   if (TL1 == EMPTY_VALUE && FT2 == 1 && FT1 == 0 && FI < 0)
   {
      Opn_S = true;
      
     
      
   }
   while (Opn_S == true)
   {
      if (FI >= 0)
      {
         Cls_S=true;
      }
   break;
   }    
//--------------------------------------------------------------- 6 --
   // Закрытие ордеров
   while(true)                                  // Цикл закрытия орд.
     {
      if (Tip==OP_BUY && Cls_B==true)                // Открыт ордер Buy..
        {                                       //и есть критерий закр
         Alert("Попытка закрыть Buy ",Ticket,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
         Ans=OrderClose(Ticket,Lot,Bid,2);      // Закрытие Buy
         if (Ans==true)                         // Получилось :)
           {
            Alert ("Закрыт ордер Buy ",Ticket);
            break;                              // Выход из цикла закр
           }
         if (Fun_Error(GetLastError())==1)      // Обработка ошибок
            continue;                           // Повторная попытка
         return;                                // Выход из start()
        }

      if (Tip==OP_SELL && Cls_S==true)                // Открыт ордер Sell..
        {                                       // и есть критерий закр
         Alert("Попытка закрыть Sell ",Ticket,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
         Ans=OrderClose(Ticket,Lot,Ask,2);      // Закрытие Sell
         if (Ans==true)                         // Получилось :)
           {
            Alert ("Закрыт ордер Sell ",Ticket);
            break;                              // Выход из цикла закр
           }
         if (Fun_Error(GetLastError())==1)      // Обработка ошибок
            continue;                           // Повторная попытка
         return;                                // Выход из start()
        }
      break;                                    // Выход из while
 
belck:

Greetings.

Can you tell me how to take into account a price crossing with an indicator line?

the indicator has three lines: bottom, middle and top.

Here is an example:

when the price crossed the upper line, I need to fix this moment and use it afterwards, when the price is below the upper line and above the middle line, and when the price is below the middle line, I need to reset the fixed result. I don't need to remember the price where the crossover occurred, I just need to put a checkmark to indicate that the crossover occurred and then clear it.

I tried it with True and false, it did not work, I cannot understand why.

I tried this:

and it doesn't work. Why not? Help me understand.


It doesn't work, because you need to bring the variables that you want to commit to the global level, i.e. before the Start function... For example these and so on.... " FiksiruemUp = True; // commit " and "iksiruemUp = False; // reset"
If you don't switch between timeframes, it should work...
Reason: