How do I only open 1 single buy trade? - page 2

 
Ibrahim Konyali: I think you re trying to open only 1 order for every candle,

That isn't what OP asked. “I'm trying to make my EA to open a single long trade ONLY.”

 
William Roeder:

That isn't what OP asked. “I'm trying to make my EA to open a single long trade ONLY.”

Is there anyway to know if a trade is long or short through a if?

 
15112020: Is there anyway to know if a trade is long or short through a if?

Of course, but I can't answer since I don't know MT5 enough.

 
15112020:

Is there anyway to know if a trade is long or short through a if?

Yes, you can use PositionGetInteger(POSITION_TYPE) then check if its equal to POSITION_TYPE_BUY or  POSITION_TYPE_SELL.

 
You can say in the OnTick() function

      if PositionsTotal()<1
      && RSI[1]>70
      && RSI[0]<=70
trade.Sell(...)

And vise versa for buy
 
pennyhunter:
You can say in the OnTick() function

      if PositionsTotal()<1
      && RSI[1]>70
      && RSI[0]<=70
trade.Sell(...)

And vise versa for buy
Thank you guys. I solved that problem and now I got one more. I'm sorry for this, but this is so confusing. Is there a reason why using the last tick and the previous RSI tick value only works on the 1 minute chart and not on the 5 minute one? Because that's exactly what's happening right now. Y'all being kind and I'm here confused. Thank you a lot you guys.
Reason: