I ran into a problem when developing further SwingRays2 here on futures.io (formerly BMT). The problem: I need one indicator to make an Int value public. So I write SharingIndi, which has a private int and the value of this int is shown to the rest of the world.
Now I want to see whether those CurrBar values are really accesible from outside, so I write another indi.
and running both on the same chart reveals that Indi.CurrBar returns 0 all the time. Namely, the output is like
What am I doing wrong? Support does not help despite I have a live license...Attached are both indis.
Many thanks for any hint,
I have imported this zip, and it appears to be working as expected on my end. Are you refreshing your output window? Otherwise the call is proper and the output is as expected.
You have an if statement in the SharingIndi which states to return(quit) if the CurrentBar < 5. You have 5 examples listed. What was the 6th bar output? With this statement intact, the first 5 bars will return 0 since it never gets to the currBar calculation and hence, any reference to the Indi.CurrBar will return 0 WHILE CurrentBar < 5.
Any time you reference something in one indicator from within another, the conditions set within that reference indicator have to be met before variables will be anything other than what they are set to during the Variable or Initialize region.
What you are seeing is the back-data on your data series "Days to load" being ran through the indicator. As these contain no real bar update calls they get fed through your indicator without meeting the CurrentBar rule.
Bottom line is, the information from the sharing indi is making it to the checker. You need to run live data through it to get the 0's to go away. I saw the same behavior on mine, but it cleared as soon as data was being fed in. Back data loaded into a chart is considered historical and is handled differently than live data by the OnBarUpdate method.
Hope this helps.
The following user says Thank You to Caveman for this post: