//+------------------------------------------------------------------+
//| %_Point.mq4 |
//| Verdi |
//| nemo811@mail.ru |
//+------------------------------------------------------------------+
// Ñêðèïò âûâîäèò % çàêðûòûõ ñäåëîê ñ ïðèáûëüþ íå áîëåå N_Point ïóíêòîâ îò îáùåãî ÷èñëà çàêðûòûõ îðäåðîâ
#property copyright "Verdi"
#property link "nemo811@mail.ru, www.mt4.ucoz.com"
#property show_inputs
extern int N_Point = 10;
extern bool Zero_Point = false; //Ó÷èòûâàòü (true) èëè íåò (false) ñäåëêè, çàêðûòûå â 0
int start()
{
int OrdClose=OrdClose_b();
int OrdCloseT=OrdCloseT_b();
double $3P=0;
if (OrdClose>0 && OrdCloseT>0)
{$3P=NormalizeDouble(OrdCloseT*100/OrdClose,2);}
Alert(" ",$3P," %\n www.mt4.ucoz.com");
return(0);
}
//+------------------------------------------------------------------+
int OrdCloseT_b()
{
int OrdCloseT=0;
double OrdOpenPrice=0;
double OrdClosePrice=0;
double OrdPrice=0;
double Zero=0;
int i;
for(i=OrdersHistoryTotal()-1;i>=0;i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == true)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
{
if(OrdOpenPrice<OrderOpenPrice())
{
OrdOpenPrice=OrderOpenPrice();
}
if(OrdClosePrice<OrderClosePrice())
{
OrdClosePrice=OrderClosePrice();
}
if(OrderType()==OP_BUY) OrdPrice=NormalizeDouble(OrdClosePrice-OrdOpenPrice,Digits);
if(OrderType()==OP_SELL) OrdPrice=NormalizeDouble(OrdOpenPrice-OrdClosePrice,Digits);
if (Zero_Point) Zero=NormalizeDouble(0,Digits); else Zero=NormalizeDouble(1*Point,Digits);
if(OrdOpenPrice>0 && OrdClosePrice>0 && OrdPrice>=Zero && OrdPrice<=NormalizeDouble(N_Point*Point,Digits))
{
OrdCloseT++;
}
}
}
OrdOpenPrice=0;
OrdClosePrice=0;
OrdPrice=0;
Zero=0;
}
return(OrdCloseT);
}
int OrdClose_b()
{
int OrdClose=0;
int i;
for(i=OrdersHistoryTotal()-1;i>=0;i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == true)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
{
OrdClose++;
}
}
}
return(OrdClose);
}
Comments