I want to draw a shape above the current bar if RSI(7) goes above 70 and below the current bar of RSI (7) falls below 30.
I wrote a sript that seemed to work except that when the RSI fell back below 70 (or above 30) the shape remained.
I introduced clearShape() which is supposed to clear the shapes drawn during the current bar but this has introduced two new problems:
1. I suspect it deletes everything, not just shapes drawn during the current bar because when a new bar forms the shape on the previous bar is deleted too.
2. When I load the EFS it correctly draws all my shapes but, obvioulsy, then deletes them all.
How can I draw my shape and delete it when without deleting all the other shapes?
I've thought of a workaround using shapes the same color as my background but I don't find the very satisfactory.
Here is my code so far:
function preMain() {
setPriceStudy(true);
setStudyTitle("RSI");
setCursorLabelName("7");
}
function main() {
var vRSI=rsi(7);
clearShape();
if(vRSI<30) drawShapeRelative(0, high()+5*getMinTick(), Shape.DOWNARROW, "", Color.lime, Shape.BOTTOM);
if(vRSI>70) drawShapeRelative(0, low()-5*getMinTick(), Shape.UPARROW, "", Color.magenta, Shape.TOP);
return null;
}
Thank you!
I wrote a sript that seemed to work except that when the RSI fell back below 70 (or above 30) the shape remained.
I introduced clearShape() which is supposed to clear the shapes drawn during the current bar but this has introduced two new problems:
1. I suspect it deletes everything, not just shapes drawn during the current bar because when a new bar forms the shape on the previous bar is deleted too.
2. When I load the EFS it correctly draws all my shapes but, obvioulsy, then deletes them all.
How can I draw my shape and delete it when without deleting all the other shapes?
I've thought of a workaround using shapes the same color as my background but I don't find the very satisfactory.
Here is my code so far:
function preMain() {
setPriceStudy(true);
setStudyTitle("RSI");
setCursorLabelName("7");
}
function main() {
var vRSI=rsi(7);
clearShape();
if(vRSI<30) drawShapeRelative(0, high()+5*getMinTick(), Shape.DOWNARROW, "", Color.lime, Shape.BOTTOM);
if(vRSI>70) drawShapeRelative(0, low()-5*getMinTick(), Shape.UPARROW, "", Color.magenta, Shape.TOP);
return null;
}
Thank you!
Comment