I’m working on a code that should only buy when the condition occurs for the second or more times. Unfortunately, I’m facing an issue where the counter doesn’t seem to increase and remains at 1, causing the “IF counter>x” condition to always return the same result, regardless of x.
Oncecounter=0// counter must have an initial value.
ifDate[1]<>Date[0]then
counter=0
endif
If you don’t do this, counter will have an undefined value which probably is a huge negative number. So it will add up, but only when a new day has started, it will reset to 0 for the first time.
Maybe what fifi added helps too ( I don’t readily see why he does it) and possibly it is so that both amendments are required to get it going.
You can let your code end with
1
2
graphcounter
graphDivg
Then you can see what values these variables receive.
Thank you very much fifi743 and PeterSt for your answers. Thanks PeterSt specially for the command “graph” I didn’t know it.
Actually the code was working I could see it with “graph counter”. The problem is that it jumps from 0 to 4, or to 0 to 20, etc. So I’m going to adjust it to start from 4, or something else.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue