I have written some code that is expereiencing some weird behavior.
First, when you assign variable to be a default study, like RSI
i.e. var rs = new RSIStudy(16, "HLC/3");
is it best to do this outside of main, and premain, so it have global scope? or is it better to do this within main.
My understanding is if you do it once, outside of main and premain, then it is only created once(I take it, it's updated for each bar automatically) so this would have the best performance as it's not creating a new rsi each time the code is called.
Well I did this for a package I am writing, and found that when this is declared this way, and I am set to computeonclose, my main is being executed with each tick. When I move this study/variable definition within main this problem goes away. Another anomoly that is also caused by this definition being outside of main, is when I draw lines on the chart, with each new tick the lines move to the left. I did some debuging and found that my internal tracking for the pviots of these lines are not being updated, as designed, so it must have something to do with esignal's internal code that is causing this anomoly. Any ideas?
I moved the definition within main and all seems to work, except I do notice the performance is not as fast when I run the routine on all the bars on the chart(I actually filter and only do it for the last 200) but it still takes a lot longer to execute than with the definition outside of main.
thoughts?
First, when you assign variable to be a default study, like RSI
i.e. var rs = new RSIStudy(16, "HLC/3");
is it best to do this outside of main, and premain, so it have global scope? or is it better to do this within main.
My understanding is if you do it once, outside of main and premain, then it is only created once(I take it, it's updated for each bar automatically) so this would have the best performance as it's not creating a new rsi each time the code is called.
Well I did this for a package I am writing, and found that when this is declared this way, and I am set to computeonclose, my main is being executed with each tick. When I move this study/variable definition within main this problem goes away. Another anomoly that is also caused by this definition being outside of main, is when I draw lines on the chart, with each new tick the lines move to the left. I did some debuging and found that my internal tracking for the pviots of these lines are not being updated, as designed, so it must have something to do with esignal's internal code that is causing this anomoly. Any ideas?
I moved the definition within main and all seems to work, except I do notice the performance is not as fast when I run the routine on all the bars on the chart(I actually filter and only do it for the last 200) but it still takes a lot longer to execute than with the definition outside of main.
thoughts?
Comment