Page 1 of 1

Variable Declaration on MouseClickEvent

Posted: Dec 03 2022
by Largo
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);

Re: Variable Declaration on MouseClickEvent

Posted: Dec 05 2022
by ABC
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);

Re: Variable Declaration on MouseClickEvent  [SOLVED]

Posted: Dec 05 2022
by Largo
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