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

 
sergeev писал(а) >>

make it an Expert instead of a script and control the execution time of the script function code in the Expert. The time has come - execute the script code.

I understood from this phrase that your terminals are closed. I am answering you - the script cannot start the terminal itself.

As you write it, that's how it is understood. If this is not what you mean, then explain yourself more clearly.

What's the value of the idea? If you needed it that badly, you wouldn't have had a proger set it up a long time ago... it's for you personally.

1. Copy the contents of the script.

2. Create a new EA using MetaEditor

3. Insert the code of the script

4. How to add the function of working by time and where to insert it (I am not a programmer)

I need the function work time from 9-00 to 9-01

The script code to be edited: (Thanks in advance to all who will help)

#property copyright "Kim Igor V. aka KimIV"
#property link "https://www.mql5.com/go?link=http://www.kimiv.ru/"
#property show_inputs

#import "kernel32.dll"
int GetUserDefaultLCID();
int GetLocaleInfoA(
int Locale, // locale identifier
int LCType, // type of information
string lpLCData, // address of buffer for information
int cchData // size of buffer
);
#import

//+------ External parameters of the script -------------------------------------------+
extern bool bCommission = False; //Discharge commissions
extern bool bSwap = True; // Unload swaps
extern bool bComment = True; // Unload comments
extern bool bMagic = True; // Unload MagicNumber

// LCTYPE Constants
#define LOCALE_SDECIMAL 0x000E // Characters used for the decimal separator.

//+----------------------------------------------------------------------------+
//| script program start function |
//+----------------------------------------------------------------------------+
void start() {
int dg, i, k=OrdersHistoryTotal();
string FileName=DoubleToStr(AccountNumber(), 0)+".csv"; st;

FileDelete(FileName);
st="Ticket;Open Time;Type;Lots;Item;Price;SL;TP;Close Time;Price";
if (bCommission) st=st+";Commission";
if (bSwap) st=st+";Swap";
st=st+";Profit"; if (bSwap) st=st+";Profit;
if (bMagic) st=st+";Magic";
if (bComment) st=st+";Comment";
WritingLineInFile(FileName, st);
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderType()<2) {
dg= MarketInfo(OrderSymbol(), MODE_DIGITS);
st= DoubleToStr(OrderTicket(), 0)+";";
st=st+TimeToStr(OrderOpenTime(), TIME_DATE|TIME_MINUTES)+";";
st=st+GetNameOP(OrderType())+";";
st=st+DoubleToStrLocale(OrderLots(), 2)+";";
st=st+OrderSymbol()+";";
st=st+DoubleToStrLocale(OrderOpenPrice(), dg)+";";
st=st+DoubleToStrLocale(OrderStopLoss(), dg)+";";
st=st+DoubleToStrLocale(OrderTakeProfit(), dg)+";";
st=st+TimeToStr(OrderCloseTime(), TIME_DATE|TIME_MINUTES)+";";
st=st+DoubleToStrLocale(OrderClosePrice(), dg)+";";
if (bCommission) st=st+DoubleToStrLocale(OrderCommission(), 2)+";";
if (bSwap) st=st+DoubleToStrLocale(OrderSwap(), 2)+";";
st=st+DoubleToStrLocale(OrderProfit(), 2)+";";
if (bMagic) st=st+DoubleToStr(OrderMagicNumber(), 0)+";";
if (bComment) st=st+OrderComment()+";";
WritingLineInFile(FileName, st);
}
Comment("Read: ",i+1," from ",k);
}
}
Comment("File written: ",FileName);
}

//+----------------------------------------------------------------------------+
//| Converts a numeric value to a string with the system |
//| separator between integer part and fractional part. |
//| Parameters: |
//| v - number of type double |
//| d - number of digits after the decimal point |
//+----------------------------------------------------------------------------+
string DoubleToStrLocale(double v, int d) {
if (d<0) d=0;
if (d>8) d=8;

string se=GetUserLocale(LOCALE_SDECIMAL), st=DoubleToStr(v, d);
if (se!=".") st=StrTran(st, ".", se);

return(st);
}

//+----------------------------------------------------------------------------+
//| Return name of the trade operation |
//| Parameters: |
//| op - trade operation identifier |
//+----------------------------------------------------------------------------+
string GetNameOP(int op) {
switch (op) {
case OP_BUY : return("Buy");
case OP_SELL : return("Sell");
case OP_BUYLIMIT : return("Buy Limit");
case OP_SELLLIMIT : return("Sell Limit");
case OP_BUYSTOP : return("Buy Stop");
case OP_SELLSTOP : return("Sell Stop");
default : return("Unknown Operation");
}
}

//+----------------------------------------------------------------------------+
//| Return of user regional settings. |
//| Parameters: |
//| LCType - type of regional setting (LCTYPE Constant) |
//+----------------------------------------------------------------------------+
string GetUserLocale(int LCType) {
int loc=GetUserDefaultLCID();
string str=" ";

GetLocaleInfoA(loc, LCType, str, 64);

return(str);
}

//+----------------------------------------------------------------------------+
//| substitute substring |
//| Parameters: |
//| str - text string, in which the substitution is made |
//| strfrom - substring to be replaced |
//| strto - substituting substring |
//+----------------------------------------------------------------------------+
string StrTran(string str, string strfrom, string strto) {
int n;
string outstr="", tempstr;

for (n=0; n<StringLen(str); n++) {
tempstr=StringSubstr(str, n, StringLen(strfrom));
if (tempstr==strfrom) {
outstr=outstr+strto;
n=n+StringLen(strfrom)-1;
} else outstr=outstr+StringSubstr(str, n, 1);
}
return(outstr);
}

//+----------------------------------------------------------------------------+
//| Write string to file |
//| Parameters: |
//| FileName - file name ||
//| text - string ||
//+----------------------------------------------------------------------------+
void WritingLineInFile(string FileName, string text) {
int file_handle=FileOpen(FileName, FILE_READ|FILE_WRITE, " ");

if (file_handle>0) {
FileSeek(file_handle, 0, SEEK_END);
FileWrite(file_handle, text);
FileClose(file_handle);
}
}
//+----------------------------------------------------------------------------+

 
Hi, could you tell me which folder to put the fonts in in MT4?
 
%windir% \ fonts
 

for baltik


string NeedTime="9:00";
datetime time0=0;

//----------------------------------------------------------------------------
void start() 
{

 if ( time0>=StrToTime( NeedTime)) return; // если сегодня уже выполняли код
 if (TimeCurrent()<=StrToTime( NeedTime)) return; // если требуемое время ещё не наступио
 time0=TimeCurrent(); // иначе запоминаем время

// и делаем то что надо

// бла бла бла остальной код

This thread is for people who are learning to program, not for people who are asking you to write for them.

 
sergeev >>:
%windir% \ fonts

Can you keep it simple, I don't understand it... what kind of folder is it? or what is it anyway?

 
chepikds >>:

можно как-то попроще, я ничего не понял... это что за папка? или что это вообще такое?


Actually, the question "which folder to put fonts in MT4" is not very clear either. Please explain in Russian. :)

Fonts are not stored in the terminal. fonts are handled by the operating system.

 
sergeev >>:

вообще-то вопрос "в какую папку вставить шрифты в МТ4" тоже не очень понятен.

в терминале никакие шрифты не хранятся. шрифтами занимается операционная система.

OK, I'll try putting it in the operating system...

 
Thank you sergeev ,it's working.
 
sergeev писал(а) >>

for baltik

This thread is for people who are learning to program, not for people who are asking you to write for them.

Thank you

I will learn :)

 

hello. i wrote a simple EA, using examples from the tutorial. the EA should signal when the price moves out of the range, which consists of two MAs. i.e. if a bar opened in the range and started rising and its current price moved out of it, then it beeps. the same goes for down. but the problem is that i cannot figure out if i do this

if (Bid > MA1 || Bid < MA2) // Checking the range pass
{
Alert("Price is outside the range.");// Message
}

If the price is above the range, then the Expert Advisor will alert me, but if I do this:

if (Bid > MA1 && Fact_Up==true) // Check upwards pass
{
Fact_Dn=true; // Report price above MA1
Fact_Up=false; // Not report price below MA1
Alert("Price is above range.");// Message
}
//--------------------------------------------------------------------
if (Bid < MA2 && Fact_Dn==true) // Check down pass
{
Fact_Up=true; // Report price below MA2
Fact_Dn=false; // Not report price above MA2
Alert("Price is below range.");// Message
}

If this message is shown, then it is not clear at all, when it gives a signal - sometimes it gives a signal, sometimes it doesn't.

I can't figure out what the "Fact_Up==true" is and why it's needed.