[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 508

 
artmedia70:

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

Returns the index of the highest value found (offset relative to the current bar).
Parameters:
symbol - Symbol name of the symbol, the data of which will be searched. NULL means current symbol.
timeframe - Period. Can be one of the periods of the chart. 0 indicates the period of the current chart.
type - The identifier of the timeseries. Can be any of the timeseries identifiers.
count - Number of elements of the timeseries (in the direction from the current bar to the ascending index), among which the search should be performed.
start - The index (offset from the current bar) of the start bar from which the search for the highest value will start. Negative values are ignored and replaced by a zero value.
Example:


Thank you very much. I don't think there will be any more questions.
 
ask:

What could be unclear to a person - I don't know. Neither do I know what caused the aggression and boorishness (they could have just ignored it), whether others would have responded or whether he would have recovered himself - is it all the same to you?

You should not think of Alexei in that way. He is one of the most benevolent people here. He did not mean to offend you. Everyone is sent to a telepath if they don't understand the problem. It's a local joke with meaning.
 
Reshetov:

Here they are (there are much more errors in your code but these ones won't even make it through the compiler): Moreover, even if you change the code to something more sane from the compiler's point of view

it will still be theoretically wrong without first normalising the real values before the comparison. Moreover, normalization may fail if price changes by more than one pip in one tick and your condition is missed.

The correct way to search for the crossing condition is


P.S. It is quite easy to find the place with the error after compilation in MetaTrader:

1. In the "Toolbox" tab, in the "File" column, specify the line number and the number of the symbol, in which the compiler has detected an error, separated by commas.

2. If you double-click on the error message in the "Description" field of the same tab, the cursor of the editor will jump to the place where the compiler has detected this very error.


Thanks for the tips.

 
Good afternoon! Respect to all forum members! If you can, please advise - when you turn off the platform data from the magazine is necessarily erased, right? And how do you write prints or any other output data from the Expert Advisor, so that when you turn off the computer, they would be saved in a notepad, or somewhere else? Isn't it too complicated and is it possible?
 
dkfl.zrjdktdbx:
Good afternoon! Respect to all forum members! If you can, please advise - when you turn off the platform data from the magazine is necessarily erased, right? And how do you write prints or any other output data from the Expert Advisor, so that when you turn off the computer, they would be saved in a notepad, or somewhere else? Isn't it too complicated and is it possible?
Well, if you look at the logs in the program folder, you will find a lot of interesting things there.
 
Thank you!
 
Can you tell me how to calculate a possible loss in the currency of the deposit by having an opening price and a stop loss price?
 
sss2019:
Tell me how to calculate a possible loss in the currency of the deposit with the opening price of the order and the stop loss price.
//--------------------------------------------------------------------
// Функция модификации StopLoss всех ордеров указанного типа
// Глобальные переменные:
// Mas_Ord_New             Массив ордеров последний известный
// int TralingStop         Значение TralingStop(количество пунктов)
//--------------------------------------------------------------------
void SampleTrailing_texbook ( int Tip, double V_StopLossPips, double V_TakeProfitPips)
  {
   int Ticket;                      // Номер ордера
   double
   Price,                           // Цена открытия рыночного ордера
   TS,                              // TralingStop (относит.знач.цены)
   SL,                              // Значение StopLoss ордера
   TP;                              // Значение TakeProfit ордера
   double difference; //разность в пунктах    
   double Profit;
   
   bool Modify;                     // Признак необходимости модифи.
//----------------------------------------------------------------------
      PointValue=MarketInfo(Symbol(),MODE_TICKVALUE)*(MarketInfo(Symbol(),MODE_POINT)/MarketInfo(Symbol(),MODE_TICKSIZE));      
      Print("PointValue = ",PointValue, " Point  = ", DoubleToStr(Point, Digits) );
      Level_new=MarketInfo(Symbol(),MODE_STOPLEVEL ); // мин уровень трала
      Modify=false;                       // Пока не назначен к модифи
      
      Price = OrderOpenPrice();           // Цена открытия ордера
      SL    = V_StopLossPips;             // Значение StopLoss ордера
      TP    = V_TakeProfitPips;           // Значение TakeProft ордера
      Ticket= OrderTicket();              // Номер ордера
      
      if (TralingStop<Level_new)          // Если меньше допустимого..
         TralingStop=Level_new;           // .. то допустимый
         TS=TralingStop*Point;            // То же в относит.знач.цены
      //-----------------------------------------------------------------
      switch(Tip)                         // Переход на тип ордера
        {
         case 0 :                         // Ордер Buy
            difference = NormalizeDouble (Bid-TS - OrderOpenPrice(), Digits)/Point;               
            Profit = Lots_New * difference*PointValue; // Профит по УРОВНЮ ТРАЛА рыночного ордера на данном объеме (не путать c OrderProfit)
            if (trlinloss==false){         // тралим только профит
               if (Profit>MathAbs (Sum_Loss)) // если профит по уровню трала больше суммарного убытка предыдущих поз 
                 if (NormalizeDouble(SL,Digits)<// Если ниже желаемого..
               NormalizeDouble(Bid-TS,Digits) && NormalizeDouble(Price,Digits)< NormalizeDouble(Bid-TS,Digits))
              {                           // ..то модифицируем его:
               SL=Bid-TS;                 // Новый его StopLoss
               Modify=true;               // Назначен к модифи.
              }
            } 
             else {                         // тралим с зоны лоссов
               if (NormalizeDouble(SL,Digits)<// Если ниже желаемого..
               NormalizeDouble(Bid-TS,Digits))
              {                           // ..то модифицируем его:
               SL=Bid-TS;                 // Новый его StopLoss
               Modify=true;               // Назначен к модифи.
              }
             } 
            break;                        // Выход из switch
         
         
         case 1 :                          // Ордер Sell
             difference = NormalizeDouble (OrderOpenPrice()-(Ask+TS),Digits)/Point;
             Profit = Lots_New * difference*PointValue; // Профит по УРОВНЮ ТРАЛА рыночного ордера на данном объеме (не путать c OrderProfit)             
             if (trlinloss==false) {          // тралим с уровня профита по ордеру
                if (Profit>MathAbs (Sum_Loss)) // если профит по уровню трала больше суммарного убытка предыдущих поз            
                   if ((NormalizeDouble(SL,Digits)>  // Если выше желаемого..
                        NormalizeDouble(Ask+TS,Digits)||
                        NormalizeDouble(SL,Digits)==0) && NormalizeDouble(Price,Digits)>NormalizeDouble(Ask+TS,Digits)) //.. или нулевой(!)
              {                           // ..то модифицируем его
               SL=Ask+TS;                 // Новый его StopLoss
               Modify=true;               // Назначен к модифи.
              }
            }            
            else {                        // тралим с зоны лоссов
          
            if (NormalizeDouble(SL,Digits)>// Если выше желаемого..
               NormalizeDouble(Ask+TS,Digits)||
               NormalizeDouble(SL,Digits)==0)//.. или нулевой(!)
              {                           // ..то модифицируем его
               SL=Ask+TS;                 // Новый его StopLoss
               Modify=true;               // Назначен к модифи.
              }
            }  
        }                                 // Конец switch
      if (Modify==false)                  // Если его не надо модифи..
         return;                        // ..то идём по циклу дальше
      bool Ans=OrderModify(Ticket,Price,SL,TP,0);//Модифицируем его!
      //----------------------------------------------------------------------
      if (Ans==false)                     // Не получилось :( 
        {                                 // Поинтересуемся ошибками:
            Print("Не удалось модифицировать ордер №",OrderTicket(),". Ошибка: ",GetLastError());
            return;                       // .. то уходим.
        }
}                                         // Выход из пользов. функции


This trader's fi- fion from the textbook was reworked by me for my own needs. Here, the calculation of profit on a given volume of lots, at the trawl level and the value of the profit above the total loss of previous closed consecutive losing positions - the trawl is enabled - you will have everything similar, only to apply not a profit, as here, but a loss - as you need.

Pay attention to the calculation of Buy and Sell variables:

double difference; //разность в пунктах    
double Profit; 
PointValue=MarketInfo(Symbol(),MODE_TICKVALUE)*(MarketInfo(Symbol(),MODE_POINT)/MarketInfo(Symbol(),MODE_TICKSIZE));
Do everything in the same way and that's it.
 
So I still don't understand how to find out the point value in the deposit currency?
 
sss2019:
So I still don't understand how to find out the point value in the deposit currency?

see this calculation - do ANALOGUE. Everything.