Error 4107/130 even with Normalizedouble and *Point....Can sb. help?

Back to topics list To post a new topic, please log in or register
avatar
22
TTromberino 2016.01.29 15:34
 

Hi guys,

i have a problem again:

I get this Error 4107 every time. The funfact is, that sometimes he opens an order with it.

I searched in the forum and in the internet and found out, that i have to use NormalizeDouble(x,Digits), but this didn´t work.

Then i normalized my SL and now i get an Error 130 on my SL. I even used *Point to make sure i get no false variables.

Maybe you know what i´m doing wrong:

The whole code is a bit longer, but here are the ordersend-relevant functions:

int start(){

.....

//---Stoplossdefinition    
      if(OrderType() == OP_BUY || OrderType() == OP_BUYSTOP) stoploss = st1_long - abst;
      if(OrderType() == OP_SELL || OrderType() == OP_SELLSTOP) stoploss = st1_short + abst; 
      NormalizeDouble(stoploss,Digits());     
       
//--- Trailingstoploss
      if(OrdersTotal() > 0){Trailingstoploss();}
      OpenLongOrderatBBModify();
      OpenShortOrderatBBModify();
      
//--- Closing Trades: 
      if(OrdersTotal() > 0){
         if(rsi1 < 30 && rsi0 > 30)
         {
            ClosingTrades();
         }
         if(rsi1 > 70 && rsi0 < 70)
         {
            ClosingTrades();
         }
       }

//--- Ordercounter
      int ord,i;
      string symbol;
      total = OrdersTotal();
      for(i=0;i<total;i++)
      {
      OrderSelect(i,SELECT_BY_POS);
      if(OrderSymbol() == Symbol()) ord++;
      }
      if(ord>0) return (0); //Abort! A Position For This Pair is Already Open

               
//--- Initializing Orders
      if(long_st() == true){
         if(ord == 0){
            if(Close[1] < BBUP) OpenLongOrderatBB();
            if(Close[1] > BBUP) OpenLongOrderMarket();
         }
      }
      if(short_st() == true){
         if(ord == 0){
            if(Close[1] < BBDN) OpenShortOrderatBB();
            if(Close[1] > BBDN) OpenShortOrderMarket();
         }
      }

......

}

      st1_long = iCustom(NULL,0,"SuperTrend1",st1,st2,0,1);
      st1_short = iCustom(NULL,0,"SuperTrend1",st1,st2,1,1);
      st2_long = iCustom(NULL,0,"SuperTrend1",st1,st2,0,2);
      st2_short = iCustom(NULL,0,"SuperTrend1",st1,st2,1,2);
      
      
      BBUP = iBands(NULL,0,iboll,2,2,PRICE_CLOSE,MODE_UPPER,0);
      BBDN = iBands(NULL,0,iboll,2,2,PRICE_CLOSE,MODE_LOWER,0);


void OpenLongOrderatBB(){
   new_del();
   ordersend = OrderSend(NULL,OP_BUYSTOP,Lots,NormalizeDouble(BBUP,Digits()),slippage,stoploss*Point,takeprofit,"Open Pending Long Order at upper Bollinger Band",magicnumber,0,Green);
   if(ordersend < 0) Alert("OrderSend ERROR LongOrder at BB NOT opened! ", GetLastError());
   else Print("Opened LongOrder: ",OrderMagicNumber()," on ",OrderSymbol(), "Lots: ",OrderLots()," StopLoss: ",OrderStopLoss()," TakeProfit: ",OrderTakeProfit());

   }

void OpenLongOrderatBBModify(){
      for(int i=0;i<=total-1;i++) {
      if(OrderSelect(i,SELECT_BY_TICKET)       // Part soll dafür sorgen, dass nur 1 Position pro Signal eröffnet wird. 
         && OrderType() == OP_BUYSTOP
         && OrderSymbol() == Symbol()
         && OrderCloseTime()==0  //Trailingstop, der auf Basis des SuperTrend Indikators nachgezogen werden soll. (Nur für Long)
         && OrderType()==OP_BUYSTOP ) {
            if(OrderOpenPrice() < BBUP) {
               ordermodify = OrderModify(OrderTicket(),NormalizeDouble(BBUP,Digits()),stoploss*Point,takeprofit,0);
               if (ordermodify == false)
                  Print("Stoploss ",OrderTicket()," NICHT nachgezogen! ERROR!");
               else
                  Print("StopLoss ",OrderTicket()," nachgezogen");
            }
         }
      }
   }

......

void Trailingstoploss(){
   //--- Trailingstoploss: 
      for(int i=0;i<=total-1;i++) {
      if(OrderSelect(i,SELECT_BY_POS)       // Part soll dafür sorgen, dass nur 1 Position pro Signal eröffnet wird. 
         && OrderType() == OP_BUY
         && OrderSymbol() == Symbol()
         && OrderCloseTime()==0) {
            if(OrderStopLoss()<stoploss) {
               ordermodify = OrderModify(OrderTicket(),OrderOpenPrice(),stoploss*Point,takeprofit,0);
               if (ordermodify == false)
                  Print("Stoploss ",OrderTicket()," NICHT nachgezogen! ERROR!");
               else
                  Print("StopLoss ",OrderTicket()," nachgezogen");
            }
         }
      }
      
      for(int i=0;i<=total-1;i++) {
      if(OrderSelect(i,SELECT_BY_POS)       // Part soll dafür sorgen, dass nur 1 Position pro Signal eröffnet wird. 
         && OrderType() == OP_SELL
         && OrderSymbol() == Symbol()
         && OrderCloseTime()==0) {
            if(OrderStopLoss() > stoploss) {
               ordermodify = OrderModify(OrderTicket(),OrderOpenPrice(),stoploss*Point,takeprofit,0);
               if (ordermodify == false)
                  Print("Stoploss ",OrderTicket()," NICHT nachgezogen! ERROR!");
               else
                  Print("StopLoss ",OrderTicket()," nachgezogen");
            }
         }
      }            

.........


The whole code is attached.

Hope you find the error cause i don´t know what i did wrong in the ordersend/ordermodifyfunctions.


Best regards and best for the last days in january

ttromberino


Attached files:
  neuertversuchyneu.mq4  (15.36 KB)
Back to topics list  

To add comments, please log in or register