Please help me:
This code isn´t working, and I don´t know why.
And: how can I add that there is only one entry at the same bar
possible?
thanks for any support
martin
----------------------------------------------------------------------------------
function preMain() {
BARSTATE_ALLBARS;
setPriceStudy(true);
setStudyTitle("Breakout");
}
function main() {
var LongLimitPrice = high(-1) +0.8
var LongStopLoss = high(-1) -0.8
var ShortLimitPrice = low(-1) -0.8
var ShortStopPrice = low(-1) +0.8
if (Strategy.isInTrade() == false && high(0) > high(-1))
onAction1()
else if (Strategy.isInTrade() == false && low(0) < low(-1))
onAction2()
function onAction1(){
Strategy.doLong("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT);
if (Strategy.isLong == true){sellStop(getSymbol(), 100,LongStopLoss) || sellLimit(getSymbol(), 100, LongLimitPrice );}
}
return onAction1();
function onAction2(){
Strategy.doShort("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT);
if (Strategy.isShort == true) {sellShortStop(getSymbol(), 100, SellShortStop) || sellShortLimit(getSymbol(), ShortLimitPrice);}
}
return onAction2();
}
This code isn´t working, and I don´t know why.
And: how can I add that there is only one entry at the same bar
possible?
thanks for any support
martin
----------------------------------------------------------------------------------
function preMain() {
BARSTATE_ALLBARS;
setPriceStudy(true);
setStudyTitle("Breakout");
}
function main() {
var LongLimitPrice = high(-1) +0.8
var LongStopLoss = high(-1) -0.8
var ShortLimitPrice = low(-1) -0.8
var ShortStopPrice = low(-1) +0.8
if (Strategy.isInTrade() == false && high(0) > high(-1))
onAction1()
else if (Strategy.isInTrade() == false && low(0) < low(-1))
onAction2()
function onAction1(){
Strategy.doLong("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT);
if (Strategy.isLong == true){sellStop(getSymbol(), 100,LongStopLoss) || sellLimit(getSymbol(), 100, LongLimitPrice );}
}
return onAction1();
function onAction2(){
Strategy.doShort("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT);
if (Strategy.isShort == true) {sellShortStop(getSymbol(), 100, SellShortStop) || sellShortLimit(getSymbol(), ShortLimitPrice);}
}
return onAction2();
}
Comment