I have a simple strategy to perform reversal trading based on opposite signal. I have included a signalname for my entry orders and trying to exit the particula orders based on the signal name. My default entries per direction is 1. I did backtesting with market order and functionality worked perfectly. When i try to test it in paper account with live market data, it is not working as expected. Strategy is missing the signals and not taking trades, only one trade is executed per day and that trade is closed at the end of session. Could you please check the code snippet and suggest?
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
// Condition set 1
if (RMheikinashi(Length).BullIndication[0] == true && Position.MarketPosition != MarketPosition.Flat)
{
if(Position.MarketPosition != MarketPosition.Long)
{
//EnterLong();
EnterLongLimit(DefaultQuantity, lastP, "longEntryHA1");
Print(" HA is Buy - Enter Long" );
}
}
// Condition set 2
if (RMheikinashi(Length).BearIndication[0] == true && Position.MarketPosition != MarketPosition.Flat)
{
if(Position.MarketPosition != MarketPosition.Short)
{
//EnterShort();
EnterShortLimit(DefaultQuantity, lastP, "shortEntryHA1");
Print(" HA is Sell - Enter Short" );
}
}
//Reversal signals
// Condition set 3
if (RMheikinashi(Length).BearIndication[0] == true && Position.MarketPosition != MarketPosition.Flat)
{
if(Position.MarketPosition == MarketPosition.Long)
{
//ExitLong();
ExitLongLimit(lastP, "", "longEntryHA1");
Print(" HA is Sell - Exit Long" );
}
}
// Condition set 4
if (RMheikinashi(Length).BullIndication[0] == true && Position.MarketPosition != MarketPosition.Flat)
{
if(Position.MarketPosition == MarketPosition.Short)
{
//ExitShort();
ExitShortLimit(lastP, "", "shortEntryHA1");
Print(" HA is Buy - Exit Short" );
}
}
}
Comment