Hi,
I have a CCI Arrow Alert that is not working excatly the way I would like. The Alert puts an arrow at the 1st tick of a new bar after a plus or minus 100 cross. I would also like to get an Arrow Alert if the CCI crosses the plus or minus 100 within a bar.
For example: If the CCI is below -100 for a few bars then and within one of the bars the CCI goes above -100 then back though, I would also like to get an Arrow Alert also.
Below is the code I'm using, any suggestions would be greatly appreciated
Thank you,
Mac
var vFlag = false;
function preMain() {
setPriceStudy(true);
setStudyTitle("CCI Alert");
setColorPriceBars(true);
setDefaultPriceBarColor(Color.RGB(255,255,255));
setShowCursorLabel(false);
}
var bInit = false;
var wCCI = null;
function main() {
if (bInit == false) {
Symbol = getSymbol();
Interval1 = getInterval();
var vSymbol1 = Symbol+","+Interval1;
wCCI = cci(20,sym(vSymbol1));
bInit = true;
}
if (getBarState() == BARSTATE_NEWBAR)
vFlag = false;
var gCCI = wCCI.getValue(0);
var gCCI_1 = wCCI.getValue(-1);
if (
gCCI == null || gCCI_1 == null
) return;
if(vFlag == false){
if (gCCI > 100 && gCCI_1 < 100) {
drawShape(Shape.UPARROW, BelowBar1, Color.RGB(0,255,0));
vFlag = true;
}
else if (gCCI < -100 && gCCI_1 > -100) {
drawShape(Shape.DOWNARROW, AboveBar1, Color.RGB(0,255,0));
vFlag = true ;
}
}
return;
}
I have a CCI Arrow Alert that is not working excatly the way I would like. The Alert puts an arrow at the 1st tick of a new bar after a plus or minus 100 cross. I would also like to get an Arrow Alert if the CCI crosses the plus or minus 100 within a bar.
For example: If the CCI is below -100 for a few bars then and within one of the bars the CCI goes above -100 then back though, I would also like to get an Arrow Alert also.
Below is the code I'm using, any suggestions would be greatly appreciated
Thank you,
Mac
var vFlag = false;
function preMain() {
setPriceStudy(true);
setStudyTitle("CCI Alert");
setColorPriceBars(true);
setDefaultPriceBarColor(Color.RGB(255,255,255));
setShowCursorLabel(false);
}
var bInit = false;
var wCCI = null;
function main() {
if (bInit == false) {
Symbol = getSymbol();
Interval1 = getInterval();
var vSymbol1 = Symbol+","+Interval1;
wCCI = cci(20,sym(vSymbol1));
bInit = true;
}
if (getBarState() == BARSTATE_NEWBAR)
vFlag = false;
var gCCI = wCCI.getValue(0);
var gCCI_1 = wCCI.getValue(-1);
if (
gCCI == null || gCCI_1 == null
) return;
if(vFlag == false){
if (gCCI > 100 && gCCI_1 < 100) {
drawShape(Shape.UPARROW, BelowBar1, Color.RGB(0,255,0));
vFlag = true;
}
else if (gCCI < -100 && gCCI_1 > -100) {
drawShape(Shape.DOWNARROW, AboveBar1, Color.RGB(0,255,0));
vFlag = true ;
}
}
return;
}
Comment