Jason, many thanks for your prompt and clear reply.
Still more questions:
19. Follow up of question 16: Brad is using 'bPosition' in Sample_TargetStop.efs (see attached) to 'prevent new entry on the same bar that an exit trade occured'. I still do not see the reason to this prevention. Even if I did a close of a trade on Current bar, I should still be able to generate a New Signal on the Same Current bar (like a Reversal) because the buy/sell will be done on the NEXTBAR anyway.
20. strMA-Pcrsv_NEXBAR.efs (and others) do not paint the bars on BackTest, as expected from the code. Is it normal? Only on PaperTrade the bar painting works? See code below:
var study = new MAStudy(40, 0, "Close", MAStudy.SIMPLE);
function preMain() {
setPriceStudy(true);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
var v = study.getValue(MAStudy.MA);
if(v == null)
return;
if(close() >= v && !Strategy.isLong())
Strategy.doLong("Crossing Up", Strategy.MARKET, Strategy.NEXTBAR); //AA
if(close() < v && !Strategy.isShort())
Strategy.doShort("Crossing Down", Strategy.MARKET, Strategy.NEXTBAR); //AA
if(Strategy.isLong())
setPriceBarColor(Color.lime);
else if(Strategy.isShort())
setPriceBarColor(Color.red);
return v;
}
Thanks, Arie
Still more questions:
19. Follow up of question 16: Brad is using 'bPosition' in Sample_TargetStop.efs (see attached) to 'prevent new entry on the same bar that an exit trade occured'. I still do not see the reason to this prevention. Even if I did a close of a trade on Current bar, I should still be able to generate a New Signal on the Same Current bar (like a Reversal) because the buy/sell will be done on the NEXTBAR anyway.
20. strMA-Pcrsv_NEXBAR.efs (and others) do not paint the bars on BackTest, as expected from the code. Is it normal? Only on PaperTrade the bar painting works? See code below:
var study = new MAStudy(40, 0, "Close", MAStudy.SIMPLE);
function preMain() {
setPriceStudy(true);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
var v = study.getValue(MAStudy.MA);
if(v == null)
return;
if(close() >= v && !Strategy.isLong())
Strategy.doLong("Crossing Up", Strategy.MARKET, Strategy.NEXTBAR); //AA
if(close() < v && !Strategy.isShort())
Strategy.doShort("Crossing Down", Strategy.MARKET, Strategy.NEXTBAR); //AA
if(Strategy.isLong())
setPriceBarColor(Color.lime);
else if(Strategy.isShort())
setPriceBarColor(Color.red);
return v;
}
Thanks, Arie
Comment