I have a simple breakout trading system, which enters on a stop when the price is above/below certain levels. I have also set the system to colour bars blue/red depending on whether the system is long/short.
I have discovered a puzzling inconsistency between this code and the strategy analyzer. I have written the code so that a long position can only be entered if the system is not already long. However, it appears that as far as strategy analyzer is concerned, this is not working properly. For example, I have one trade this morning where a trade was triggered, but the stop loss was hit on the same bar and the trade exited.
However the entry condition was also true on the following bar. The bar colouring code identified this and flagged the bars accordingly, but the strategy analyzer completely ignored the trade. My suspicion is that strategy analyzer may not be detecting that the trade on the previous bar has exited, though it may of course be something else.
The entry logic is:
if(high() > LastHigh && !Strategy.isLong()) {
Strategy.doLong("SHLong", Strategy.STOP, Strategy.THISBAR,Strategy.DEFAULT,LastHigh)
;}
The bar colouring code is:
if(Strategy.isLong()){
setPriceBarColor(Color.blue) ;}
Any suggestions?
I have discovered a puzzling inconsistency between this code and the strategy analyzer. I have written the code so that a long position can only be entered if the system is not already long. However, it appears that as far as strategy analyzer is concerned, this is not working properly. For example, I have one trade this morning where a trade was triggered, but the stop loss was hit on the same bar and the trade exited.
However the entry condition was also true on the following bar. The bar colouring code identified this and flagged the bars accordingly, but the strategy analyzer completely ignored the trade. My suspicion is that strategy analyzer may not be detecting that the trade on the previous bar has exited, though it may of course be something else.
The entry logic is:
if(high() > LastHigh && !Strategy.isLong()) {
Strategy.doLong("SHLong", Strategy.STOP, Strategy.THISBAR,Strategy.DEFAULT,LastHigh)
;}
The bar colouring code is:
if(Strategy.isLong()){
setPriceBarColor(Color.blue) ;}
Any suggestions?
Comment