- you're never setting the bid array as a buffer, you're setting the ask array twice
- the if statement in shiftarray is unclear, proper bracing for an if statement is
Inserted Code
//check 1 thing, do 1 thing
if(check_1)do_1;
//check 2 things, do 1 thing
if(check_1)if(check_2)do_1;
//check 2 things, do 1 thing
if(check_1 &&/|| check_2)do_1;
//check 1 thing, do 1 thing
if(check_1){
do_1;
}
//check 1 thing, do stuff, check other stuff and do other stuff
if(check_1){
do_1;
do_2;
if(check2)do_3;
if(check3){
do_4;
do_5;
}
} Looks like youre trying to have your own ask/bid lines as buffer lines on the chart, with that in mind:
- the loop in shiftarray() never touches the live bar 0, and the lines being buffers will not pass the rightside of the live bar without a large shift
- in oncalc you're setting the buffer indexes at 1, but shiftarray is starting from n=barsperchart, and counting down, from left to right, to bar 1, due to buffers being timeseries indexing
- to set all the buffer values with a single value, you can do arrayinitialize(), or from the index of the value youre setting, loop from that to where ever
- barsperchart only gives you the number of bars per chart for the given zoom, so you can scroll back to bar 1000, and if the barsperchart is 200, you're looking at bar indexes 999-799, while buffer indexes 199-1 are (trying to be) filled
- you're also calling shiftarray() before youre setting a value in the buffers
>>- all of this could be replaced by using 2 horizontal lines, and setting them to ask/bid prices