Hi:
The following Strategy should generate lots of trades and I
am geting zero trades. Could someone please help me
figure it out.
Thank you very much
sol123
var newtrade = 0;
var entpric = 0;
function preMain(){
setPriceStudy(true);
setStudyTitle("STRAT2_TEST");
setCursorLabelName("STEST2",0);
}
function main(proftar, xstop){
if(proftar == null){
proftar = 5;
}
if(xstop == null){
xstop = 2.5;
}
if (newtrade == 1){
entpric = open();
}
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
if (low() <= (entpric - proftar)) {
Strategy.doCover("Short PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric - proftar));
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
if (high() >= (entpric + proftar)) {
Strategy.doSell("Long PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric + proftar));
}
}
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
if (high() >= (entpric + xstop)) {
Strategy.doCover("Short stp Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric + xstop));
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
if (low() <= (entpric - xstop)) {
Strategy.doSell("Long stp Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric - xstop));
}
}
newtrade = 0;
//DebugPrintln("TEST FOR TRADE");
if(low() < low(-1) && low(-1) < low(-2) && Strategy.isInTrade() == false){
Strategy.doShort("GO SHORT", Strategy.MARKET, Strategy.Nextbar);
newtrade = 1;
DebugPrintln("GO SHORT");
}
if(high() > high(-1) && high(-1) > high(-2) && Strategy.isInTrade() == false){
Strategy.doLong("GO LONG", Strategy.MARKET, Strategy.Nextbar);
newtrade = 1;
DebugPrintln("GO LONG");
}
}
The following Strategy should generate lots of trades and I
am geting zero trades. Could someone please help me
figure it out.
Thank you very much
sol123
var newtrade = 0;
var entpric = 0;
function preMain(){
setPriceStudy(true);
setStudyTitle("STRAT2_TEST");
setCursorLabelName("STEST2",0);
}
function main(proftar, xstop){
if(proftar == null){
proftar = 5;
}
if(xstop == null){
xstop = 2.5;
}
if (newtrade == 1){
entpric = open();
}
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
if (low() <= (entpric - proftar)) {
Strategy.doCover("Short PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric - proftar));
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
if (high() >= (entpric + proftar)) {
Strategy.doSell("Long PT1 Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric + proftar));
}
}
if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
if (high() >= (entpric + xstop)) {
Strategy.doCover("Short stp Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric + xstop));
}
}
if (Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
if (low() <= (entpric - xstop)) {
Strategy.doSell("Long stp Exit", Strategy.STOP, Strategy.THISBAR,
Strategy.getDefaultLotSize(), (entpric - xstop));
}
}
newtrade = 0;
//DebugPrintln("TEST FOR TRADE");
if(low() < low(-1) && low(-1) < low(-2) && Strategy.isInTrade() == false){
Strategy.doShort("GO SHORT", Strategy.MARKET, Strategy.Nextbar);
newtrade = 1;
DebugPrintln("GO SHORT");
}
if(high() > high(-1) && high(-1) > high(-2) && Strategy.isInTrade() == false){
Strategy.doLong("GO LONG", Strategy.MARKET, Strategy.Nextbar);
newtrade = 1;
DebugPrintln("GO LONG");
}
}
Comment