How do I get data from the close of the previous bar???
How do I get data from the close of 2 bars ago???
Thanks,
John
How do I get data from the close of 2 bars ago???
Thanks,
John
var myClose1 = close(-1);//the Close at the prior bar
var myHigh2 = high(-2);//the High of two bars ago
var myVar3 = sma(10,-3);//the value of a 10 period simple MA at three bars ago
//etc
var myStudy = sma(10);//declare and initialize the series
var myVar1 = myStudy.getValue(-1);//retrieves the value of myStudy one bar back
var myVar2 = myStudy.getValue(-2);//the value of myStudy two bars back
//etc
var xInit = false;
var xMiddle = null;
var xOpen = null;
var xHigh = null;
var xLow = null;
var xClose = null;
function main( ) {
if(xInit==false){
xOpen = open( inv("D") ) ;
xHigh = high( inv("D") ) ;
xLow = low( inv("D") ) ;
xClose = close( inv("D") ) ;
xInit=true;
} // xInit
var zOpen = xOpen.getValue(0) ;
var zClose1 = xClose.getValue(-1) ;
var zHigh = xHigh.getValue(-1) ;
var zLow = xLow.getValue(-1) ;
var zMid1 = rnd( ((zHigh + zLow) * .50) , 2 ) ;
var zGap = rnd( (zOpen - zClose1) , 2) ;
debugPrint( "zMid1 xInit : " + zMid1 + "\n" );
debugPrint( "zGap xInit : " + zGap + "\n" );
return ; // main
}
//==rnd will round to N digits.
function rnd(value, N) {
var n;
var mult=1;
for(n=0;n<N;n++) mult*=10;
value*=mult;
return Math.round( value,N)/mult;
}
var xInit = false;
var xMiddle = null;
var xOpen = null;
var xHigh = null;
var xLow = null;
var xClose = null;
function main( ) {
if(xInit==false){
xOpen = open( inv("D") ) ;
xHigh = high( inv("D") ) ;
xLow = low( inv("D") ) ;
xClose = close( inv("D") ) ;
xInit=true;
} // xInit
var zOpen = xOpen.getValue(0) ;
var zClose1 = xClose.getValue(-1) ;
var zHigh = xHigh.getValue(-1) ;
var zLow = xLow.getValue(-1) ;
var zMid1 = rnd( ((zHigh + zLow) * .50) , 2 ) ;
var zGap = rnd( (zOpen - zClose1) , 2) ;
debugPrint( "zMid1 xInit : " + zMid1 + "\n" );
debugPrint( "zGap xInit : " + zGap + "\n" );
return ; // main
}
//==rnd will round to N digits.
function rnd(value, N) {
var n;
var mult=1;
for(n=0;n<N;n++) mult*=10;
value*=mult;
return Math.round( value,N)/mult;
}
function main() {
....
if (xMidpoint == null) xMidpoint = efsInternal("calcMidpoint", xHigh, xLow);
....
}
function calcMidpoint(xH, xL) {
return (xH.getValue(0) + xL.getValue(0)) * .50;
}
var xInit = false;
var xMiddle1 = null;
var xMidpoint = null;
var xOpen = null;
var xHigh = null;
var xLow = null;
var xClose = null;
function preMain() {
setPlotType(PLOTTYPE_SQUAREWAVE ,0);
setDefaultBarThickness(2,0);
}
function main( ) {
if(xInit==false){
xOpen = open( ) ;
xHigh = high( ) ;
xLow = low( ) ;
xClose = close( ) ;
xInit=true;
} // xInit
if (xMidpoint == null) xMidpoint = efsInternal("calcMidpoint", xHigh, xLow);
// debugPrint( "xMidpoint.getValue(0) : " + xMidpoint.getValue(0) + "\n" );
xMiddle = rnd( xMidpoint.getValue(0) , 2 ) ;
xMiddle1 = rnd( xMidpoint.getValue(-1) , 2 ) ;
debugPrint( "xMiddle1 : " + xMiddle1 + "\n" );
debugPrint( "xMiddle : " + xMiddle + "\n" );
return new Array( getSeries(xMidpoint) ) ;
}
function calcMidpoint(xH, xL) {
return (xH.getValue(0) + xL.getValue(0)) * .50;
}
// rnd function - round to iDecimals places
function rnd(value, iDecimals ) {
value = value * Math.pow(10, iDecimals);
return Math.round(value, iDecimals) / Math.pow(10, iDecimals);
}
var xInit = false;
var xMiddle1 = null;
var xMidpoint = null;
var xOpen = null;
var xHigh = null;
var xLow = null;
var xClose = null;
function preMain() {
setPlotType(PLOTTYPE_SQUAREWAVE ,0);
setDefaultBarThickness(2,0);
}
function main( ) {
if(xInit==false){
xOpen = open( ) ;
xHigh = high( ) ;
xLow = low( ) ;
xClose = close( ) ;
xInit=true;
} // xInit
if (xMidpoint == null) xMidpoint = efsInternal("calcMidpoint", xHigh, xLow);
// debugPrint( "xMidpoint.getValue(0) : " + xMidpoint.getValue(0) + "\n" );
xMiddle = rnd( xMidpoint.getValue(0) , 2 ) ;
xMiddle1 = rnd( xMidpoint.getValue(-1) , 2 ) ;
debugPrint( "xMiddle1 : " + xMiddle1 + "\n" );
debugPrint( "xMiddle : " + xMiddle + "\n" );
return new Array( getSeries(xMidpoint) ) ;
}
function calcMidpoint(xH, xL) {
return (xH.getValue(0) + xL.getValue(0)) * .50;
}
// rnd function - round to iDecimals places
function rnd(value, iDecimals ) {
value = value * Math.pow(10, iDecimals);
return Math.round(value, iDecimals) / Math.pow(10, iDecimals);
}
Comment