Indicator keeps refreshing
Indicator keeps refreshing
14 Apr 2020, 12:15
Hi everyone,
i have coded my custom indicator that basically draws and removes horizontal lines after pressing buttons that i placed directly on the chart.
The code is ok, but the problem is that when I change timeframe or reconnect to the platform, i think the indicator calls the initialize method and updates itself by redrawing everything, even those lines that I had disabled.
I want to call it one time and not everytime it want.
How to solve this ? Thanks
Replies
sessialessio
14 Apr 2020, 13:05
RE:
PanagiotisCharalampous said:
Hi sessialessio,
By design, when a chart is refreshed for any reason, the indicator is reinitialized. If you want to avoid some part of the code being executed when the indicator is initialized, you will need to implement your own logic that will keep track of the indicator state e.g. write the state in a file.
Best Regards,
Panagiotis
Thank you for the answer, i'm quite new to coding calgo, is there a guide or something to do what you suggested ?
@sessialessio
PanagiotisCharalampous
14 Apr 2020, 14:41
Hi sessialessio,
Not really. It is a general suggestion to a general question. Trying to become more specific, save in a file the information you need in order to make a decision if an indicator needs to be reinitialized or not e.g. if objects have been drawn or if they have to be drawn again. But you are the one who knows what needs to be done exactly. If you have more specific questions, I would be happy to give more specific answers.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
14 Apr 2020, 12:52
Hi sessialessio,
By design, when a chart is refreshed for any reason, the indicator is reinitialized. If you want to avoid some part of the code being executed when the indicator is initialized, you will need to implement your own logic that will keep track of the indicator state e.g. write the state in a file.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous