normalized double not working

 

here normalizedouble is not working due to that im getting these errors..error 130 as un normalized values..

//+------------------------------------------------------------------+
//|                                                martin manual.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
double sl,tp,buyl,selll,lots,sls,tps,buyls,sellls,l1,l2,l3,l4;
int slp=21,tpp=11;
int OpenBuyOrders;
int OpenSellOrders;
int total,ticket2,ticket3,ticket;
int pot=0;
int poc,i,pocf;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
//int sto;
  // sto = MarketInfo(Symbol(), MODE_STOPLEVEL) + MarketInfo(Symbol(), MODE_SPREAD);
   //Print(sto);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {

  if(OrdersTotal()==1)
{
if(!OrderSelect(0,SELECT_BY_POS))
Print("orderselect failed with ",GetLastError());
pot=OrderType();
if(pot==0)
{
tp=NormalizeDouble((OrderOpenPrice()+tpp*Point+0.0002),Digits);
buyl=NormalizeDouble(OrderOpenPrice(),Digits);
selll=NormalizeDouble(OrderOpenPrice()-tpp*Point,Digits);
sl=NormalizeDouble((OrderOpenPrice()-slp*Point-0.0002),Digits);
RefreshRates();
OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,0);
}
else if(pot==1)
{
sls=NormalizeDouble(OrderOpenPrice()+slp*Point,Digits);
buyls=NormalizeDouble(OrderOpenPrice()+tpp*Point,Digits);
sellls=NormalizeDouble(OrderOpenPrice(),Digits);
tps=NormalizeDouble(OrderOpenPrice()-tpp*Point,Digits);

RefreshRates();
OrderModify(OrderTicket(),OrderOpenPrice(),sls,tps,0,0);
}
int fot=pot;
if(fot==0)
{
l1=NormalizeDouble(tp,4);Print(l1);
l2=NormalizeDouble(buyl,Digits);
l3=NormalizeDouble(selll,Digits);
l4=NormalizeDouble(sl,Digits);
}
else if(fot==1)
{
l1=NormalizeDouble(sls,Digits);Print(l1);
l2=NormalizeDouble(buyls,Digits);
l3=NormalizeDouble(sellls,Digits);
l4=NormalizeDouble(tps,Digits);
}
} //end of first if

RefreshRates();

  if (OrdersTotal()==1)
lots=0.03;
if(OrdersTotal()>1)
lots=lots*2;
//Print(lots);

  poc=poc();
RefreshRates();
if((pot==0 ||pot==2||pot==4)&& poc==0)
{
l1=NormalizeDouble(l1,Digits);
l2=NormalizeDouble(l2,Digits);
l3=NormalizeDouble(l3,Digits);
l4=NormalizeDouble(l4,Digits);
ticket2=OrderSend(Symbol(),5,lots,l3,3,l4,l1,0,0);
if(ticket2<0)
Print("sell stop error is",GetLastError(),l1+" ",l2+" ",l3+" ",l4);
if(ticket2>0)
{
//OrderSelect(ticket2,SELECT_BY_TICKET);
//OrderModify(ticket2,OrderOpenPrice(),sls,tps,0,0);
pot=5;
}
}
poc=poc();
RefreshRates();
 if ((pot==1||pot==3||pot==5)&& poc==0)
{
l1=NormalizeDouble(l1,Digits);
l2=NormalizeDouble(l2,Digits);
l3=NormalizeDouble(l3,Digits);
l4=NormalizeDouble(l4,Digits);
ticket3=OrderSend(Symbol(),4,lots,l2,3,l1,l4 ,NULL,0,0,0);
if(ticket3<0)
Print("buy stop error is",GetLastError());
if(ticket3>0)
{
pot=4;
//OrderSelect(ticket3,SELECT_BY_TICKET);
//OrderModify(ticket3,OrderOpenPrice(),sl,tp,0,0);
}
}
   return(0);
  }

int poc()
{
int pocf=0;
for(i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderType()==OP_BUYSTOP ||OrderType()==OP_SELLSTOP)
pocf++;
}
return(pocf);
}
 
ankit29030:

here normalizedouble is not working due to that im getting these errors..error 130 as un normalized values..

 

I haven't read your code, but - despite what documentation says - we never normalizedouble any price or any indicator data.
 
phi.nuts:
I haven't read your code, but - despite what documentation says - we never normalizedouble any price or any indicator data.

as the platform is not able to normalize values ordersend gives me 130 error inspite of providing good sl and tp..

WHATS THE OTHER WAY OF NORMALIZING THEM BEFORE PUTTING INTO PENDING ORDERS... 

 
ankit29030:

here normalizedouble is not working due to that im getting these errors..error 130 as un normalized values..

 

Why is it you get error 130 ???

Do you really think it is for wrong normalizedouble

ticket2=OrderSend(Symbol(),5,lots,l3,3,l4,l1,0,0);
if(ticket2<0)
Print("sell stop error is",GetLastError(),l1+" ",l2+" ",l3+" ",l4);

this is your code why shouldn't it be you get error 130 for wrong Ordersend ??

This case orderopenprice()   1.3300    sellstop

orderstoploss()   l4     1.3288   ????

ordertakeprofit()   l1    1.3324   ???? 

Reason: