getBarState() |
Top Previous Next |
getBarState()
Returns a status flag from the EFS engine indicating the bar processing that is currently taking place.
Parameters
Return Flags
Usage
function main() { var nState; ... ... nState = getBarState(); if (nState == BARSTATE_ALLBARS) { //the bars are being loaded by the script. This happens when a script is first loaded debugPrint("Script is loading\n"); } else if (nState == BARSTATE_NEWBAR) { //this flag is set when a new bar is coming in debugPrint("The first tick of a new bar has arrived\n"); } else if (nState == BARSTATE_CURRENTBAR) { //this flag is set as each new tick comes in debugPrint("A new tick has arrived\n"); }
}
var sSymbol = null; var nInterval = null; var myArray = new Array(50);
function main() {
//perform some initialization actions when script is first loading if (getBarState() == BARSTATE_ALLBARS) {
sSymbol = getSymbol(); //grab the name of the symbol being charted for later use nInterval = getInterval(); //grab the bar interval we are using for later use return;
} ... ... //cycle an array when a new bar comes in.... if (getBarState() == BARSTATE_NEWBAR) {
myArray.unshift(0); myArray.pop();
}
}
|