Create simple RSI EA help!

 
Can someone create an Simple RSI EA for me that opens only just one trade every signal ? (For example  it opens only one buy position on signal with tp and sl and then wait for a sell signal signal and opens a sell position with sl and tp). I tried finding other EA's that might have this function but couldn't find any i even tried making my own with a little coding knowledge. I succeeded in making the EA working but it opens multiple positions on one signal like (it opens buy position on signal and when its filled it opens another buy on the same signal) but i want it to wait for an opposite signal. Basically like zig zag but one position per signal. Sorry if this is confusion i hope u get the idea. 
I want it for mt5  i would really appreciate if anyone will help me out or even just tell me the code for it thanks!!
 

You can search the codebase for RSI EAs. Or try to fix your EA and show the code here if it doesn't work. The code to limit the Buys/Sells to a certain number is easy to implement.

int CountOpenBuys()
 {
   int buys=0;
   for(int i=PositionsTotal()-1;i>=0;i--)
     {
      if(PositionGetSymbol(i)!=_Symbol || PositionGetInteger(POSITION_MAGIC)!=MagicID) continue;
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) buys++;
     }
   return buys;
 }
 
lippmaje:

You can search the codebase for RSI EAs. Or try to fix your EA and show the code here if it doesn't work. The code to limit the Buys/Sells to a certain number is easy to implement.

thanks alot. I'll let you know if it works.
 
lippmaje:

You can search the codebase for RSI EAs. Or try to fix your EA and show the code here if it doesn't work. The code to limit the Buys/Sells to a certain number is easy to implement.

i think you didnt get the idea. My EA does open only one position on a signal but the thing is i keep my Take profit really low so it gets filled really quick but after the position is closed it opens another on the "still going on buy signal"  but i want it to open a position on the other signal the opposite one or a different buy signal. Is there any way to do that? I hope u get it.
 
lippmaje:

You can search the codebase for RSI EAs. Or try to fix your EA and show the code here if it doesn't work. The code to limit the Buys/Sells to a certain number is easy to implement.

This is the EA by the way. Can you fix it?
Files:
 
RSI indicator - the thread with many indicators and so on.
 
FaizanXG:
This is the EA by the way. Can you fix it?

We can assist you in fixing but the job is on you. I recommend to try an EA from Sergey's thread, and adapt it to your needs where required.

      CopyBuffer(myRSIDefinition,0,0,3,myRSIArray);
      
      // calculate the curernt RSI Value
      double myRSIValue=NormalizeDouble(myRSIArray[0],2);

After that copy command your buffer looks like so: [0] -> RSI of 2nd last candle, [1] -> RSI of last candle, [2] -> RSI of current candle. Either copy only one value and get it from [0], or leave it as is and get the current RSI from [2].

Reason: