Please can you help me with this EA. Should be easy for experienced MQL4 programmer.Thanks!!

 
Hey! I am running multiple EAs on multiple time frames, now I have coded these EAs myself... I have coded these EAs to only enter one trade at a time... But as soon as this trade has closed, I want It to put in another trade if paramenters are still correct, so how can you tell the EA that the trade that has just been entered has closed ? You cant use the TotalOrders() function because that interferes with my other EAs and their trades.

So can you please help me to somehow code my EA to know when the trade it entered has closed and has to reinitialise its parameters and set the total trades back to 0 ....


Thanks so much !

Code :
//+------------------------------------------------------------------+
//| Xlr8eSoft Probability Trader.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Xlr8er"
#property link "https://www.metaquotes.net//"
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
extern int Total_Orders_EA = 1;
extern int Open_Percentage = 80 ;
extern int Close_Percentage = 40 ;
extern int Take_Profit = 13 ;
extern int Stop_Loss = 15 ;
int PMI ;
string TI ;
int buy ;
int sell ;
extern int Max_Order_Count = 5;
extern double Slippage = 3;
extern int Magic_Number = 10810 ;
extern double Lots = 0.05 ;
int Total = 0;

int init()
{
//----


int Total = 0;


//----
return(0);
}

int start()
{
//-


iCustom(NULL, 0, "MEGATREND PROBABILITY METER II",13,7,0) ;



Print( GetLastError());
string Probability_Value = ObjectDescription("prop_value");


PMI = StrToDouble(StringSubstr(Probability_Value,0,StringLen(Probability_Value)-1));


TI = ObjectDescription("trend_comment_");
Print ("Succesful no 4.5");
buy = StringFind(TI,"LONG",0);
sell = StringFind(TI,"SHORT",0);



Print("BUYSELL",buy, sell);


Print(PMI,Probability_Value );






if(Total_Orders_EA > Total )
{


Print( GetLastError());
if(PMI > Open_Percentage && buy != -1)


{
OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask - Stop_Loss * Point,Ask + Take_Profit * Point,"Xlr8eBot",0,0,Green);
Total ++ ;


}
}







if(Total_Orders_EA > Total)
{
if(PMI > Open_Percentage && sell != -1)

{
OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid + Stop_Loss * Point,Ask - Take_Profit * Point,"Xlr8eBot",0,0,Red);


Total ++ ;

}
}


//----
return(0);
}

//+------------------------------------------------------------------+
 

I am also getting the error : Memory handler : cannot allocate 630892 bytes of memory ...

any idea how I can clear the memory my EA uses now and then and re-load it... I do have enough physical memory as I have 16GB gaming RAM in my pc and 40GB virtual RAM so I dont think Its realy the memory thats running out... any ideas, has anyone seen this before?

 
I think something like this will let you know if an order has just closed...

   static int LastHistoryCount;
   if (LastHistoryCount!=OrdersHistoryTotal())
      {
       Alert("Order Closed");
       closet=iTime(NULL,0,0);
      }

   LastHistoryCount=OrdersHistoryTotal();
Memory problems are above my pay grade though...
V
 

what is closet ? it is not defined ?


Thanks :)

 
Sorry, it's a code snippit from one of my EA's. it's a variable I define elsewhere. Just a datetime so I can track the how recently my last trade closed. I'm the opposite to you, if a trade closes, I want to make sure I don't re enter on the same bar.
 

hello,

I need assistance of some MQL programmer.. I have an indicator,.. can some one please help in creating the EA for that..

Your help will be highly appreciated