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

 
splxgf:
Better still the first option, place before attempting to open an order (OrderSend)
Thank you very much! Everything works :)
 
kolyango:

All these conditions may not follow immediately one after another (may be in an hour or two or three), therefore we should make it so that as soon as the indicator reaches 1.0000, this condition is not checked at every tick, and wait until one bar closes with fall, and after that these 2 conditions are not checked at every tick, and wait until the indicator reaches 0.9980 or equal. As soon as all conditions are fulfilled we open a market order to sell 0.1 lot with a stop loss of 400p and take profit of 400p.

In general it's OK, but I would pay close attention to the values returned by the indicator.

bool Val_max=false, Cl_dn=false, Val_min=false; 
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   int
   i, j, total,
   cnt,
   OrderBuy,
   OrderSell,
   Magic,
   Ticket,                                      // Номер ордера
   Total=0,                                     // Количество ордеров в окне
   Tip=-1;                                      // Тип выбран. ордера (B=0,S=1)      
   double
   Open_0,
   ask,
   bid,
   Price,                                       // Цена выбранного ордера
   SL,                                          // SL выбранного ордера
   TP,                                          // TP выбранного ордера
   Lot;                                         // Колич. лотов в выбран.ордере
   Open_0=Open[0];                             // Цена откр. формирующегося бара
   ask=Ask;                                    // Текущая цена покупки
   bid=Bid;                                    // Текущая цена продажи
   string
   Symb;                                        // Название финанс. инструмента
   Symb=Symbol();                               // Название фин.инстр.
double Value_max=1.0000;
double Value_min=0.9980;
double Open_1= Open[1];
double Close_1= Close[1];
//----

//--------------------------------------------------------------- 4 --

double Val=iCustom(NULL, 0, "HMR MULTI Indicator",0,0);   
if (Val >= Value_max) Val_max=true;                  // 
if (Open_1 > Close_1 && Val_max==true) Cl_dn=true;
if (Val <= Value_min && Cl_dn==true) Val_min=true;
if (Val_max==true && Cl_dn==true && Val_min==true)
  {
   for (j = 0; j < OrdersTotal(); j++)
    {
     OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
     if (OrderSymbol() == Symbol())
      {
      if (OrderType() == OP_SELL) return(0);
      }
    }

   OrderSend(Symbol(),OP_SELL,0.1,NormalizeDouble(Bid,Digits),2,Bid+400*Point,Bid-400*Point,"",3,Red);  // Открытие SELL
   Val_max=false; Cl_dn=false; Val_min=false;
  }

//----
   return(0);
  }
 
splxgf:

Overall it's OK, but I would pay close attention to the values returned by the indicator.


Tried in real time via Alert the value of the indicator, the message was displayed normally:

double Val=iCustom(NULL, 0, "HMR MULTI Indicator",0,0);   
if (Val >= Value_max)
{
Alert("Значение индикатора >= 1.0000");
}
When the value reached 1.0000, at each tick the following message was displayed: " Indicator value >= 1.0000".
 
kolyango:


Tried the real time value of the indicator via Alert, the message was displayed normally:

Then what the tester doesn't like, you need to add alerts and look at the log.
 
splxgf:
Then what the tester doesn't like, you need to add alerts and look in the logbook.

Well is the code correct?
 

What does it mean?

2011.12.06 01:07:55 HMR MULTI Indicator EURUSD,M15: removed

2011.12.06 01:07:57 TestGenerator: unmatched data error (volume limit 603 at 2011.12.01 00:00 exceeded)

2011.12.06 01:07:57 2011.12.01 00:00 HMR MULTI Indicator EURUSD,M15: unknown subwindow number -1 for ObjectCreate function


 
kolyango:

What does it mean?

2011.12.06 01:07:55 HMR MULTI Indicator EURUSD,M15: removed

2011.12.06 01:07:57 TestGenerator: unmatched data error (volume limit 603 at 2011.12.01 00:00 exceeded)

2011.12.06 01:07:57 2011.12.01 00:00 HMR MULTI Indicator EURUSD,M15: unknown subwindow number -1 for ObjectCreate function


There seem to be two errors:
1. Probably need to disconnect MT4 from Internet and then import historical data.
2. You need to check the code.

 
chief2000:
There seem to be two mistakes there:
1. You may need to disconnect MT4 from the internet and then import historical data.
2. You need to check the code.

... indicator.

 int start(){
  double Val=iCustom(NULL, 0, "HMR MULTI Indicator",0,0);   
  Alert(Val);
}

Try the "gut feeling" method with an empty Expert Advisor,

verify in the indicator that ObjectCreate finds its subwindow (or why draw it IF we test OR OPTIMIZE it)

if(IsTesting()||IsOptimization())флаг_Канады_не_рисовать_obj=true;          //проверяем надо ли рисовать (в ините ему место через статик переменную)
if(!флаг_Канады_не_рисовать_obj){                                           //запрет отрисовки объектов ели оптимизация или тестирование
ObjectCreate(........................);
}
 
granit77:
That is, if there is no parameter transfer, then:

Thank you for your answers !
 

Good afternoon!

Can you please tell me how to prevent the EA from writing repetitions to the file using the "Tool" parameter (_OrderSymbol). I've seen on the forum how to delete repetitions https://forum.mql4.com/ru/5814 in an array, but I haven't figured out how to apply it to my situation. And with repeats it starts stamping 200 identical lines into a file even in one loop.

void TimeStr6() { 
   int i,handle,_ordertype;
   double _openprice,_orderLots,_OrderProfit;
   string _orderspread,_orderbalance,_OrderSymbol,_orderOpenTime,_orderOpenTime1;
   string tekTime=TimeToStr(CurTime(),TIME_DATE)+"_";
   string path=tekTime+"Оптимальный.csv";
//---------------------------
    handle=FileOpen(path,FILE_READ|FILE_WRITE);
    if (handle>0){
       FileWrite(handle,"Дата","Время","Инструмент","Баланс оптимальный"); 
       _orderOpenTime=TimeToStr(OrderOpenTime(),TIME_DATE);
       _orderOpenTime1=TimeToStr(OrderOpenTime(),TIME_SECONDS);
       _OrderSymbol=SymbolMax[nnnn];
       _orderbalance=DoubleToStr(StartBalance,0);
       FileSeek(handle,0,SEEK_END);
       FileWrite(handle,_orderOpenTime,_orderOpenTime1,_OrderSymbol,_orderbalance);
       FileClose(handle);
     }
   return;
}

Reason: