Here is simple code that is applied to an intraday chart with 81 bars in a day.
value1=XAverage(c,100);
value2=value1[81];
if barstatus(1)=2 then print(date," ",time," ",value1," ",value2);
Value2 should show what value1 was 81 bars ago, the same time of day. According to the printout, instead it is showing what Value1 was 94 bars ago.
code question [SOLVED]
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: a very concerning bug
Here is simple code that is applied to an intraday chart with 81 bars in a day.
value1=XAverage(c,100);
value2=value1[81];
if barstatus(1)=2 then print(date," ",time," ",value1," ",value2);
Value2 should show what value1 was 81 bars ago, the same time of day. According to the printout, instead it is showing what Value1 was 94 bars ago.
You should review your result again, I doubt there is a bug for a rudimental operation like this.
What is your chart resolution?
Please post your complete code as well as your output.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: a very concerning bug [SOLVED]
hint:
Always always always avoid using generic variable names. ie value1, condition1, etc.,
Variable names are free... they can save you lots of headache in debug time.
Always always always avoid using generic variable names. ie value1, condition1, etc.,
Variable names are free... they can save you lots of headache in debug time.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
Re: a very concerning bug
Thanks - you completely nailed it - it was using the "value1" that did it...
I did this out of laziness, and don't typically use "value1", but never will again - is this common knowledge?
I did this out of laziness, and don't typically use "value1", but never will again - is this common knowledge?