MT4 EA help please and thank you

Hello everybody. I have not programmed for a long time. I cannot recall how to make an EA only open 1 trade per bar.

Here is an example EA I am playing with (the trading strategy is not the focus because it is bad). It is a basic MA crossover with RSI. However, I want it to open an order under the criteria, then wait for another bar. If 10 bars later it has another cross, it will open another order. As you will see, to keep the visuals simple, I only have basic information on the EA for now. Thank you for any coding and language assistance.

//------------------------------------

extern int MagicNumber = 1234;
extern double Lots = 1;
extern double TakeProfit = 40;
extern double StopLoss = 30;
extern double TrailingStop = 0;
extern double FMA = 10;
extern double SMA = 100;
extern string SoundAlert = “alert.wav”;
datetime CheckTime,
CheckEntryTime,
CrossTime;
static int TimeFrame = 0;

//±-----------------------------------------------------------------+
//| expert initialization function |
//±-----------------------------------------------------------------+

int start()
{
int cnt, ticket, total;

if(Bars<100)
{
Print(“bars less than 100”);
return(0);
}
// to simplify the coding and speed up access
// data are put into internal variables

double Fast1=iMA(NULL,0,FMA,0,1,0,1);
double Fast2=iMA(NULL,0,FMA,0,1,0,2);
double Slow1=iMA(NULL,0,SMA,0,1,0,1);
double Slow2=iMA(NULL,0,SMA,0,1,0,2);
double Rsi=iRSI(NULL,0,14,PRICE_CLOSE,0);

total=OrdersTotal();
if(total<10)
{
{
if(CheckEntryTime==iTime(NULL,TimeFrame,0)) return(0); else CheckEntryTime = iTime(NULL,TimeFrame,0);
}
if(AccountFreeMargin()<(1Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if(Fast2<Slow2 && Fast1>Slow1 && Rsi>50)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-(StopLoss
Point),Ask+TakeProfit*Point,“Good Luck”,MagicNumber,0,Green);
PlaySound(SoundAlert);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
}
}
// the end.

Mate, if you don’t have any luck here, might i suggest you have a look at
Jim Dandy MQL4 You tube channel
or go to Stack Exchange and ask the same question.