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

 
Jahspear писал(а) >>

Comment("Sample text" );

Hi all, here is the comment displayed by the EA. Then you disconnect the EA from the chart, but the comment remains. I understand that we have to make the comment an object and then prescribe deleting this object in deinit. Theoretically it's clear, but in practice, not so much. Professionals, sketch a code template, how to do this, please.

int deinit(){
   Comment("");
   return(0);
}
 
Vinin >>:

Thank you! It really does remove it. But immediately, with the arrival of a new tick. Not when you delete the EA. How do I do it right?

 

Afternoon.

I have applied a MA to a CCI and if I look up its value in the iMA, I get the value from the chart.

I don't know how to access this MA and get its value from this CCI instead of from the chart, I decided to do it by calculation.

I built the following script to check it. Supposedly it should output five matching pairs of CCI and simple MA values on the CCI.
int start()
{
int Period_CCI=18;
int Period_MA=9;
double MApoCCI;
double ind_CCI,ind_CCI_2;
double Sum_CCI;
int k=1;
for (k=1;k<5;k++)
{
for (int i=1+k;i<Period_MA;i++)
{
ind_CCI= iCCI(Symbol(),0,Period_CCI,PRICE_TYPICAL,i);
Sum_CCI=Sum_CCI+ind_CCI;
}
MApoCCI=Sum_CCI/Period_MA;
ind_CCI_2= iCCI(Symbol(),0,Period_CCI,PRICE_TYPICAL,k);
Alert("MA by CCCI "+k+" ="+MApoCCI);
Alert("CCCI "+k+" ="+ind_CCI_2);
Sum_CCI=0;
}
//----
return(0);
}

It outputs pairs, but gives the MA values on CCI that do not coincide with the value of MA taken by hovering the cursor over

to the corresponding hour on the MA line in the CCI window, the CCI values in this case correspond to the chart line.

Who knows why there is a difference in MA values and is it possible to get MA values from CCI in an easier way than I am trying to do?

 
Vekker >>:


Кто знает почему разница в значениях МА ...?.

Because you have an error in your code.

correct

for (int i=1+k;i<Period_MA+k;i++)
{
...
}
and use the SRC button to insert the code.
 
alsu писал(а) >>

Because you have an error in your code.

correct

Corrected it without figuring out what for - put it aside for later, if all goes well. MA value has changed, but again not the same as on the line.

I ran the script on GBPCHF on the day pair.

The calculation gives 45.62145966, from the line, calculated by Simple, it reads 62.6442.

This is embarrassing, but what is it?

 
Jahspear >>:

Спасибо! Действительно удаляет. Но сразу, с приходом нового тика. А не когда удаляешь советник. А как сделать правильно?

How did you achieve this? Deinit is triggered once at shutdown and is not executed post facto. You may have inserted part of the code into start and deinit is a separate function that should be between init and start.

 
granit77 >>:

Как Вы этого добились? deinit срабатывает один раз при завершении работы и не исполняется потиково. Возможно, Вы вставили часть кода в start, а deinit - это отдельная функция, которая должна стоять между init и start.

I don't know myself) Now I tried again, with a clean chart window, it worked. So this comment was interrupted by a comment from another indicator.

 
Vekker >>:

Исправил, не разобираясь для чего - отложил на потом, если все пойдет. Значения МА поменялось, но снова не такое, как на линии.

Прогнал скриптик на паре GBPCHF на дневке.

расчет дает 45,62145966, с с линии, расчитанной по "Simple" снимается 62,6442

Стыдно, но кнопкой SRC - это как?

look for more logical errors.


SRC it is:


 

Hello, I decided to study MQL4 and started working with arrays. When I try to output an element Time[] I get the value 1264149780 instead of 2006.11.01 14:35, or maybe 1264149780 is a coordinate?

 
alsu писал(а) >>

look for more logical errors.

SRC it is:

Thanks for the button! You live and learn, and it's bad for the clueless.