getBarStateSymbol() |
Top Previous Next |
getBarStateSymbol( symbol/interval )
Returns a status flag from the EFS engine indicating the bar processing that is currently taking place. This function allows you to monitor bar activity in symbols other than the one that the script is running under.
Parameters
Return Flags
Usage
function main() { var nState; ... ... //we will monitor the Dell daily bar interval while, for example, our script may be //running in a MSFT 5-min chart. nState = getBarStateSymbol("DELL,D"); 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, in this case on the daily bar interval 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, again on the daily bar interval 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 on the Dell 60-minute bar interval regardless //of the symbol and/or interval we are currently viewing in our chart.... if (getBarStateSymbol("DELL,60") == BARSTATE_NEWBAR) {
myArray.unshift(0); myArray.pop();
}
}
|