I am using drawShapeRelative to indicate on a Stochastics study when there is a slope change in a moving average. My problem is on the current bar. During a 30-min period, the slope could change and my efs draws a shape (up or down arrow). No problem. But then the slope could resume its original direction. The shape remains. I've tried using "clearShape" but that clears all shapes that are on the chart. I want to keep all shapes of past bars. How do I clear the shape on the Current Bar only?
Announcement
Collapse
No announcement yet.
clearShape on Current Bar only
Collapse
X
-
Re: clearShape on Current Bar only
Phil
You need to use the removeShape() function to remove individual shapes (see the linked article in the EFS KnowledgeBase for the required syntax). Also if you run a search in these forums for the keyword removeshape* you will find several examples of its use
Alex
Originally posted by pjkowalski
I am using drawShapeRelative to indicate on a Stochastics study when there is a slope change in a moving average. My problem is on the current bar. During a 30-min period, the slope could change and my efs draws a shape (up or down arrow). No problem. But then the slope could resume its original direction. The shape remains. I've tried using "clearShape" but that clears all shapes that are on the chart. I want to keep all shapes of past bars. How do I clear the shape on the Current Bar only?
-
Alex - I did try using removeShape as well. I added a tagID to the drawShapeRelative, and removed the shape based on tagID if getBarState was == BARSTATE_CURRENTBAR. All of the shapes were removed from the chart.
Would you be able to direct me to a code example?
Here is a sampling of my code:
nState = getBarState();
if(getHour()>4 && getHour()<15) {
// If moving average slope turns up //
if(nState == BARSTATE_CURRENTBAR) {
removeShape(nTagUp);
}
if(nSMA2>=nSMA1) {
if(nSMA1<=nSMA0) {
if((nSMA0-nSMA1)>0) {
nTagUp + 1;
drawShapeRelative(0, vSignal, Shape.UPARROW, null, Color.green, Shape.TOP | Shape.ONTOP, nTagUp);
}
}
}
// If moving average slope turns down //
if(nState == BARSTATE_CURRENTBAR) {
removeShape(nTagDown);
}
if(nSMA2<=nSMA1) {
if(nSMA1>=nSMA0) {
if((nSMA1-nSMA0)>0) {
nTagDown + 1
drawShapeRelative(0, vSignal, Shape.DOWNARROW, null, Color.red, Shape.TOP | Shape.ONTOP, nTagDown);
}
}
}
Comment
-
Phil
One way of removing the shape is shown in the following example
Alex
PHP Code:if(myCondition) {
drawShapeRelative(...,myTagID);
} else {
removeShape(myTagID);
}
Originally posted by pjkowalski
Alex - I did try using removeShape as well. I added a tagID to the drawShapeRelative, and removed the shape based on tagID if getBarState was == BARSTATE_CURRENTBAR. All of the shapes were removed from the chart.
Would you be able to direct me to a code example?
Here is a sampling of my code:
nState = getBarState();
if(getHour()>4 && getHour()<15) {
// If moving average slope turns up //
if(nState == BARSTATE_CURRENTBAR) {
removeShape(nTagUp);
}
if(nSMA2>=nSMA1) {
if(nSMA1<=nSMA0) {
if((nSMA0-nSMA1)>0) {
nTagUp + 1;
drawShapeRelative(0, vSignal, Shape.UPARROW, null, Color.green, Shape.TOP | Shape.ONTOP, nTagUp);
}
}
}
// If moving average slope turns down //
if(nState == BARSTATE_CURRENTBAR) {
removeShape(nTagDown);
}
if(nSMA2<=nSMA1) {
if(nSMA1>=nSMA0) {
if((nSMA1-nSMA0)>0) {
nTagDown + 1
drawShapeRelative(0, vSignal, Shape.DOWNARROW, null, Color.red, Shape.TOP | Shape.ONTOP, nTagDown);
}
}
}
Comment
Comment