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

 
BaceK1 >> :
How do I open a position at a precise time? For example, I need to open a position at 00.15 local time.

if (hour == 0 && minute==15) {then do this;}

Look into Expert Advisor, there are some missing (and some unnecessary) brackets:

//+------------------------------------------------------------------+
//|                                                   Полуночник.mq4 |
//|                                                            BaceK |
//+------------------------------------------------------------------+
#property copyright "BaceK"
#property link ""
//---- input parameters
extern int Dist_SL=20;
extern int Dist_TP=30;
extern double Prots=0.35;
int start()
{
string Symb=Symbol(); // Финанс. инструмент
int Min_Dist=MarketInfo( Symb,MODE_STOPLEVEL);// Мин. дистанция //Alert("Мин. дистанция = ",Min_Dist);
double Min_Lot=MarketInfo( Symb,MODE_MINLOT);// Мин. размер лота//Alert("Мин. размер лота = ",Min_Lot);
double Free =AccountFreeMargin(); // Свободн средства//Alert("Свободн средства = ",Free);
double One_Lot=MarketInfo( Symb,MODE_MARGINREQUIRED);//Стоим.лота//Alert("Стоим.лота = ",One_Lot);
double Lot=MathFloor(( Free* Prots)/( One_Lot* Min_Lot))* Min_Lot;// Лоты//Alert("Лоты = ",Lot);//Alert("Bars = ",Bars);
//-----------------------------------------------
if( Lot != 0 ) // Проверка свободных срелств                       
 {//Alert("Работа дальше = ",OrderSymbol());
  // Проверка рабочего времени
  int h=TimeHour(TimeCurrent());
  if( h < 1 )
    {for(int i=1; i<=OrdersTotal(); i++) // Цикл перебора ордер
        {if(OrderSelect( i-1, SELECT_BY_POS)==true) // Если есть следующий
           {// Анализ ордеров:
            if(OrderSymbol()!= Symb) // Не наш фин.инструм.
              {//Alert("Работа дальше = ",OrderSymbol());
               // Определение в какую сторону открываться
               if(iOpen(NULL,PERIOD_D1,1)-iClose(NULL,PERIOD_D1,1)< 0)
                 {//Alert("Длинная позиция = ",iOpen(NULL,PERIOD_D1,1)-iClose(NULL,PERIOD_D1,1));
                  int ticket=OrderSend( Symb,OP_BUY, Lot,Ask,3,Bid- Dist_SL*Point,Bid+ Dist_TP*Point);
                 }
               else
                 {//Alert("Короткая позиция = ",iOpen(NULL,PERIOD_D1,1)-iClose(NULL,PERIOD_D1,1));
                  int ticket1=OrderSend( Symb,OP_SELL, Lot,Bid,3,Bid+ Dist_SL*Point,Bid- Dist_TP*Point);
                 }
               if( ticket>0 || ticket1>0) // Получилось :)
                 {// Alert ("Установлен ордер SELL ",ticket || ticket1);
                  Sleep(5000);
                 }
               else
                 {int Error=GetLastError(); // Не получилось :(
                  switch( Error) // Преодолимые ошибки
                    {case 129:...................................
                    }
                  switch( Error) // Критические ошибки
                    {case 2 : ...................................
                    }
                  //Alert (GetLastError());
                  return(0);
                 }
              }
            else
              {//Alert("Выход по Symb = ",Symb);
               return(0);
              }
        }//это скобка закрывающая for() почему после неё идёт else ???????? 
      else
        {//Alert("Выход по ордеров нет = ",Symb);
         if(iOpen(NULL,PERIOD_D1,1)-iClose(NULL,PERIOD_D1,1)< 0)
           {//Alert("Длинная позиция = ",iOpen(NULL,PERIOD_D1,1)-iClose(NULL,PERIOD_D1,1));
            int ticket2=OrderSend( Symb,OP_BUY, Lot,Ask,3,Bid- Dist_SL*Point,Bid+ Dist_TP*Point);
           }
         else{//Alert("Короткая позиция = ",iOpen(NULL,PERIOD_D1,1)-iClose(NULL,PERIOD_D1,1));
              int ticket3=OrderSend( Symb,OP_SELL, Lot,Bid,3,Bid+ Dist_SL*Point,Bid- Dist_TP*Point);
             }
         if( ticket2>0 || ticket3>0) // Получилось :)
           {Sleep(5000);//Alert ("Установлен ордер SELL ",ticket2 || ticket3);            
           }
         else
           {int Error1=GetLastError(); // Не получилось :(
            switch( Error1) // Преодолимые ошибки
              {case 129:................................
              }
            switch( Error1) // Критические ошибки
              {case 2 : ..........................
              }
            Alert(GetLastError());return(0);
           }
    }
  }
// дальше я не могу отследить что откуда ?????????????????????????????????????????????????????????
//?????????????????????????????????????????????????????????????????????????????????????????????????
}else
{// Alert("Выход по времени = ",Hour());
return(0);
}
}else
{return(0);}//Alert("Выход по Lot = ",Lot);
 return(0); //Alert ("Скрипт закончил работу -----------------------------");
}
//+------------------------------------------------------------------+

