Hello members,
I have been trying to get an alert to appear in the triggered alert box only when a certain condition appears.
In this case I just want an alert when a bar turns green. However, the alert occurs everytime the price changes.
Can someone please help
function preMain(){
setStudyTitle("MFIcolors");
setCursorLabelName("MFI", 0);
setPlotType(PLOTTYPE_HISTOGRAM);
}
var color=0
var MFIold=0;
var sMyVol="Volume";
var MFI=0;
function main(){
if(getBarState()==BARSTATE_NEWBAR)
MFIold=MFI
var MyVol = "Volume";
if (sMyVol != null) MyVol = sMyVol;
var Range = high(0) - low(0);
var Vol = getValue(MyVol,0);
//var MFI = 0.0;
if (Vol > 0) MFI = Range / Vol * 1000000000;
else MFI = 0;
debugPrintln(MFI+" "+MFIold)
if(MFI>MFIold && volume()>volume(-1))
setBarFgColor(Color.green)
Alert.addToList( "IBM", "Breakout!", Color.green, Color.black );
if(MFI<MFIold && volume()<volume(-1))
setBarFgColor(Color.brown)
if(MFI>MFIold && volume()<volume(-1))
setBarFgColor(Color.blue)
if(MFI<MFIold && volume()>volume(-1))
setBarFgColor(Color.red)
return MFI;
}
function test() {
if(MFI>MFIold && volume()>volume(-1)){
Alert.addToList( "IBM", "Breakout!", Color.green, Color.black );
}
}
Cheers
Carlton
I have been trying to get an alert to appear in the triggered alert box only when a certain condition appears.
In this case I just want an alert when a bar turns green. However, the alert occurs everytime the price changes.
Can someone please help
function preMain(){
setStudyTitle("MFIcolors");
setCursorLabelName("MFI", 0);
setPlotType(PLOTTYPE_HISTOGRAM);
}
var color=0
var MFIold=0;
var sMyVol="Volume";
var MFI=0;
function main(){
if(getBarState()==BARSTATE_NEWBAR)
MFIold=MFI
var MyVol = "Volume";
if (sMyVol != null) MyVol = sMyVol;
var Range = high(0) - low(0);
var Vol = getValue(MyVol,0);
//var MFI = 0.0;
if (Vol > 0) MFI = Range / Vol * 1000000000;
else MFI = 0;
debugPrintln(MFI+" "+MFIold)
if(MFI>MFIold && volume()>volume(-1))
setBarFgColor(Color.green)
Alert.addToList( "IBM", "Breakout!", Color.green, Color.black );
if(MFI<MFIold && volume()<volume(-1))
setBarFgColor(Color.brown)
if(MFI>MFIold && volume()<volume(-1))
setBarFgColor(Color.blue)
if(MFI<MFIold && volume()>volume(-1))
setBarFgColor(Color.red)
return MFI;
}
function test() {
if(MFI>MFIold && volume()>volume(-1)){
Alert.addToList( "IBM", "Breakout!", Color.green, Color.black );
}
}
Cheers
Carlton
Comment