Download MetaTrader 5

4051 ,1 errors,etc

To add comments, please log in or register
Add our Facebook page to friends. Follow the latest news!
pascalboy
238
pascalboy 2013.12.11 17:26 
int start()
{
//IF ORDER'S TOTAL NUMBER BELOW TWO OPEN PENDING ORDERS  
while(OrdersTotal()<2)
{
   int Emiral=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,3,Ask-500*Point,Ask+1000*Point,0);
   int Emirsat=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,3,Bid+500*Point,Bid-1000*Point,0);
}


///////////////////////////////////////
//IF THERE ARE MARKET ORDERS 
for(int i=1;i<OrdersTotal();i++)
   if(OrderSelect(i-1,SELECT_BY_POS)==true)
      if (OrderType()==0 || OrderType()==1)        
         //IF THERE ARE OP_BUYSTOP OR OP_SELLSTOP ORDERS 
         for(i=1;i<OrdersTotal();i++)
            if(OrderSelect(i-1,SELECT_BY_POS)==true)
               if(OrderType()==3  || OrderType()==5) 
//ERASE LAST SELECTED PENDING  ORDER 
int SilinecekEmirNumarasi=OrderTicket();
   OrderDelete(SilinecekEmirNumarasi);     

//IF THERE IS A OP_BUY ORDER SELECT IT
for(i=1;i<OrdersTotal();i++)
   if(OrderSelect(i-1,SELECT_BY_POS)==true)
      if(OrderType()==0)
         {
         int AcikAlimEmriNo=OrderTicket();
         int AcikAlimEmriAcilisFiyati=OrderOpenPrice();
         int AcikAlimEmriZararDurdur=OrderStopLoss();
         int AcikAlimEmriKarAl=OrderTakeProfit();
         int AcikAlimEmriTipi=OrderType();
         }  
// IF THERE IS A OP_SELL ORDER SELECT IT  
       if(OrderType()==1)
         {
         int AcikSatimEmriNo=OrderTicket();
         int AcikSatimEmriAcilisFiyati=OrderOpenPrice();
         int AcikSatimEmriZararDurdur=OrderStopLoss();
         int AcikSatimEmriKarAl=OrderTakeProfit();
         int AcikSatimEmriTipi=OrderType();
         }   
         
//IF ASK PRICE IS ABOVE OR EQUAL TO ORDEROPEN PRICE MODIFY ORDER 'S STOPLOSS AS ORDEROPENPRICE          
if(OrderType()==0 && Ask>=  AcikAlimEmriAcilisFiyati && Ask<=AcikAlimEmriAcilisFiyati+10)       
   OrderModify(AcikAlimEmriNo,0,AcikAlimEmriAcilisFiyati,0,0,0);            
        
//IF BID  PRICE IS BELOW OR EQUAL TO  ORDEROPEN PRICE MODIFY ORDER 'S STOPLOSS AS ORDEROPENPRICE   if(OrderType()==1 && Bid<=  AcikSatimEmriAcilisFiyati && Bid>=AcikSatimEmriAcilisFiyati+10)       
   OrderModify(AcikSatimEmriNo,0,AcikSatimEmriAcilisFiyati,0,0,0);             




///EMİRLERİ SINIRLARA GÖRE MODİFİYE ET


return;
}

hello friends,

i hope you are very good .

there are "4051 errors","order ticket not found errors "at this comic program.

modification errors,deleting errors .etc.

i know stoplevel and freeze point logic .when i add or subtract stoplevel for stoploss points error 130 added.

why does not programming love me? :)

thanks bye .

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.12.11 17:44  
pascalboy:

hello friends,

i hope you are very good .

there are "4051 errors","order ticket not found errors "at this comic program.

modification errors,deleting errors .etc.

i know stoplevel and freeze point logic .when i add or subtract stoplevel for stoploss points error 130 added.

why does not programming love me? :)

thanks bye .

Add some { } braces to make your like easier and clearer . . .

               if(OrderType() == 3  || OrderType() == 5)   //  if this . . .
