can someone help me to correct this script? my EA keep re-order after my position hit TP/SL / close manually because the rule on strategy still valid. i really appreciate if you can help me to fix my problem, i want my EA only open 1 position and then stop open position for 4 hours to start new position again. this is the script from my EA. . .
int TotalOrdersCount()
{
int result=0;
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) result++;
}
return (result);
}
double AdvancedMM()
{
int i;
double AdvancedMMLots = 0;
bool profit1=false;
int SystemHistoryOrders=0;
for( i=0;i<OrdersHistoryTotal();i++)
{ OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY);
if (OrderMagicNumber()==MagicNumber) SystemHistoryOrders++;
}
bool profit2=false;
int LO=0;
if(SystemHistoryOrders<2) return(Lots);
for( i=OrdersHistoryTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY))
if (OrderMagicNumber()==MagicNumber)
{
if(OrderProfit()>=0 && profit1) return(Lots);
if( LO==0)
{ if(OrderProfit()>=0) profit1=true;
if(OrderProfit()<0) return(OrderLots());
LO=1;
}
if(OrderProfit()>=0 && profit2) return(AdvancedMMLots);
if(OrderProfit()>=0) profit2=true;
if(OrderProfit()<0 )
{ profit1=false;
profit2=false;
AdvancedMMLots+=OrderLots();
}
}
}
return(AdvancedMMLots);
}
can someone help me? thanks
int TotalOrdersCount()
{
int result=0;
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) result++;
}
return (result);
}
double AdvancedMM()
{
int i;
double AdvancedMMLots = 0;
bool profit1=false;
int SystemHistoryOrders=0;
for( i=0;i<OrdersHistoryTotal();i++)
{ OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY);
if (OrderMagicNumber()==MagicNumber) SystemHistoryOrders++;
}
bool profit2=false;
int LO=0;
if(SystemHistoryOrders<2) return(Lots);
for( i=OrdersHistoryTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS ,MODE_HISTORY))
if (OrderMagicNumber()==MagicNumber)
{
if(OrderProfit()>=0 && profit1) return(Lots);
if( LO==0)
{ if(OrderProfit()>=0) profit1=true;
if(OrderProfit()<0) return(OrderLots());
LO=1;
}
if(OrderProfit()>=0 && profit2) return(AdvancedMMLots);
if(OrderProfit()>=0) profit2=true;
if(OrderProfit()<0 )
{ profit1=false;
profit2=false;
AdvancedMMLots+=OrderLots();
}
}
}
return(AdvancedMMLots);
}
can someone help me? thanks