{
//---
g_Point=Point;
if(Digits==5 || Digits==3)
{
g_Point *= 10;
Slippage*=10;
}
static datetime previousBar;
if(previousBar!=Time[0])
{
previousBar=Time[0];
ChartRedraw();
}
else
{
return;
}
if(iVolume(Symbol(),PERIOD_H4,0)>iVolume(Symbol(),PERIOD_H4,1))
return;
//**********************************
if(!BytesToRead>0)
return;
int pos = -1 ;
for(int i = 0 ; i < BytesToRead - 1 ; i++)
{
if(!(data[i][0]<Time[0]))
break;
pos = i + 1;
}
//********************************
HideTestIndicators(true);
double wpr= iWPR(Symbol(),0,4,0);
double ao = iAO(Symbol(),0,0);
HideTestIndicators(false);
double level=NormalizeDouble(data[pos][1],Digits);
ObjectDelete("level");
MakeLine(level);
if(data[pos][1]>Open[0])
Comment("BUY - ", data[pos][1]);
if(data[pos][1]<Open[0])
Comment("SELL - ", data[pos][1]);
if(MarketInfo(Symbol(),MODE_SPREAD)>150)return;
int TB=0,TS=0;
for (i=0;i<OrdersTotal();i++){
xx=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicID){continue;}
if(OrderType()==0){TB++;}
if(OrderType()==1){TS++;}
}
if(pos>0)
{
if(CheckMarketBuyOrders()<70 && CheckMarketSellOrders()<70){
if(data[pos][1]>Open[0] && OP_BySignal == OFF)
if(IsBuyPinbar() && TB<Max_OP && (jamOP() || TB>0)){
double BuySL=NormalizeDouble(Ask - SL*g_Point,Digits);
double BuyTP=NormalizeDouble(Ask + TP*g_Point,Digits);
if(AccountFreeMarginCheck(Symbol(),OP_BUY,GetLots())>0)
{
ticket=OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,BuySL,BuyTP,"",MagicID,0,clrGreen);
if(TPLinier){ModifyTP(0,rata_price(0)+TP*g_Point);}
CloseSell();
}
}