Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm working on a strategy that basically has some levels and I need to know where the price is in relations to those levels.
For example I have 5 levels and I want to know when the price is between 1 and 2, 2 and 3, etc...
the snapcode of the interested part is:
With this code I was hoping to get the position of the price between levels by changing the burntIndex variable and UPDATING it in realtime...
But using a lot of prints to debug I discoved that it performs the operation succesfully ONLY at the start of the session (probably just the first time that the code is executed)... I tried to print the burntIndex value at several different hours of the day but it REMAIN THE SAME for ALL THE DAY... it just reset at the morning....
The code above should be executed on EVERY tick (IOG is true) so I think I'm really missing something stupid here but I can't come up to a solution.
btw: there are no ONCE piece in front of this code.
Any ideas on WHY it doesn't update the burntIndex during the day when the price is moving?
Any suggestions are appreciated,
Thanks and Best Regards
Can you help answer these questions from other members on NexusFi?
without the full code or at least code that can be used to reproduce the behavior I am afraid it's hard to tell.
Check your level values and the value for price using print statements for a few bars to see if they actually hold the values that you think they do.
the piece of code with the 5 "if" is in the main part of the strategy and it is supposed to work indipendently to the other part of the code. I'll try to add the other parts without all details..
I cannot find other relevant part of code because the other part are UNRELATED with those prints.
I need the burntIndex to perform diffentent kind of actions on the actual level...
But as I said it just print the burntIndex related to the price value at the opening of the sesssion..
I would check if the conditions are actually triggered and when by adding print statements within each begin... end block.
You might want to add the print before you set the value for burntIndex as this would allow you to check for
if burntIndex <> 1 then Print... for the first check and so on for the other checks with adjusting the number of course. This should tell you when and which level triggers and not clutter the output too much.
Based on that you can investigate things further.
Did you check your level values and the value for price using print statements for a few bars to see if they actually hold the values that you think they do? What was the result?
Hello again, I made one thing to solve the problem... I've removed all the code BEFORE those code above and surprisingly the burntIndex was working!!! So I checked the section where I set up the level values depending on the date... at the end I came up to the solution that was so so easy...
I had to put INTRABARPERSIST even in front of every level variables... that solved the problem!!
I didn't think it was necessary to declare also the level variables as intrabarpersist because they are values that are updated just once at the starting of the session... Now I know!
you are welcome and I am glad to hear that you figured it out.
Variables don't necessarily have to be intrabarpersist in an intrabar order generation strategy. However if you update them during the bar and want them to keep the value they have to be declared as intrabarpersist. Otherwise they will revert back to the previous value at the end of the code cycle.
That's why I suggested checking if the level variables actually hold the value that you think they do.