Damn bot doesn't allow to lay out all code, I'll have to cut it. I cut switch() to make it fit.

 

How would I write all available history to a file in the form of these lines

O;H;L;C;volume;MA3;MA5;MA7;MA13; ... and other indicators further

On H1 timeframe?

Thank you

 
snowman647 >> :

How can I write all available history in a file in the form of these strings

O;H;L;C;volume;MA3;MA5;MA7;MA13; ... and other indicators further

On H1 timeframe?

Thank you




//+------------------------- WritingLineInFile() ----------------------------
//| Дописывание строки в конец файла
//+---------------------------------
void WritingLineInFile(string FlName, string Text){
  int file_handle=FileOpen( FlName, FILE_CSV| FILE_READ| FILE_WRITE, " ");
	if ( file_handle>0){
		FileSeek( file_handle,0, SEEK_END);
		FileWrite( file_handle, Text);
		FileClose( file_handle);
	}
	else{
	  Print("Ошибка ",GetLastError()," - Не удалось открыть файл ", FlName);
   }
}
//--------------------------------------------------------------------------- 

This is a user-defined subroutine that adds a text line to the end of the file. It is placed after the start function. At the very start we use it as follows:

 // --------- Генерируем имя файла ------------
  FileName=Symbol()+"_"+DoubleToStr(Day(),0)+"_"+DoubleToStr(Month(),0)+"_"+DoubleToStr(Year(),0)+".txt";
  TextInFile=TimeToStr(TimeCurrent(), TIME_DATE| TIME_SECONDS);
  TextInFile= TextInFile+" "+DoubleToStr(Bid,Digits);
 

Thank you!

Can you also tell me how to arrange to go through all the history?

I have a file that contains H1 data from 1999 to 2009

 

Planning to install a new operating system purely for the tester, who knows which OS has faster tests?

 

Good evening.

Just yesterday I tried MQL5 for the first time. I have a problem with the button. Please advise how to set coordinates of a button, change its colour, set text and how to receive feedback from it. I have tried to use the old version that was published before the MT5 release. Where can I read it? Thank you. :)

 
Patriot писал(а) >>

Good evening.

Just yesterday I tried MQL5 for the first time. I have a problem with the button. Please advise how to set coordinates of a button, change its colour, set text and how to receive feedback from it. I have tried to use the old version that was published before the MT5 release. Where can I read it? Thank you. :)

Go here... Beta-testing of MetaTrader 5 has started!

 
DDFedor >> :

It's this way... Beta testing of MetaTrader 5 has started!


Thank you very much. :)
 
001 писал(а) >>

Planning to install a new operating system purely for the tester, who knows which OS has faster tests?

And anyway, well don't start a new thread on this, will you?

 

XP and the subject is closed...

)))

Reason: