Variable Declaration on MouseClickEvent  [SOLVED]

Questions about MultiCharts and user contributed studies.
Largo
Posts: 6
Joined: 07 Sep 2018
Has thanked: 1 time
Been thanked: 1 time

Variable Declaration on MouseClickEvent

Postby Largo » 03 Dec 2022

Hello,

out of despair I seek help here- I tried and searched a lot.

I declare a Variable with Ctrl+Mouseclick (which works just fine) and store that value.

Problem is, if I left-click (NOT a ctrl-click, normal left-click) on the chart after I have Ctrl-clicked, this value resets. Why is that and how can I store that value in my variable (or anywhere else)?

Code: Select all

[ProcessMouseEvents = True]; variables: testvar (0); if (MouseClickCtrlPressed = True) then begin testvar = MouseClickBarNumber; end; print(MouseClickCtrlPressed," ",testvar);

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Variable Declaration on MouseClickEvent

Postby ABC » 05 Dec 2022

Largo,

declaring your variable as intrabarpersist should help in your case. Currently it will revert to the prior bar's value on the next code calculation, which might be what you observe as "this value resets".

Regards,

ABC
Hello,

out of despair I seek help here- I tried and searched a lot.

I declare a Variable with Ctrl+Mouseclick (which works just fine) and store that value.

Problem is, if I left-click (NOT a ctrl-click, normal left-click) on the chart after I have Ctrl-clicked, this value resets. Why is that and how can I store that value in my variable (or anywhere else)?

Code: Select all

[ProcessMouseEvents = True]; variables: testvar (0); if (MouseClickCtrlPressed = True) then begin testvar = MouseClickBarNumber; end; print(MouseClickCtrlPressed," ",testvar);

Largo
Posts: 6
Joined: 07 Sep 2018
Has thanked: 1 time
Been thanked: 1 time

Re: Variable Declaration on MouseClickEvent  [SOLVED]

Postby Largo » 05 Dec 2022

Hi ABC,

funny thing is, I stumbled upon that advice of yours from 2012 in this thread and I couldn't for the live of it get it to work. Since you replied I decided to give it another shot and it worked! Don't know why now, but it's solved- thank you!

And since you're here: Thanks also for the content on your website. Learned a lot there back in the days.

Schöne Grüße nach Hamburg,

Largo


Return to “MultiCharts”