I am having a problem with some code where the long exit strategy is working correctly but the short exit strategy is not.
The problem with the short side is the trade is exited immediately after it is entered, is there anything I am missing here?
I've just added the second exit strategy using or statement (myExecutionPrice) prior to this addition everything was working correctly.
Here's my code;
// If we have a long position and the price is below offset for long (stop-loss) then immediately exit at market (code is in indicator) if (Position.MarketPosition == MarketPosition.Long) { if(this.CR(5, 4).TradePosition == 0 || lastPrice <= myExecutionPrice - (5 * TickSize)) { // Checks to see if our Stop Order has been submitted already //if (stopOrder != null) //{ // Modifies stop-loss to an immediate exit stopOrder = ExitLong("long entry"); //} } } // If we have a short position and the price is above offset for short (stop-loss) then immediately exit at market (code is in indicator) if (Position.MarketPosition == MarketPosition.Short) { if(this.CR(5, 4).TradePosition == 0 || lastPrice >= myExecutionPrice + (5 * TickSize)) { // Checks to see if our Stop Order has been submitted already //if (stopOrder != null) //{ // Modifies stop-loss to an immediate exit stopOrder = ExitShort("short entry"); //} } }
suprsnipes
Comment