I've tried everything you suggested, twisted and turned, but it still paints lines in one colour in MT5. And in MT4 it paints lines normally, and without delays.
I guess I have not tried everything.
Alexey Viktorov:
It is very likely that after renaming an object it is still unavailable for reference to it. You can try putting ChartRedraw after renaming. If it doesn't help, we will have to build the sequence in some other way.
ps; Another option: first repaint with the name sparam and then rename it.
For some reason, event CHARTEVENT_OBJECT_CREATE counts immediately after the rat touches the chart, not after finishing creation of object. And prices of different ends of the fuse turn out to be the same. So you have to repaint after the object is created.
And one more remark: do you paint levels or main line of the wick?
Here are three variants:
One.
bool endCreate;
string newName;
/*******************Expert initialization function*******************/intOnInit()
{
ChartSetInteger(ChartID(), CHART_EVENT_OBJECT_CREATE, true);
return(INIT_SUCCEEDED);
}/******************************************************************//************************Expert tick function************************/voidOnTick()
{
if(endCreate)
{
double Level_0= ObjectGetDouble(0, newName, OBJPROP_PRICE, 0);
double Level_1= ObjectGetDouble(0, newName, OBJPROP_PRICE, 1);
if(Level_0 > Level_1)
ObjectSetInteger(0, newName, OBJPROP_LEVELCOLOR, 1, clrDeepSkyBlue);
elseObjectSetInteger(0, newName, OBJPROP_LEVELCOLOR, 1, clrYellow);
endCreate = false;
}
}/******************************************************************//***********************OnChartEvent function************************/voidOnChartEvent(constint id, // идентификатор событияconstlong& lparam, // параметр события типа longconstdouble& dparam, // параметр события типа doubleconststring& sparam // параметр события типа string
)
{
if(id == CHARTEVENT_OBJECT_CREATE)
{
ulong timeCreate = ObjectGetInteger(0, sparam, OBJPROP_CREATETIME); // получим время создания объекта
newName = "Fibo "+string(timeCreate); // сформируем новое имя объектаObjectSetString(0, sparam, OBJPROP_NAME, newName); // переименуем объект
endCreate = true;
}
}/******************************************************************/
Second.
/*******************Expert initialization function*******************/intOnInit()
{
ChartSetInteger(ChartID(), CHART_EVENT_OBJECT_CREATE, true);
return(INIT_SUCCEEDED);
}/******************************************************************//************************Expert tick function************************/voidOnTick()
{
}/******************************************************************//***********************OnChartEvent function************************/voidOnChartEvent(constint id, // идентификатор событияconstlong& lparam, // параметр события типа longconstdouble& dparam, // параметр события типа doubleconststring& sparam // параметр события типа string
)
{
string newName;
if(id == CHARTEVENT_OBJECT_CREATE)
{
ulong timeCreate = ObjectGetInteger(0, sparam, OBJPROP_CREATETIME); // получим время создания объекта
newName = "Fibo "+string(timeCreate); // сформируем новое имя объектаObjectSetString(0, sparam, OBJPROP_NAME, newName); // переименуем объект
}
if(id == CHARTEVENT_OBJECT_DRAG)
{
double Level_0= ObjectGetDouble(0, newName, OBJPROP_PRICE, 0);
double Level_1= ObjectGetDouble(0, newName, OBJPROP_PRICE, 1);
if(Level_0 > Level_1)
ObjectSetInteger(0, newName, OBJPROP_LEVELCOLOR, 1, clrDeepSkyBlue);
elseObjectSetInteger(0, newName, OBJPROP_LEVELCOLOR, 1, clrYellow);
}
}/******************************************************************/
Three.
/*******************Expert initialization function*******************/intOnInit()
{
ChartSetInteger(ChartID(), CHART_EVENT_OBJECT_CREATE, true);
return(INIT_SUCCEEDED);
}/******************************************************************//************************Expert tick function************************/voidOnTick()
{
}/******************************************************************//***********************OnChartEvent function************************/voidOnChartEvent(constint id, // идентификатор событияconstlong& lparam, // параметр события типа longconstdouble& dparam, // параметр события типа doubleconststring& sparam // параметр события типа string
)
{
if(id == CHARTEVENT_OBJECT_DRAG)
{
ulong timeCreate = ObjectGetInteger(0, sparam, OBJPROP_CREATETIME); // получим время создания объектаstring newName = "Fibo "+string(timeCreate); // сформируем новое имя объектаObjectSetString(0, sparam, OBJPROP_NAME, newName); // переименуем объектdouble Level_0= ObjectGetDouble(0, newName, OBJPROP_PRICE, 0);
double Level_1= ObjectGetDouble(0, newName, OBJPROP_PRICE, 1);
if(Level_0 > Level_1)
ObjectSetInteger(0, newName, OBJPROP_LEVELCOLOR, 1, clrDeepSkyBlue);
elseObjectSetInteger(0, newName, OBJPROP_LEVELCOLOR, 1, clrYellow);
ChartRedraw();
}
}/******************************************************************/
//--- найдем максимальное и минимальное значение графикаdouble max_price=ChartGetDouble(0,CHART_PRICE_MAX);
double min_price=ChartGetDouble(0,CHART_PRICE_MIN);
//--- определим шаг изменения цены и заполним массивdouble step=(max_price-min_price)/accuracy;
for(int i=0;i<accuracy;i++)
price[i]=min_price+i*step;
//--- определим точки для рисования линииint d1=InpDate1*(bars-1)/100;
int p1=InpPrice1*(accuracy-1)/100;
//--- количество видимых баров в окне графикаint bars=(int)ChartGetInteger(0,CHART_VISIBLE_BARS);
//--- размер массива priceint accuracy=1000;
//--- массивы для хранения значений дат и цен, которые будут использованы//--- для установки и изменения координат точек привязки линииdatetime date[];
double price[];
//--- выделение памятиArrayResize(date,bars);
ArrayResize(price,accuracy);
//--- заполним массив датResetLastError();
if(CopyTime(Symbol(),Period(),0,bars,date)==-1)
{
Print("Не удалось скопировать значения времени! Код ошибки = ",GetLastError());
return;
}
//--- заполним массив цен//--- найдем максимальное и минимальное значение графикаdouble max_price=ChartGetDouble(0,CHART_PRICE_MAX);
double min_price=ChartGetDouble(0,CHART_PRICE_MIN);
//--- определим шаг изменения цены и заполним массивdouble step=(max_price-min_price)/accuracy;
for(int i=0;i<accuracy;i++)
price[i]=min_price+i*step;
//--- определим точки для рисования линииint d1=InpDate1*(bars-1)/100;
int d2=InpDate2*(bars-1)/100;
int p1=InpPrice1*(accuracy-1)/100;
int p2=InpPrice2*(accuracy-1)/100;
//--- создадим линию трендаif(!TrendCreate(0,InpName,0,date[d1],price[p1],date[d2],price[p2],InpColor,InpStyle,
InpWidth,InpBack,InpSelection,InpRayLeft,InpRayRight,InpHidden,InpZOrder))
{
return;
}
The trend lines are drawn at 2 points, it's either the price data or the data of another indicator, the example of drawing by fractals, which, by the way, is familiar to you)
cm BASKET Советник управляющий счетом. Показывает какие пары инструментов сейчас торгуются на данном счете. Показывает прибыль полученную по каждой паре за определенное время. Помогает переключаться между множества открытых окон... Virtual Trailing Stop 2
Trend lines are drawn at 2 points, this is either price data or data from another indicator, an example of drawing by fractals, which, by the way, is familiar to you)
For some reason, the CHARTEVENT_OBJECT_CREATE event counts immediately after the rat touches the chart, not after the end of object creation. And prices of different ends of the fuse turn out to be the same. So, we have to repaint after the object has been created.
How have you determined this? Logically?
And another remark: do you paint levels or the main line of the fib?
I tried repainting trend lines in different variants))))
Here are three variants:
One.
Second.
The Third.
Thank you very much for those!!! I may learn to think logically, based on your examples))))
How long have you been in trading? I've been doing it for 12 years now)))
Thank you very much for the options!!! I'll use your examples and learn to think logically))))
I mean, how long have you been trading? I've been doing it for 12 years now.)
I'm not always so "kind". I'm not always so "kind", only during attacks... So there's not much to learn from my examples. I'm in trading almost as long.
I'm not always so "kind". Only during attacks... So there's not much to learn from my examples. I'm about the same in trading.
I don't know, I'm learning the methods and techniques of programming better by examples. I wish MQL5 had such a tutorial like MQL4 where the robot is explained step by step using included files.
So you already know the essence of market fluctuations? It seems to me that I have already learned)))) I just need to ask it, because I can work with it for a certain time, and then I snap and create a mess)))))) But now I understand any asset)))) I especially like the S&P, it is technical and dynamic))
Well, combine them, you can create many different objects in one indicator)
I wanted to do it that way. I've been trying to do it for a week now, but it just wouldn't work.
- It seems to be better in the second indicator - you cannot see past points and the lines themselves, there are only those points and levels that are used to determine entries into the market.
----------------
these two indicators are one (this is my draft - I didn't change the names of 4 indicators in it)
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.
I've tried everything you suggested, twisted and turned, but it still paints lines in one colour in MT5. And in MT4 it paints lines normally, and without delays.
I guess I have not tried everything.
It is very likely that after renaming an object it is still unavailable for reference to it. You can try putting ChartRedraw after renaming. If it doesn't help, we will have to build the sequence in some other way.
ps; Another option: first repaint with the name sparam and then rename it.For some reason, event CHARTEVENT_OBJECT_CREATE counts immediately after the rat touches the chart, not after finishing creation of object. And prices of different ends of the fuse turn out to be the same. So you have to repaint after the object is created.
And one more remark: do you paint levels or main line of the wick?
Here are three variants:
One.
Second.
Three.
how to organise an algorithm in one indicator to take points and transfer them to another buffer.
- To draw the trend lines. (as on the picture)
-----------------------------------------
I tried everything with gut feeling, they are drawn but in strange places.
-----------------------------------------------------------------------------------------------------
I have attached the indicator, it works, but I cannot adjust these lines.
I cannot do it. Maybe someone can direct me to the articles about binding points of the trend line.
-- I cannot draw them, it is not clear at what points.
---------------------------------------------------------
something like that, maybe?
-------------------
am i on the right track ???
Maybe someone can direct me to articles about trendline points.
-- all I can do now is draw them, it's not clear at which points.
---------------------------------------------------------
something like that, maybe?
-------------------
am i on the right track ???
The trend lines are drawn at 2 points, it's either the price data or the data of another indicator, the example of drawing by fractals, which, by the way, is familiar to you)
https://www.mql5.com/ru/code/29210
Trend lines are drawn at 2 points, this is either price data or data from another indicator, an example of drawing by fractals, which, by the way, is familiar to you)
https://www.mql5.com/ru/code/29210
I wanted to do it with one indicator, but it didn't work.
- I had to do it with two indicators.
That's what I did.
---------------------------
I forgot to say thank you! - Thank you!!!
I wanted to do it in one Indicator, but it didn't work, but I've done it in this one, which you suggested.
- so I had to do it with two Indicators.
That's how it worked.
---------------------------
I forgot to say thank you! - Thank you!!!
Well combine them, you can create many different objects in one indicator)
Apparently I haven't tried everything.
For some reason, the CHARTEVENT_OBJECT_CREATE event counts immediately after the rat touches the chart, not after the end of object creation. And prices of different ends of the fuse turn out to be the same. So, we have to repaint after the object has been created.
How have you determined this? Logically?
And another remark: do you paint levels or the main line of the fib?
I tried repainting trend lines in different variants))))
Here are three variants:
One.
Second.
The Third.
Thank you very much for those!!! I may learn to think logically, based on your examples))))
How long have you been in trading? I've been doing it for 12 years now)))
Thank you very much for the options!!! I'll use your examples and learn to think logically))))
I mean, how long have you been trading? I've been doing it for 12 years now.)
I'm not always so "kind". I'm not always so "kind", only during attacks... So there's not much to learn from my examples. I'm in trading almost as long.
I'm not always so "kind". Only during attacks... So there's not much to learn from my examples. I'm about the same in trading.
I don't know, I'm learning the methods and techniques of programming better by examples. I wish MQL5 had such a tutorial like MQL4 where the robot is explained step by step using included files.
I am in trading for almost as long.
So you already know the essence of market fluctuations? It seems to me that I have already learned)))) I just need to ask it, because I can work with it for a certain time, and then I snap and create a mess)))))) But now I understand any asset)))) I especially like the S&P, it is technical and dynamic))
Well, combine them, you can create many different objects in one indicator)
I wanted to do it that way. I've been trying to do it for a week now, but it just wouldn't work.
- It seems to be better in the second indicator - you cannot see past points and the lines themselves, there are only those points and levels that are used to determine entries into the market.
----------------
these two indicators are one (this is my draft - I didn't change the names of 4 indicators in it)