I would expect the code below to 1) color bars aqua, trade the same aqua-colored bars. this isn't the case. instead, the bars i am looking to identify are set to aqua, but different bars are traded. this seems bizarrely buggy to me, but since I'm a newbie, I must be doing something dreadully wrong. can an expert pls help? thanks! begin if (linearreg(bar-1, #close, 200) > priceopen(bar)) and (priceopen(bar -1) < priceopen(bar)) and (priceopen(bar) <> priceclose(bar)) then setbarcolor(bar, #aqua); end; begin if (linearreg(bar-1, #close, 200) > priceopen(bar)) and (priceopen(bar -1) < priceopen(bar)) and (priceopen(bar) <> priceclose(bar)) then buyatmarket(bar,''); sellatclose(bar,lastactiveposition,''); end;
i even tried a boolean...comes out a little bit better...now it trades aqua bars with some non-aquas thrown in.
Your code works as expected, i.e. aqua bars are traded bars. BTW, you don't need the two "begin" and "end" statements. Richard