//ERASE LAST SELECTED PENDING  ORDER 
int SilinecekEmirNumarasi=OrderTicket();   //  do this . . .

 OrderDelete(SilinecekEmirNumarasi);   //  do this regardless of the if . . .


what are 3 and 5 ? use the correct constant names so we don't have to guess . . .


return correctly from an int type function . . . return an int.

Don't you want to know if your trading functions fail ? and if they do fail what the error was ?

What are Function return values ? How do I use them ?

whroeder1
14512
whroeder1 2013.12.11 18:01  
And you MUST count down when deleting/closing Loops and Closing or Deleting Orders - MQL4 forum
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.12.13 13:07  
pascalboy:
Hello Raptor UK. Thanks again for helpfull knowledges. Is it possible to open orders with a logic " as soon as the ask/bid levels passes over the orderopenprice,modify orderstoploss as orderopenprice. Does stoplevels let this order. At 2011 championship there was a program by "Tim Fass" and i think it was without stoplevels. Is it possible? Do stoplevels and freezepoints differ at championships from the real life?
The Stoplevel and Freezelevel are set by your Broker, I don't know what setting/simulation was used for the Championships. Don't confuse Stoplevel with Stop Loss. . . they are very different things.

If you want to know what will work without giving errors in terms of OrderSend, OrderModify and Stoplevel and Freezelevel read and understand this article, it has all the information you need but is quite detailed so needs some time studying it: Requirements and Limitations in Making Trades
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.12.14 12:20  

pascalboy:

i am making mistakes but cannot find why .



Plus 10 what ?

Ask<=AcikAlimEmriAcilisFiyati   + 10)   // 10 what ? 
whroeder1
14512
whroeder1 2013.12.14 16:00  
   OrderModify(AcikSatimEmriNo,0,AcikSatimEmriAcilisFiyati,0,0,0)
  1. What are Function return values ? How do I use them ? - MQL4 forum
  2. How do you expect to modify the order price to ZERO?
  3. Why are you trying to only modify the last one (modifies are outside the loop)
whroeder1
14512
whroeder1 2013.12.14 16:34  
pascalboy: .i couldn't find the connection with my program.where can be the mistake?
There are none in your program.
pascalboy
238
pascalboy 2013.12.14 19:46  
int start()
{
//IF ORDER'S TOTAL NUMBER BELOW TWO OPEN PENDING ORDERS  
while(OrdersTotal()<2)
{
   int Emiral=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,3,Ask-500*Point,Ask+1000*Point,0);
   int Emirsat=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,3,Bid+500*Point,Bid-1000*Point,0);
}


///////////////////////////////////////
//IF THERE ARE MARKET ORDERS 
for(int i=OrdersTotal();i<=1;i--)
{
   if(OrderSelect(i,SELECT_BY_POS))
      if (OrderType()==OP_BUY || OrderType()==OP_SELL) 
      {
         Print(".............",OrderType());
                //IF THERE ARE OP_BUYSTOP OR OP_SELLSTOP ORDERS 
         for(i=OrdersTotal();i<=1;i--)
            if(OrderSelect(i,SELECT_BY_POS))
//ERASE LAST SELECTED PENDING  ORDER 
               if(OrderType()==OP_BUYSTOP )
               int OpBuySilinecekEmirNumarasi=OrderTicket();
               OrderDelete(OpBuySilinecekEmirNumarasi);  
               if(OrderType()==OP_SELLSTOP)   
               int OpSellSilinecekEmirNumarasi=OrderTicket();
               OrderDelete(OpSellSilinecekEmirNumarasi);   
      }
}     

//IF THERE IS A OP_BUY ORDER SELECT IT
for(i=1;i<OrdersTotal();i++)
{
   if(OrderSelect(i-1,SELECT_BY_POS))
      if(OrderType()==OP_BUY)
         {
         int AcikAlimEmriNo=OrderTicket();
         int AcikAlimEmriAcilisFiyati=OrderOpenPrice();
         int AcikAlimEmriZararDurdur=OrderStopLoss();
         int AcikAlimEmriKarAl=OrderTakeProfit();
         int AcikAlimEmriTipi=OrderType();
         }  
// IF THERE IS A OP_SELL ORDER SELECT IT  
       if(OrderType()==OP_SELL)
         {
         int AcikSatimEmriNo=OrderTicket();
         int AcikSatimEmriAcilisFiyati=OrderOpenPrice();
         int AcikSatimEmriZararDurdur=OrderStopLoss();
         int AcikSatimEmriKarAl=OrderTakeProfit();
         int AcikSatimEmriTipi=OrderType();
         }   
}         
//IF ASK PRICE IS ABOVE OR EQUAL TO ORDEROPEN PRICE MODIFY ORDER 'S STOPLOSS AS ORDEROPENPRICE          
if(OrderType()==OP_BUY && Ask>=  AcikAlimEmriAcilisFiyati && Ask<=AcikAlimEmriAcilisFiyati+10*Point)       
   OrderModify(AcikAlimEmriNo,AcikAlimEmriAcilisFiyati,0,0,0,0);            
        
//IF BID  PRICE IS BELOW OR EQUAL TO  ORDEROPEN PRICE MODIFY ORDER 'S STOPLOSS AS ORDEROPENPRICE   if(OrderType()==1 && Bid<=  AcikSatimEmriAcilisFiyati && Bid>=AcikSatimEmriAcilisFiyati+10)       
if(OrderType()==OP_SELL && Bid<=  AcikSatimEmriAcilisFiyati && Bid>=AcikSatimEmriAcilisFiyati-10*Point)          
   OrderModify(AcikSatimEmriNo,AcikSatimEmriAcilisFiyati,0,0,0);             




///EMİRLERİ SINIRLARA GÖRE MODİFİYE ET


return;
}



//IF ORDER'S TOTAL NUMBER BELOW TWO OPEN PENDING ORDERS  
while(OrdersTotal()<2)
{
   int Emiral=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,3,Ask-500*Point,Ask+1000*Point,0);
   int Emirsat=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,3,Bid+500*Point,Bid-1000*Point,0);
}


///////////////////////////////////////
//IF THERE ARE MARKET ORDERS 
for(int i=OrdersTotal();i<=1;i--)
{
   if(OrderSelect(i,SELECT_BY_POS))
      if (OrderType()==OP_BUY || OrderType()==OP_SELL) 
      {
         Print(".............",OrderType());
                //IF THERE ARE OP_BUYSTOP OR OP_SELLSTOP ORDERS 
         for(i=OrdersTotal();i<=1;i--)
            if(OrderSelect(i,SELECT_BY_POS))
//ERASE LAST SELECTED PENDING  ORDER 
               if(OrderType()==OP_BUYSTOP )
               int OpBuySilinecekEmirNumarasi=OrderTicket();
               OrderDelete(OpBuySilinecekEmirNumarasi);  
               if(OrderType()==OP_SELLSTOP)   
               int OpSellSilinecekEmirNumarasi=OrderTicket();
               OrderDelete(OpSellSilinecekEmirNumarasi);   
      }
}     
pascalboy
238
pascalboy 2013.12.14 19:52  

Hi Raptor,

I am unable to erase pending orders.

I tought about the cycle but no errors.

Why ?

Tjipke de Vries
6315
Tjipke de Vries 2013.12.14 20:37  


pascalboy:

Hi Raptor,

I am unable to erase pending orders.

I tought about the cycle but no errors.

Why ?

for(int i=OrdersTotal();i<=1;i--)
{
 Print ("i = ",i);
} 

Suppose your OrdersTotal() is equal to 10

what will this function print ???

whroeder1
14512
whroeder1 2013.12.14 21:02  
pascalboy: I am unable to erase pending orders.
You were told some things to change You didn't (latter half) You have only two choices: learn to code it, or pay someone. We're not going to code it FOR you.
12
To add comments, please log in or register