I don't need a subwindow, the indicator should be placed on the price chart as a standard chart
I regard it as an example, and try to understand .
I want the indicator mounted on the chart to have its number, so that the necessary number of copies can be created on the chart using the "Add" button ..... I want to delete one selected by the "cross" button ........ (I don't want to describe them yet))
When an indicator should be added to the main chart window
sub_window
[in] Chart subwindow number.0 means main chart window. To add an indicator to a new window, the parameter must be one more than the index of the last existing window, i.e. equal toCHART_WINDOWS_TOTAL. If the parameter value exceedsCHART_WINDOWS_TOTAL, a new window will not be created, the indicator will not be added.
You cannot add the indicator to OnInit() - since the expert has not yet been formed at this stage. But the function - OnTick() is a sign of complete working of the Expert Advisor.
//+------------------------------------------------------------------+//| 0000.mq5 |//| Copyright 2016, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2016, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"inputint MA_Period=21;
inputint MA_Shift=0;
inputENUM_MA_METHOD MA_Method=MODE_SMA;
//--- variablesint MA_handle=INVALID_HANDLE;
bool first_start=false;
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ intOnInit()
{
Print(__FUNCTION__,", first_start = ",first_start);
MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",MA_Period,MA_Shift,MA_Method,PRICE_CLOSE);
if(MA_handle==INVALID_HANDLE)
return(INIT_FAILED);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| "Tick" event handler function |//+------------------------------------------------------------------+voidOnTick()
{
//---if(!first_start)
{
if(AddIndicator()) //попробуем добавить индикатор на график
first_start=true;
}
}
//+------------------------------------------------------------------+ //| Функция проверки и добавления индикатора на график | //+------------------------------------------------------------------+ bool AddIndicator()
{
//--- сбросим код ошибки ResetLastError();
//--- накладываем индикатор на график int subwindow=0;
PrintFormat("Добавляем индикатор на окно %d графика",subwindow);
if(!ChartIndicatorAdd(0,subwindow,MA_handle))
{
PrintFormat("Не удалось добавить индикатор на окно %d графика. Код ошибки %d",
subwindow,GetLastError());
}
return(true);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//---
}
//+------------------------------------------------------------------+
And rewrite the AddIndicator() function so that it returns false at unsuccessful attempt to add an indicator.
I don't need a subwindow, the indicator should be placed on the price chart as a standard chart
I regard it as an example, and try to understand .
I want the indicator mounted on the chart to have its own number, so that the necessary number of copies can be created on the chart using the "Add" button ..... I want to delete one selected with the "cross" button ........ (there are a lot of fantasies and I don't want to describe them yet))
The indicator can have a name, if you like numbers, let it be a number. However, the number will not be a number but a text. Do you want a custom control panel that allows you to add any indicator number from one or more?
pako: There are four five weeks in a month, today is the fourth week of the month
I see. So he wants to account for weeks of this nature on the 29th of the previous month (Monday, for example) and up to the 31st of the current month (Monday too, for example). It is more than a month. It is not logical to count such weeks. If it isn't, then the week won't be a whole week. Nope, no point....
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello Vladimir.
I must have phrased my question incorrectly.
I don't need a subwindow, the indicator should be placed on the price chart as a standard chart
I regard it as an example, and try to understand .
I want the indicator mounted on the chart to have its number, so that the necessary number of copies can be created on the chart using the "Add" button ..... I want to delete one selected by the "cross" button ........ (I don't want to describe them yet))
When an indicator should be added to the main chart window
sub_window
[in] Chart subwindow number.0 means main chart window. To add an indicator to a new window, the parameter must be one more than the index of the last existing window, i.e. equal toCHART_WINDOWS_TOTAL. If the parameter value exceedsCHART_WINDOWS_TOTAL, a new window will not be created, the indicator will not be added.
You cannot add the indicator to OnInit() - since the expert has not yet been formed at this stage. But the function - OnTick() is a sign of complete working of the Expert Advisor.
And rewrite the AddIndicator() function so that it returns false at unsuccessful attempt to add an indicator.Hello Vladimir.
I must have phrased my question incorrectly.
I don't need a subwindow, the indicator should be placed on the price chart as a standard chart
I regard it as an example, and try to understand .
I want the indicator mounted on the chart to have its own number, so that the necessary number of copies can be created on the chart using the "Add" button ..... I want to delete one selected with the "cross" button ........ (there are a lot of fantasies and I don't want to describe them yet))
bool TimeStart=false;
int hour=12;
//--Фильтр по ремени открытия бара внутри дня
if (TimeStart==true)
{
datetime Open_timePos=iTime(_Symbol,0,0);
MqlDateTime str1;
TimeToStruct(Open_timePos,str1);
str1.hour=hour;
str1.min=0;
str1.sec=0;
datetime start_time=StructToTime(str1);
if (start_time>iTime(_Symbol,0,0))
{
BuyPrIMA=false;
SellPrIMA=false;
}
Can you tell me how to filter by day number and separately by week number in a month? Inside the day I have done this:
He's asking about the week of the month
I've made all three options there. Which one does he want to use as a base, please?
This one?
I did all three options there. Please specify.
There are five to six weeks in the month, today is the fourth week of the month
str.day day of the month
str.day_of_week day
There are four five weeks in a month, today is the fourth week of the month
I've made all three options there. Which one does he want to use as a base, please?
This one?