Questions from Beginners MQL5 MT5 MetaTrader 5 - page 539

 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

comp, 2016.03.23 09:49

How do I know the chart period by ChartID?ChartGetInteger does not allow to do this in one action.

So far I've come up with a crutch solution by saving a template and parsing the period in it.

How to find out normally?

UseChartPeriod

ChartPeriod

Returnsperiod value of the specified chart.

ENUM_TIMEFRAMESChartPeriod(
longchart_id=0// chart ID
);

Parameters

chart_id=0

[Chart ID. 0 means the current chart.

Returned value

Value ofENUM_TIMEFRAMES type. If there is no chart, 0 is returned.

 
Karputov Vladimir:

UseChartPeriod

Thank you.
 

Good afternoon!

How can the status of the one-click trading panel be determined (unfolded or collapsed)?

 
Tell me how to search for questions on the right topic in this beginner's thread. The thread has grown into a huge layer of questions and answers and so it is no longer possible to search manually. If you have already hesitated to ask a question, it may have already been answered here a long time ago, but the search is done throughout the site and not in this particular section "for beginners" ?
 
Alexander:
Tell me how to search for questions on the right topic in this beginner's thread. The thread has grown into a huge layer of questions and answers and so manually searching is no longer possible. Asking a question already hesitates, maybe it has already been answered here a long time ago, and the search is done throughout the site and not in this particular section "for beginners" ?

Type in a google search: search site:https://www.mql5.com/ru/forum/6343

"Searchable" is what you're looking for.

 
Question about µl4 language - Why doesn't the"create object" function work during optimization, when using an object to store data of several variables, it turns out to be 20 times faster than when using the openfail->failride->failclose function, which slows down optimization and testing very much?
 

Good afternoon!

I can't figure out how to process the bars for two hours, say from 3pm to 5pm server time, for the last 250 trading sessions.

Could you please give me a conceptual suggestion?

mql5

 
Stairway_2_7:

Good afternoon!

I can't figure out how to process the bars for two hours, say from 3pm to 5pm server time, for the last 250 trading sessions.

Could you please give me a conceptual suggestion?

mql5

Use the functions with time query

int  CopyOpen( 
   string           symbol_name,     // имя символа 
   ENUM_TIMEFRAMES  timeframe,       // период 
   datetime         start_time,      // с какой даты 
   datetime         stop_time,       // по какую дату 
   double           open_array[]     // массив для копирования цен открытия 
   );
 

Sergey,

thanks for the reply!

For my task it is more convenient to

void OnStart()

{

datetime start =StringToTime("2016.03.25 15:00");

datetime stop =StringToTime("2016.03.25 15:55");

MqlRates rates[];

ArraySetAsSeries(rates,true);

int copied=CopyRates(_Symbol,PERIOD_M5,start,stop,rates);

if(copied>0)

{

Print("Copied bars: "+copied);

string format="open = %G, high = %G, low = %G, close = %G, volume = %d";

string out;

int size=fmin(copied,10);

for(int i=0;i<size;i++)

{

out=i+": "+TimeToString(rates[i].time);

out=out+"+StringFormat(format,

rates[i].open,

rates[i].high,

rates[i].low,

rates[i].close,

rates[i].tick_volume);

Print(out);

}

}

else Print("Failed to get historical data on symbol ",Symbol());

}

How can I remove Saturdays and Sundays?

More precisely, do a similar operation for the last, say, 250 trading days?

 
Stairway_2_7:

Sergey,

thanks for the reply!

For my task it is more convenient to

void OnStart()

{

datetime start =StringToTime("2016.03.25 15:00");

datetime stop =StringToTime("2016.03.25 15:55");

MqlRates rates[];

ArraySetAsSeries(rates,true);

int copied=CopyRates(_Symbol,PERIOD_M5,start,stop,rates);

if(copied>0)

{

Print("Copied bars: "+copied);

string format="open = %G, high = %G, low = %G, close = %G, volume = %d";

string out;

int size=fmin(copied,10);

for(int i=0;i<size;i++)

{

out=i+": "+TimeToString(rates[i].time);

out=out+"+StringFormat(format,

rates[i].open,

rates[i].high,

rates[i].low,

rates[i].close,

rates[i].tick_volume);

Print(out);

}

}

else Print("Failed to get historical data on symbol ",Symbol());

}

How can I remove Saturdays and Sundays?

To be more precise, how to make a similar operation for the last, say, 250 trading days?

Try to work with this structure

struct MqlDateTime 
  { 
   int year;           // год 
   int mon;            // месяц 
   int day;            // день 
   int hour;           // час 
   int min;            // минуты 
   int sec;            // секунды 
   int day_of_week;    // день недели (0-воскресенье, 1-понедельник, ... ,6-суббота) 
   int day_of_year;    // порядковый номер в году (1 января имеет номер 0) 
  };
Reason: