Here is the 2nd half of the code from last post. On your end just paste it below the above code:
NOTE: This is the second half of the post. The first half is in the previous post.
Wayne
PHP Code:
//Exit Signals
if (Strategy.isInTrade() == true)
{
if (Strategy.isShort() == true)
{
if (bShort1 == true && bShort2 == false && bShort3 == false && bShort4 == false)
{
if (low(0)< nPrice && low(-1)>= nPrice)
{
nExitPrice = nPrice;
Strategy.doCover("Cover Short1 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, BelowBar2, Color.green,"DoCover1"+gID());//added tagID
}
}
if (bShort1 == true && bShort2 == true && bShort3 == false && bShort4 == false)
{
if (low(0)< nPrice+Res1 && low(-1)>= nPrice+Res1)
{
nExitPrice = nPrice+Res1;
Strategy.doCover("Cover Short2 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, BelowBar2, Color.green,"DoCover2"+gID());//added tagID
}
}
if (bShort1 == true && bShort2 == true && bShort3 == true && bShort4 == false)
{
if (low(0)< nPrice+Res2 && low(-1)>= nPrice+Res2)
{
nExitPrice = nPrice+Res2;
Strategy.doCover("Cover Short3 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, BelowBar2, Color.green,"DoCover3"+gID());//added tagID
}
}
if (bShort1 == true && bShort2 == true && bShort3 == true && bShort4 == true)
{
if (low(0)< nPrice+Res3 && low(-1)>= nPrice+Res3)
{
nExitPrice = nPrice+Res3;
Strategy.doCover("Cover Short4 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, BelowBar2, Color.green,"DoCover4"+gID());//added tagID
}
}
} else if (Strategy.isLong() == true)
{
if (bLong1 == true && bLong2 == false && bLong3 == false && bLong4 == false)
{
if (high(0)> nPrice && high(-1)<= nPrice)
{
nExitPrice = nPrice;
Strategy.doSell("Sell Long1 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, AboveBar2, Color.green,"DoSell1"+gID());//added tagID
}
}
if (bLong1 == true && bLong2 == true && bLong3 == false && bLong4 == false)
{
if (high(0)> nPrice-Sup1 && high(-1)<= nPrice-Sup1)
{
nExitPrice = nPrice-Sup1;
Strategy.doSell("Sell Long2 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, AboveBar2, Color.green,"DoSell2"+gID());//added tagID
}
}
if (bLong1 == true && bLong2 == true && bLong3 == true && bLong4 == false)
{
if (high(0)> nPrice-Sup2 && high(-1)<= nPrice-Sup2)
{
nExitPrice = nPrice-Sup2;
Strategy.doSell("Sell Long3 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, AboveBar2, Color.green,"DoSell3"+gID());//added tagID
}
}
if (bLong1 == true && bLong2 == true && bLong3 == true && bLong4 == true)
{
if (high(0)> nPrice-Sup3 && high(-1)<= nPrice-Sup3)
{
nExitPrice = nPrice-Sup3;
Strategy.doSell("Sell Long4 Signal", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nExitPrice);
drawShape(Shape.DIAMOND, AboveBar2, Color.green,"DoSell4"+gID());//added tagID
}
}
}
}
if(plotPrice.indexOf("Open")!=-1) drawTextRelative(PriceOffset, nPrice, nPrice, Color.blue, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP");
if(plotPrice.indexOf("Res1")!=-1) drawTextRelative(PriceOffset, nPrice+Res1, nPrice+Res1, Color.yellow, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_H");
if(plotPrice.indexOf("Res2")!=-1) drawTextRelative(PriceOffset, nPrice+Res2, nPrice+Res2, Color.green, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_K");
if(plotPrice.indexOf("Res3")!=-1) drawTextRelative(PriceOffset, nPrice+Res3, nPrice+Res3, Color.red, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_L");
if(plotPrice.indexOf("Res4")!=-1) drawTextRelative(PriceOffset, nPrice+Res4, nPrice+Res4, Color.red, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_M");
if(plotPrice.indexOf("Sup1")!=-1) drawTextRelative(PriceOffset, nPrice-Sup1, nPrice-Sup1, Color.yellow, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_N");
if(plotPrice.indexOf("Sup2")!=-1) drawTextRelative(PriceOffset, nPrice-Sup2, nPrice-Sup2, Color.green, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_O");
if(plotPrice.indexOf("Sup3")!=-1) drawTextRelative(PriceOffset, nPrice-Sup3, nPrice-Sup3, Color.red, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_P");
if(plotPrice.indexOf("Sup4")!=-1) drawTextRelative(PriceOffset, nPrice-Sup4, nPrice-Sup4, Color.red, null, Text.BOLD | Text.LEFT | Text.VCENTER, null, 10, "TimeP_Q");
return [Strategy.isInTrade(),Strategy.isLong(),Strategy.isShort(),doTrade]; //added to show "in Trade" conditions in Data Window
}
var grID = 0;
function gID()
{
grID ++;
return( grID );
}
Wayne
Comment