Did you code this yourself? I’m no expert but these bits of code seem to contradict your description.
if((iRSIMQL4(NULL,0,Prd,PRICE_CLOSE,00)<Sell)) // Here is your open Sell rule
{
if(StopLoss>0) TheStopLoss=SymbolInfoDouble(_Symbol,SYMBOL_ASK)+StopLoss*MyPoint;
if(TakeProfit>0) TheTakeProfit=SymbolInfoDouble(_Symbol,SYMBOL_ASK)-TakeProfit*MyPoint;
trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,TradeSizeOptimized(),SymbolInfoDouble(_Symbol,SYMBOL_BID),TheStopLoss,TheTakeProfit);
return;
}
and
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
{
if((iRSIMQL4(NULL,0,Prd,PRICE_CLOSE,00)>Sellstop)) // here is your close sell rule
{
trade.PositionClose(ticket);
break;
Plus the weird bit that stands out is that it looks like an attempted conversion of an MQL4 to 5 code? The syntax is in the form of MQL4 and not MQL5. Also not sure how declaring the MAs, Stoch and Timeframes are supposed to help either.
I’m not an expert but the codes looks very messy and doesn’t appear to fulfill the described function. I’d code one from scratch if I were you and get rid of redundant lines of code and avoid conversion errors (try compiling the code). Probably the best place to try is the MQL5 forum.