Hello...Im new to the forum and to coding...would someone here mind looking at my code and telling me what im doing wrong? thank you in advance for any suggestion.....john
All i wanted the code to do is compare the most recent bar close to the second most recent bars close ..if the close of the first is greater than the close of its previous bar then it would draw a text above the 5th bar back...if not then draw a text over the first bar....BUT ITS DRAWING A TEXT OVER BOTH BARS!! and i cant figure out why...below is the code and a screen shot...can someone please tell me what im doing wrong
function preMain() {
setPriceStudy(true);
setStudyTitle("Bar States");
setShowCursorLabel(false);
}
function main() {
if (close (-1) > close (-2)) {
drawTextAbsolute(-5, high(0), "N", Color.blue, null,
Text.BOLD|Text.TOP|Text.FRAME, null, 7);
} else {
drawTextAbsolute(-1, high(0), "N", Color.blue, null,
Text.BOLD|Text.TOP|Text.FRAME, null, 7) ;
}
}
All i wanted the code to do is compare the most recent bar close to the second most recent bars close ..if the close of the first is greater than the close of its previous bar then it would draw a text above the 5th bar back...if not then draw a text over the first bar....BUT ITS DRAWING A TEXT OVER BOTH BARS!! and i cant figure out why...below is the code and a screen shot...can someone please tell me what im doing wrong
function preMain() {
setPriceStudy(true);
setStudyTitle("Bar States");
setShowCursorLabel(false);
}
function main() {
if (close (-1) > close (-2)) {
drawTextAbsolute(-5, high(0), "N", Color.blue, null,
Text.BOLD|Text.TOP|Text.FRAME, null, 7);
} else {
drawTextAbsolute(-1, high(0), "N", Color.blue, null,
Text.BOLD|Text.TOP|Text.FRAME, null, 7) ;
}
}
Comment