[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 150

 

Afternoon.

I need a EURUSD m5/m15 history from before 2009, can anyone share theirs? (i.e. the one on which you debug your experts).

I would be very grateful.

 
ewoke:

Afternoon.

I need a EURUSD m5/m15 history from before 2009, can anyone share theirs? (i.e. the one on which you debug your experts).

I would be very grateful.

Press F2 with your terminal open, then go to Fx Majors -> EURUSD -> 1 Minute (M1) -> Download.

 
paladin80:
The opening curly bracket { should be placed before price[...]=Ask; (see below). Read again about "if" operator. If there is no parenthesis immediately after if, it handles only one action (you have price[...]=Ask;), if several actions are required, they must be placed in {...} immediately after if.

Thank you.But I put brackets right after the if statement as you suggested,
but it didn't change anything. See the screenshot - it shows that the EA opened a buy position
and the price went down and crossed the levels of 1.2100 and 1.2200 and positions by the operator

if to open buy positions at 1.2100 and 1.2200 - did not open.


 
alex12:
Thanks, but I put brackets right after the if statement, as you suggested,
but it didn't change anything. See the screenshot - it shows that the Expert Advisor opened a buy position
and the price went down and crossed the levels of 1.2100 and 1.2200 and the positions by the operator condition

if to open buy positions at 1.2100 and 1.2200 - did not open.


isn't it necessary to put return operator after ordersend to finish the processing of the tick?
 
alex12:
Thanks, but I put brackets right after the if statement, as you suggested,
but it did not change anything. see the screenshot - it shows that the EA opened a buy position
and the price went down and crossed levels 1.2100 and 1.2200 and positions according to the statement

If to open buy positions at 1.2100 and 1.2200 - they did not open.

Do you open the first position manually or do you want the pending orders to be placed after the price has crossed some level and then, based on its presence? Try it this way:
if (OrdersTotal()>0)
{  for (int i=OrdersTotal()-1; i>=0; i--)
   {  if (OrderSelect(SELECT_BY_POS,MODE_TRADES)
      {  if (OrderSymbol()!=Symbol())  continue;
         if (OrderType()==OP_BUYLIMIT) return(0);
}  }  }

if (OrdersTotal()>0)
{  for (i=OrdersTotal()-1; i>=0; i--)
   {  if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {  if (OrderSymbol()!=Symbol()) continue;
         if (OrderType()==OP_BUY)
         {  for (int j=0; j=10-1; j++}
            {  OrderSend (Symbol(),OP_BUYLIMIT,Lot,price[j],10,0,Ask+g*Point,"My order #",11+j);
               Sleep(10*1000);
      }  }  }
}  }
Of course, we still need error handling in case a pending order is rejected by DC.
 
OlegTs:
Shouldn't we put return operator after ordersend to end tick processing?

Thank you. I put return operator after ordersend and nothing has changed.


extern double Lot=1;
int g=20; //тейкпрофит
double price[10];   // Заданный уровень 
//-----------------------
int init()
  {
double price[10];   // объявляем массив из 5 элементов           
price[0] = 1.2100; // обращаемся к первому элементу массива и 
                   // присваиваем ему цену. Обратите внимание 
                   // на то, что индекс первого элемента 
                   // начинается с 0. Это важная особенность,
                   // к которой нужно привыкнуть.   
price[1] = 1.2200;  // обращаемся ко второму элементу 
price[2] = 1.2300;  // и так далее 
price[3] = 1.2400; 
price[4] = 1.2500;
price[5] = 1.2600; 
price[6] = 1.2700;  
price[7] = 1.2800; 
price[8] = 1.2900;
price[9] = 1.3000;  
   return(0);
  }
//---------------
int start()
   {
// начало открытия ордеров 
   if (OrdersTotal()>0)return(0);

   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==False)//проверка наличия откр.поз
   {
   price[0]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2100,10,0,Ask+g*Point,"My order #",11);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[1]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2200,10,0,Ask+g*Point,"My order #",12);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[2]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2300,10,0,Ask+g*Point,"My order #",13);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[3]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2400,10,0,Ask+g*Point,"My order #",14);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[4]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2500,10,0,Ask+g*Point,"My order #",15);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[5]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2600,10,0,Ask+g*Point,"My order #",16);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[6]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2700,10,0,Ask+g*Point,"My order #",17);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[7]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2800,10,0,Ask+g*Point,"My order #",18);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[8]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2900,10,0,Ask+g*Point,"My order #",19);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[9]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.3000,10,0,Ask+g*Point,"My order #",20);return;
   }
      return(0);
  }
//+------------------------------------------------------------------+
 
paladin80:
Do you open the very first position manually or do you want the pending orders to be opened when the price reaches a certain level and then, based on it? Try the following:. Of course, we need more error handling in case a pending order is rejected by DC.

If the price reaches a certain level and then opens a position at the levels defined in the orders.

It turns out we have one position on one level - until it closes at the same time.

 
alex12:

...

One pose at a time on the same level - until they close on the current.

A risky strategy, I wouldn't mess around with it.
 
paladin80:
Do you open the first position manually or do you want the pending orders to be placed after the price has crossed a certain level? Try this: There is no error handling in case your brokerage company rejects a pending order.

Thanks for the tip code of course, but as I'm not a very good programmer I couldn't find the error:'}' - unclosed parentheses

I looked through your code in Notepad++ in zoomed in and could not correct the error.

I see. I'm interested in the code itself, not the TS.

It generates the error '}'. - unbalanced parentheses

I don't know how to fix it.

extern double Lot=1;
int g=20;          //тейкпрофит
double price[5];   // Заданный уровень 
//-----------------------
int init()
  { 
double price[]={1.2100,1.2200,1.2300,1.2400,1.2500}; // объявляем массив из 5 элементов  
   return(0);
  }
//---------------
int start()
   {
// начало открытия ордеров 
   if (OrdersTotal()>0)return(0);  
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==False)//проверка наличия откр.поз
   {
   price[0]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2100,10,0,Ask+g*Point,"My order #",11);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[1]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2200,10,0,Ask+g*Point,"My order #",12);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[2]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2300,10,0,Ask+g*Point,"My order #",13);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[3]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2400,10,0,Ask+g*Point,"My order #",14);return;
   }
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==True)//проверка наличия откр.поз
   {
   price[4]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2500,10,0,Ask+g*Point,"My order #",15);return;
   }
   if (OrdersTotal()>0)
   {  
   for (int i=OrdersTotal()-1;i>=0;i--)
   {  
   if (OrderSelect(SELECT_BY_POS,MODE_TRADES)
   { 
   if (OrderSymbol()!=Symbol()) continue;
         
   if (OrderType()==OP_BUYLIMIT) return(0);
   } 
   }
   }
   if (OrdersTotal()>0)
   { 
   for (i=OrdersTotal()-1;i>=0;i--)
   {  
   if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
   { 
   if (OrderSymbol()!=Symbol()) continue;
   if (OrderType()==OP_BUY)
   {
   for (int j=0;j=5-1;j++}
   { 
   OrderSend (Symbol(),OP_BUYLIMIT,Lot,price[j],10,0,Ask+g*Point,"My order #",11+j);
   Sleep(10*1000);
   } 
   } 
   }
   } 
   }
      return(0);
   }
//+------------------------------------------------------------------+
 

Can you tell me why the EA does not open a position when testing, I don't understand why - I think I wrote the code correctly.

extern double Lot=1;
//--------------------------------------------------------------------
int g=20; //тейкпрофит
double price[5];   // Заданный уровень 
//--------------------------------------------------------------------
int init()
  { 
double price[]={1.2100,1.2200,1.2300,1.2400,1.2500}; // объявляем массив из 5 элементов  
   return(0);
  }
//---------------
int start()
   {
   double WMA0=iEnvelopes(NULL,0,1,MODE_SMMA,0,PRICE_WEIGHTED,0.001,MODE_PLUSDI,0);
   double WMA1=iEnvelopes(NULL,0,1,MODE_SMMA,0,PRICE_WEIGHTED,0.001,MODE_PLUSDI,0);
   double WMA2=iEnvelopes(NULL,0,1,MODE_SMMA,0,PRICE_WEIGHTED,0.001,MODE_PLUSDI,0);
   double WMA3=iEnvelopes(NULL,0,1,MODE_SMMA,0,PRICE_WEIGHTED,0.001,MODE_PLUSDI,0);
   double WMA4=iEnvelopes(NULL,0,1,MODE_SMMA,0,PRICE_WEIGHTED,0.001,MODE_PLUSDI,0);

   // начало открытия ордеров 
   if (OrdersTotal()>0)return(0);// не открывает новые пока не закроются открытые
   
   if (price[0]<WMA0&&price[0]>WMA0) //Buy
   {                           
   price[0]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2100,10,0,Ask+g*Point,"My order #",1);return;
   }
   else
      if (price[1]<WMA1&&price[1]>WMA1) //Buy
   {                           
   price[1]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2200,10,0,Ask+g*Point,"My order #",2);return;
   }
   else
      if (price[2]<WMA2&&price[2]>WMA2) //Buy
   {                           
   price[2]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2300,10,0,Ask+g*Point,"My order #",3);return;
   }
   else
      if (price[3]<WMA3&&price[3]>WMA3) //Buy
   {                           
   price[3]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2400,10,0,Ask+g*Point,"My order #",4);return;
   }
   else
      if (price[4]<WMA4&&price[4]>WMA4) //Buy
   {                           
   price[4]=Ask;
   OrderSend (Symbol(),OP_BUY,Lot,1.2500,10,0,Ask+g*Point,"My order #",5);return;
   }

return(0);
} 
/////////////////////////////////////////////////////////////////////////////////////////
Reason: