Is there anyway to disable an indicator temporarily via a checkbox

Custom indicators, trading strategies, data export and recording and more...
dmavro
Posts: 52
Joined: Thu Sep 24, 2020 9:20 pm
Been thanked: 1 time

Is there anyway to disable an indicator temporarily via a checkbox

Post by dmavro » Wed Apr 14, 2021 4:15 pm

Hey guys,

I was wondering if there is a way to make a group of indicator lines stop displaying on Bookmap temporarily. My goal is to be able to uncheck a checkbox or something along those lines that will stop displaying the lines but I need to be able to recheck the checkbox and have all the lines continue plotting all the previous data that was there beforehand(not start over again from scratch like when you disable and reenable an addon). Im looking for something similar to what the newest "Stops&Icebergs On-Chart" addon has for disabling either the Stops or Icebergs. One thing though, all my data for the indicators is acquired from a CSV file so im not sure if that factor will allow me to do this.  I had one idea that might work but not sure... Figured i could rewrite the indicator that writes data to my CSV file so it stores all data for the day with timestamps that way it could be reread by bookmap. Then i thought i could change my addon so it uses  'IndicatorModifiable" and read the csv data into the addon using the timestamps. Not sure if that is a valid approach but Im really hoping there is something i can do directly in Bookmap to avoid all of that. 


Thanks in advance,

Dean 

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Is there anyway to disable an indicator temporarily via a checkbox

Post by Svyatoslav » Wed Apr 14, 2021 5:42 pm

Your idea with IndicatorModifiable should work, and that's probably the easiest route if you need programmatic control over line visibility. You could use a few tricks in simplified API (I can explain if you want me to), or you could use core API (more complicated, but gives you complete control).

However note, that lines visibility can be controlled from the bookmap UI without writing any extra code. You just create a line and populate it, that's it. Then when you need to hide it you can use an icon that looks like a cog on the bottom panel near the widgets area. It opens a popup where you can show/hide each widget and each indicator line.

dmavro
Posts: 52
Joined: Thu Sep 24, 2020 9:20 pm
Been thanked: 1 time

Re: Is there anyway to disable an indicator temporarily via a checkbox

Post by dmavro » Fri Apr 16, 2021 3:03 pm

Svyatoslav wrote:
Wed Apr 14, 2021 5:42 pm
Your idea with IndicatorModifiable should work, and that's probably the easiest route if you need programmatic control over line visibility. You could use a few tricks in simplified API (I can explain if you want me to), or you could use core API (more complicated, but gives you complete control).

However note, that lines visibility can be controlled from the bookmap UI without writing any extra code. You just create a line and populate it, that's it. Then when you need to hide it you can use an icon that looks like a cog on the bottom panel near the widgets area. It opens a popup where you can show/hide each widget and each indicator line.
Svyatoslav,

I didnt even think to use the widget control panel like you mentioned. Going to use that approach for now until i decide what im going to do. If you have the time, then Im curious and would like to know about the tricks in simplified API that you mentioned.  


Thanks,
Dean 
 

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Is there anyway to disable an indicator temporarily via a checkbox

Post by Svyatoslav » Fri Apr 16, 2021 6:16 pm

In short, the tricks would be around reloading indicator and/or erasing data. Or using parts of core API. I believe you have suggested one of those yourself. So, what you could do is (from easy to hard):
- erasing data, then re-adding it when you want to show it again (using modifiable indicator)
- calling "reload" api method so you can avoid registering the indicator altogether during the initialization. Then calling it again when user reenables the checkbox
- directly using Layer1ApiUserMessageModifyIndicator to register an indicator and rendering the line yourself. That's a core API message, but you can send it from simplified API too if you want. This way you'd have full control over adding/hiding the indicator line.

In all those cases you have to store data separately though in order for it to be available for you later (to re-add it when indicator is reenabled or to feed it on demand in last option).

dmavro
Posts: 52
Joined: Thu Sep 24, 2020 9:20 pm
Been thanked: 1 time

Re: Is there anyway to disable an indicator temporarily via a checkbox

Post by dmavro » Thu Apr 22, 2021 4:01 pm

Thank you for the explanation!

Post Reply