An advisor that would follow the rate on a five-minute chart with conditions after launch: - page 5

 
Made my code, it seems to compile, but will it work?

int start()
{


//----
if (iOpen(NULL,5,0)-Bid>Delta*Point) //Цена упала больше Delta пунктов
{
OrderSend(Symbol(),OP_BUY,Ask,5,0,Ask+TakeProfit*Point,0);

}
if (iOpen(NULL,5,0)-Bid<Delta*Point) //Цена выросла больше Delta пунктов
{
OrderSend(Symbol(),OP_SELL,Ask,5,0,Ask+TakeProfit*Point,0);
}
//----
return(0);
}


OrderSend(Symbol(),OP_SELL,Ask,5,0,Ask+TakeProfit*Point,0);
Эту строку вытащил из другого эксперта. А что означают в ней цифры 5 и 0?
 
You are irreparable, read the help, it's all there.
 
Eventually made into what, it's something, but it doesn't work...... :(
What's wrong?

//+------------------------------------------------------------------+
//|                                                Expert-000001.mq4 |
//|                                    Copyright © 2008, salesman*** |
//|                                         http://www.forexgrand.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, salesman***"
#property link      "http://www.forexgrand.ru"
extern int StopLoss=12;                         // Stop Loss
extern int TakeProfit=3;                        // Take Profit
extern int Percent=100;                         // Объем сделки в %
extern int Delta=30;                            // Сигнал приказа в пунктах
extern string _Comment = "Money-money-money";    // Комментарий к ордеру
extern int MagicNumber =55555;                  // Order ID
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{


//----
if (iOpen(NULL,5,0)-Bid>Delta*Point) //Цена упала больше Delta пунктов
{
OrderSend(Symbol(),OP_BUY,Ask,5,0,Ask*Point,0);

}
if (iOpen(NULL,5,0)-Bid<Delta*Point) //Цена выросла больше Delta пунктов
{
OrderSend(Symbol(),OP_SELL,Ask,5,0,Ask*Point,0);
}
//----
return(0);
}
//+------------------------------------------------------------------+
 
Although the face on the chart smiles...... doesn't work. Tried it on the pound.
 

Function OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

Parameters: symbol - Name of the financial instrument being traded.

cmd - The trade operation. Can be any of the trading operation values.

volume - Number of lots.

price - Opening price. slippage - Maximum allowed price deviation for market orders (Buy or Sell orders).

Stoploss - The price to close a position when the loss is reached (0 if there is no loss).

Takeprofit - The price to close a position when the profitability level is reached (0 if there is no profitability level).

comment - Order comment text. The last part of the comment can be changed by the trading server.

magic - The magic number of the order. Can be used as a user-defined identifier.

expiration - Expiration time of the pending order.

arrow_color - Color of the opening arrow on the chart. If the parameter is missing or its value is CLR_NONE, the opening arrow is not shown on the chart.

Where do you have it? - You have some fragment instead of OrderSend


#property copyright "Copyright © 2008, salesman и группа лиц "
#property link      "http://www.forexgrand.ru"
extern int StopLoss=12;                         // Stop Loss
extern int TakeProfit=3;                        // Take Profit
extern int Percent=100;                         // Объем сделки в %
extern int Delta=30;                            // Сигнал приказа в пунктах
extern int MagicNumber =55555;                  // Order ID
int  ticket;
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"My order #",MagicNumber,0,Green);

 

And what is the result of the Ask*Point calculation here:

OrderSend(Symbol(),OP_SELL,Ask,5,0,Ask*Point,0);
???
 
I don't have...... working for some reason.
Here is full code:
//+------------------------------------------------------------------+
//|                                                Expert-000001.mq4 |
//|                                    Copyright © 2008, salesman*** |
//|                                         http://www.forexgrand.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, salesman***"
#property link      "http://www.forexgrand.ru"
extern int StopLoss=12;                          // Stop Loss
extern int TakeProfit=3;                         // Take Profit
extern int Percent=70;                           // Объем сделки в %
extern int Slippage = 3;                         // Максимальное отклонение от запрошенной цены
extern int Delta=2;                              // Сигнал приказа в пунктах
extern string _Comment = "Money-money-money";    // Комментарий к ордеру
extern int MagicNumber =55555;                   // Order ID
int  ticket;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{


//----
if (iOpen(NULL,5,0)-Bid>Delta*Point) //Цена упала больше Delta пунктов
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"My order #",MagicNumber,0,Green);

}
if (iOpen(NULL,5,0)-Bid<Delta*Point) //Цена выросла больше Delta пунктов
{
ticket=OrderSend(Symbol(),OP_SELL,1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"My order #",MagicNumber,0,Green);
}
//----
return(0);
}
//+------------------------------------------------------------------+


