Hi,
The enclosed efs uses the DrawTextCtr variable to control the number of bars back used to plot the DrawTextRelative(...). This reduces overhead resources.
It draws small colored squares at the bottom of the chart. I found this method via a forum search.
Problem: Initially it plots as intended (LookBack of 300 bars back) but it soon starts to erase the plotted squares from left to right until only one square remains.
I would like it to keep the last 300 squares so that as a new square is plotted, the square at the begining is erased (now 301 bars back).
I'm sure it's a simple solution but it escapes me.
Thanks in advance.
Wayne
The enclosed efs uses the DrawTextCtr variable to control the number of bars back used to plot the DrawTextRelative(...). This reduces overhead resources.
It draws small colored squares at the bottom of the chart. I found this method via a forum search.
Problem: Initially it plots as intended (LookBack of 300 bars back) but it soon starts to erase the plotted squares from left to right until only one square remains.
I would like it to keep the last 300 squares so that as a new square is plotted, the square at the begining is erased (now 301 bars back).
I'm sure it's a simple solution but it escapes me.
Thanks in advance.
Wayne
PHP Code:
debugClear();
var bInit = false;
var aFPArray = new Array();
function preMain() {
setPriceStudy(true);
var x=0;
aFPArray[x] = new FunctionParameter( "Interval0", FunctionParameter.STRING);
with( aFPArray[x++] ) {
setName( "Price Interval" );
setDefault( );
}
}
var myStudy0 = null;
var myStudy1 = null;
var DrawTextCntr = 0;
var LookBack = 300;
function main(Interval0) {
var myVar0,myVar1;
var TempColor = Color.white;
if ( bInit == false ) {
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
if(Interval0 == null) Interval0 = getInterval();
if(myStudy0 == null) myStudy0 = sma( 9, inv(Interval0) );
myStudy0 = getSeries(myStudy0);
if(myStudy1 == null) myStudy1 = sma( 13, inv(Interval0) );
myStudy1 = getSeries(myStudy1);
bInit = true;
}
var Close0 = close(0);
var myVar0 = myStudy0.getValue(0);
var myVar1 = myStudy1.getValue(0);
if(Close0 > myVar0 && myVar0 > myVar1) TempColor = Color.green;//Price is above MA0 & MA0 is above MA1
if(Close0 > myVar0 && myVar0 < myVar1) TempColor = Color.red;//Price is above MA0 & MA0 is below MA1
if(Close0 < myVar0 && myVar0 < myVar1) TempColor = Color.RGB(218,218,165);//Price is below MA1 & MA0 is below MA1
if(Close0 < myVar0 && myVar0 > myVar1) TempColor = Color.RGB(255,230,195);//Price is below MA1 & MA0 is above MA1
drawTextRelative(0,1,"n",TempColor,null,Text.VCENTER | Text.RELATIVETOBOTTOM |Text.CENTER|Text.BOLD,"Wingdings",10,"n0"+ DrawTextCntr++);
if (DrawTextCntr > LookBack) DrawTextCntr = 0;
return new Array( myStudy0, myStudy1 );
}
Comment