BEFORE I REINVENT THE WHEEL...
Has someone created and posted a study template that we can copy/paste from?
Thought I would ask first BEFORE I create one from scratch.
Since most of the code is that same, I find it much easier to copy/paste when I create a new study.
THANKING YOU IN ADVANCE.
Here's an example of what I mean:
Has someone created and posted a study template that we can copy/paste from?
Thought I would ask first BEFORE I create one from scratch.
Since most of the code is that same, I find it much easier to copy/paste when I create a new study.
THANKING YOU IN ADVANCE.
Here's an example of what I mean:
PHP Code:
/*********************************************************
TRO_
Modifying Programmer: Avery T. Horton, Jr. aka *************,
Color.white
Color.black
Color.darkgrey
Color.grey
Color.lightgrey
Color.navy
Color.blue
Color.aqua
Color.cyan
Color.teal
Color.darkgreen
Color.green
Color.lime
Color.olive
Color.khaki
Color.brown
Color.purple
Color.red
Color.magenta
Color.maroon
Color.yellow
Color.lightyellow
Color.paleyellow
Valid PriceSource values:
"O", "H", "L", "C"
"Open", "High", "Low", "Close"
"HL/2"
"HLC/3"
"OHLC/4"
**********************************************************/
debugClear();
function preMain() {
setPriceStudy(true);
setStudyTitle("TRO_");
setCursorLabelName("POpen", 0);
setDefaultBarFgColor(Color.olive,0);
setDefaultBarThickness(2,0);
setPlotType(PLOTTYPE_FLATLINES,0);
}
var vOpen = null;
var vOpen1 = null;
var vHigh = null;
var vHigh1 = null;
var vLow = null;
var vLow1 = null;
var vClose1 = null;
var vMid = null;
var vMid1 = null;
askForInput();
var iAlert = new FunctionParameter("iAlert", FunctionParameter.BOOLEAN);
iAlert.setDefault( true );
var iPeriods = new FunctionParameter("iPeriods", FunctionParameter.NUMBER);
iPeriods.setDefault( 05 );
function main( iAlert, iPeriods ) {
if (close(-1)==null)
return;
if(getBarState()==BARSTATE_NEWBAR&&getDay()!=getDay(-1)) {
vHigh1 = vHigh;
vLow1 = vLow;
vOpen1 = vOpen;
vClose1 = formatPriceNumber( close(-1) ) * 1 ;//comment out this line if using alternate vClose1
vMid1 = formatPriceNumber( vMid ) * 1 ;
vHigh = high();
vLow = low();
vOpen=open();
}
if (vHigh == null)
vHigh = high();
if (vLow == null)
vLow = low();
vHigh = Math.max(high(), vHigh);
vLow = Math.min(low(), vLow);
vMid = ( vHigh + vLow ) * .50 ;
//alternate vClose1 if one wants to use the daily bar Close. NOTE that this will not work with Tick Replay
//vClose1 = call("/OHLC/getPrevOHLC.efs", "Close");
if (vOpen1 == null || vLow1 == null || vHigh1 == null || vClose1 == null) {
return;
} else {
// PREVIOUS Open ALERT
if( ( high(-1) < vOpen1 || low(0) < vOpen1 ) && close(0) >= vOpen1 ){
Alert.addToList(getSymbol(), vOpen1 +" Cross above PrevOpen", Color.green, Color.black);
if( iAlert == true ) Alert.playSound("ding.wav");
debugPrint("Cross above PrevOpen: " + formatPriceNumber( vOpen1 ) + " " + getValue( "Time" ) + "\n" );
}
if( ( low(-1) > vOpen1 || high(0) > vOpen1 ) && close(0) <= vOpen1 ){
Alert.addToList(getSymbol(), vOpen1 +" Cross below PrevOpen", Color.red, Color.black);
if( iAlert == true ) Alert.playSound("ding.wav");
debugPrint("Cross below PrevOpen: " + formatPriceNumber( vOpen1 ) + " " + getValue( "Time" ) + "\n" );
}
if ( isLastBarOnChart() == true ) {
//clear the Formula Output Window
//print a line of text to that window
debugPrint( "The previous day's midpoint is: " + formatPriceNumber( vMid1 ) + "\n" );
}
return new Array( vOpen1 );
}
}