For a quick test I set Delta=2

extern int Delta=2;


Maybe you can implement this to understand the errors:

//+------------------------------------------------------------------+
bool IsCondition()
  {
   bool result=true;
   string field="     ";
   string msg;
   string title="Ошибка"; if (AccountNumber()>0)title=AccountNumber()+": "+title;
   if (!IsConnected())
     {
      msg=msg+"Связь с сервером отсутствует"+field;
      result=false;
     }
   if (!IsTradeAllowed())
     {
      if (!result) msg=msg+"\n";
      msg=msg+"Торговля запрещена"+field;
      result=false;
     }
   if (!result) MessageBox(msg,title,MB_OK|MB_ICONERROR);
   return(result);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ShowError()
  {
   string description;
   int err=GetLastError();
   switch(err)
     {
      case   0: return;
      case   1: description="Нет ошибки, но результат неизвестен"; break;
      case   2: description="Общая ошибка"; break;
      case   3: description="Неправильные параметры"; break;
      case   4: description="Торговый сервер занят"; break;
      case   5: description="Старая версия клиентского терминала"; break;
      case   6: description="Нет связи с торговым сервером"; break;
      case   7: description="Недостаточно прав"; break;
      case   8: description="Слишком частые запросы"; break;
      case   9: description="Недопустимая операция нарушающая функционирование сервера"; break;
      case  64: description="Счет заблокирован"; break;
      case  65: description="Неправильный номер счета"; break;
      case 128: description="Истек срок ожидания совершения сделки"; break;
      case 129: description="Неправильная цена"; break;
      case 130: description="Неправильные стопы"; break;
      case 131: description="Неправильный объем"; break;
      case 132: description="Рынок закрыт"; break;
      case 133: description="Торговля запрещена"; break;
      case 134: description="Недостаточно денег для совершения операции"; break;
      case 135: description="Цена изменилась"; break;
      case 136: description="Нет цен"; break;
      case 137: description="Брокер занят"; break;
      case 138: description="Новые цены"; break;
      case 139: description="Ордер заблокирован и уже обрабатывается"; break;
      case 140: description="Разрешена только покупка"; break;
      case 141: description="Слишком много запросов"; break;
      case 145: description="Модификация запрещена, так как ордер слишком близок к рынку"; break;
      case 146: description="Подсистема торговли занята"; break;
      case 147: description="Использование даты истечения ордера запрещено брокером"; break;
      default : description="Неизвестная ошибка"; break;
     }
   string field="     ";
   string msg="Ошибка #"+err+" "+description+field;
   string title="Ошибка"; if (AccountNumber()>0)title=AccountNumber()+": "+title;
   MessageBox(msg,title,MB_OK|MB_ICONERROR);
  }
// End
//+------------------------------------------------------------------+
 
salesman77:
It's not working for me for some reason......
Here is the full code:
if (iOpen(NULL,5,0)-Bid>Delta*Point) //Цена упала больше Delta пунктов
{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"My order #",MagicNumber,0,Green);

}
if (iOpen(NULL,5,0)-Bid<Delta*Point) //Цена выросла больше Delta пунктов
{
ticket=OrderSend(Symbol(),OP_SELL,1,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"My order #",MagicNumber,0,Green);
}
//----
return(0);
}
//+------------------------------------------------------------------+


Actually OrderSend for buying and for selling are written slightly differently. Because we buy at Ask price and sell at Bid price ! And closing by stops as well... With you - all at the same price ...
In addition, lot=1 is intended to work here. Does your deposit correspond to this size? And what does the log say - why isn't it working?
 

You do not know the difference between Bid and Ask, you do not understand the difference between a short position and a long position. You have no idea what a Stop Loss and Take Profit is. You do not understand what you have already written. You are trying to code by gut feeling. Who can help you???? Learn the basics. All questions have been answered. I don't see the point in quoting a textbook.

 
salesman77:
It's not working for me for some reason......
For a quick test I set Delta=2

extern int Delta=2;


What for? Do you know how to use a tester?

I knew a guy once. He'd been trading forex for a year and he still thought a long position was one that stayed in the market for a long time. And a short position is one that's, like, a pipsqueak position.

What do you think?

Reason: