Hi,
I'm trying to understand the Function Parameter Class.
Please can you help me understand what is happening in this piece of code:
var fp2 = new FunctionParameter("nStopAmt", FunctionParameter.NUMBER);
fp2.setName("Stop Target Amount");
fp2.setLowerLimit(0.01);
fp2.setDefault(0.25);
}
In the body of the program, when a trade is opened, a stop level is set as follows:
if (nNewTrade == 1) { //Execute New Trade
// new or reversed trade position
if (Strategy.isInTrade() == true) {
if ((nsignal > 0) && (Strategy.isShort() == true)) {
Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.NEXTBAR);
Strategy.doLong("Rev Long", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = low(-1) - nStopAmt;
}
if ((nsignal < 0) && (Strategy.isLong() == true)) {
Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR);
Strategy.doShort("Rev Short", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = high(-1) + nStopAmt;
}
} else {
if ((nsignal > 0)) {
Strategy.doLong("Go Long", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = low(-1) - nStopAmt;
}
if ((nsignal < 0)) {
Strategy.doShort("Go Short", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = high(-1) + nStopAmt;
}
} // end if IN TRADE
} // END EXECUTE NEW TRADE
My question is, what is the value afforded to nStopAmt by the code. I don't understand the
fp2.setLowerLimit(0.01);
fp2.setDefault(0.25);
part of the Function Parameter Class.
Thanks in advance for your help.
Neil.
I'm trying to understand the Function Parameter Class.
Please can you help me understand what is happening in this piece of code:
var fp2 = new FunctionParameter("nStopAmt", FunctionParameter.NUMBER);
fp2.setName("Stop Target Amount");
fp2.setLowerLimit(0.01);
fp2.setDefault(0.25);
}
In the body of the program, when a trade is opened, a stop level is set as follows:
if (nNewTrade == 1) { //Execute New Trade
// new or reversed trade position
if (Strategy.isInTrade() == true) {
if ((nsignal > 0) && (Strategy.isShort() == true)) {
Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.NEXTBAR);
Strategy.doLong("Rev Long", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = low(-1) - nStopAmt;
}
if ((nsignal < 0) && (Strategy.isLong() == true)) {
Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR);
Strategy.doShort("Rev Short", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = high(-1) + nStopAmt;
}
} else {
if ((nsignal > 0)) {
Strategy.doLong("Go Long", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = low(-1) - nStopAmt;
}
if ((nsignal < 0)) {
Strategy.doShort("Go Short", Strategy.MARKET, Strategy.NEXTBAR);
nStopLevel = high(-1) + nStopAmt;
}
} // end if IN TRADE
} // END EXECUTE NEW TRADE
My question is, what is the value afforded to nStopAmt by the code. I don't understand the
fp2.setLowerLimit(0.01);
fp2.setDefault(0.25);
part of the Function Parameter Class.
Thanks in advance for your help.
Neil.
Comment