I wrote an *.EFS for parabolic, so that I can get sell/buy signals, if the parabolic crosses.
But the parabolic is not shown in my chart, and also the *efs donĀ“t work.
I will get my first signal, when the parabilc crosses the first time, and the additional signals, if crosses.
can anybody help me?
var study = new ParabolicStudy(0.06, 0.06, 0.2);
var thisTrade = 0; //-1 SHORT, 1 LONG,
var onTrade = 0; //0 NO, 1 YES
var nNewTrade; //New Trade Trigger 0 = OFF , 1 = ON
var nsignal; //returns the direction of the trading signal
function preMain() {
setPriceStudy(true);
setPlotType(PLOTTYPE_LINE)
setDefaultBarThickness(1);
}
function main() {
var value = study.getValue(ParabolicStudy.STOP);
/*if(value == null)
return;*/
if(value >= open()) { //Buy Condition
nNewTrade = 1; //New Trade Triger
nsignal = +1; //Buy Signal
}
if(value <= close()) { //Sell Condition
nNewTrade = 1; //New Trade Triger
nSignal = -1; //Sell Signal
}
// execute trades only if nNewTrade is triggered
if (nNewTrade == 1) { //Execute new Trade, new or reversed trade position
if (Strategy.isInTrade() == true) {
if ((nsignal > 0) && (Strategy.isShort() == true)) {
Strategy.doCOVER("EXIT", Strategy.CLOSE, Strategy.THISBAR);
Strategy.doLONG("ReversLONG", Strategy.CLOSE, Strategy.THISBAR);
drawTextRelative(0, low(), "B", Color.black, Color.lime, Text.FRAME | Text.ONTOP | Text.BOLD, null, 9);
}
if ((nsignal < 0) && (Strategy.isLong() == true)) {
Strategy.doSELL("EXIT" , Strategy.CLOSE, Strategy.THISBAR);
Strategy.doSHORT("ReversSHORT", Strategy.CLOSE,Strategy.THISBAR);
drawTextRelative(0, high(), "S", Color.black, Color.red, Text.FRAME | Text.ONTOP | Text.BOLD, null, 9);
}
} else { // not in trade now
if ((nsignal > 0)) {
Strategy.doLONG("GoLONG", Strategy.CLOSE, Strategy.THISBAR);
}
if ((nsignal < 0)) {
Strategy.doSHORT("GoSHORT", Strategy.CLOSE, Strategy.THISBAR);
}
} // end if IN TRADE
nNewTrade = 0; // Turn off NEW TRADE switch
} // End execute Trade
return value;
}
best wishes, Torso
But the parabolic is not shown in my chart, and also the *efs donĀ“t work.
I will get my first signal, when the parabilc crosses the first time, and the additional signals, if crosses.
can anybody help me?
var study = new ParabolicStudy(0.06, 0.06, 0.2);
var thisTrade = 0; //-1 SHORT, 1 LONG,
var onTrade = 0; //0 NO, 1 YES
var nNewTrade; //New Trade Trigger 0 = OFF , 1 = ON
var nsignal; //returns the direction of the trading signal
function preMain() {
setPriceStudy(true);
setPlotType(PLOTTYPE_LINE)
setDefaultBarThickness(1);
}
function main() {
var value = study.getValue(ParabolicStudy.STOP);
/*if(value == null)
return;*/
if(value >= open()) { //Buy Condition
nNewTrade = 1; //New Trade Triger
nsignal = +1; //Buy Signal
}
if(value <= close()) { //Sell Condition
nNewTrade = 1; //New Trade Triger
nSignal = -1; //Sell Signal
}
// execute trades only if nNewTrade is triggered
if (nNewTrade == 1) { //Execute new Trade, new or reversed trade position
if (Strategy.isInTrade() == true) {
if ((nsignal > 0) && (Strategy.isShort() == true)) {
Strategy.doCOVER("EXIT", Strategy.CLOSE, Strategy.THISBAR);
Strategy.doLONG("ReversLONG", Strategy.CLOSE, Strategy.THISBAR);
drawTextRelative(0, low(), "B", Color.black, Color.lime, Text.FRAME | Text.ONTOP | Text.BOLD, null, 9);
}
if ((nsignal < 0) && (Strategy.isLong() == true)) {
Strategy.doSELL("EXIT" , Strategy.CLOSE, Strategy.THISBAR);
Strategy.doSHORT("ReversSHORT", Strategy.CLOSE,Strategy.THISBAR);
drawTextRelative(0, high(), "S", Color.black, Color.red, Text.FRAME | Text.ONTOP | Text.BOLD, null, 9);
}
} else { // not in trade now
if ((nsignal > 0)) {
Strategy.doLONG("GoLONG", Strategy.CLOSE, Strategy.THISBAR);
}
if ((nsignal < 0)) {
Strategy.doSHORT("GoSHORT", Strategy.CLOSE, Strategy.THISBAR);
}
} // end if IN TRADE
nNewTrade = 0; // Turn off NEW TRADE switch
} // End execute Trade
return value;
}
best wishes, Torso
Comment