Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 08:04:42 +0000



Post From: Custom Study - performing code once per bar

[2013-04-29 19:20:41]
joshtrader - Posts: 439
I am using some code to draw a horizontal line near the last bar on the chart. I would like to update the line only once per new bar, not every tick, for efficiency reasons.

But, if I surround the code inside a check for sc.GetBarHasClosedStatus(), what happens is that if I switch time frames or settings and the chart reloads, the code waits until the bar has closed to draw the line. After that, it updates on each new bar and it is fine. But if I switch time frames, I have no line until the bar closes. So I would like the line to draw immediately, and only then switch to updating every bar. I can't think of a way to do this--do you have a suggestion?

As a second question, if I want to hide the drawings in the study I will have to know whether the current study is visible and hide them manually (I would guess so anyway), and I suppose the GetStudyVisibilityState() function you are adding will make this possible; however, how do I know internally the ID of my own study?
Date Time Of Last Edit: 2013-04-29 19:59:35