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

 
int start()
{
if(OrdersTotal() !=0) return;

//----
if (iOpen(NULL,5,0)-Bid>Delta*Point) //The price has dropped more than Delta points
........


 
zhuki:
if(OrdersTotal ()!=0) return;

What about other people's orders (using other symbols and magicians)? In the tester, it will work, but if there is something else on the account besides this EA, the correct way is as follows

bool NmbrOfOpened(int Magic){
 
   int  _OrdersTotal=OrdersTotal();
 
   if (_OrdersTotal>0) {
       for (int i=0; i<_OrdersTotal; i++) {    
         OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
         if (OrderMagicNumber()==Magic && OrderSymbol()==Symbol()) {
            return(true);  break; 
         }
       }
   }
   else return(false); 
 return(false);
}

The function will return false if there is no position opened by the current symbol with the specified (passed to it) magician.

 
You are going to mislead the guy, and he cannot read the descriptions.
Imagine how confused he will be, that's why I wrote it in such a way that he would understand it better.
 
Very good, I'm getting the hang of it :))
Both cases caught up, thank you very much.
 
Only with Expert Advisor I still do not understand how the Delta function works
Deals are not triggered under my conditions
Delta=30
It means I want my Expert Advisor to open position +-30 in pips. But it opens at 5-10 pips up and down, it is not clear....
 
Really, the Delta function just doesn't know how it works :(
Maybe there are some other simple solutions?
I have found one function
Distance=30 // Distance from current price to pending order price
Can it be implemented not only for pending orders?
The idea is the same: keep track of the current bar, its open price and if during a 5 min bar its price will either increase or decrease by, say, 30 pips from the open market of that 5 min bar, only then open a position......
My strategy does not work with pending orders.....

 

And you would post your whole code here. And see why Delta doesn't work...

 
//+------------------------------------------------------------------+
//|                                                Expert-000001.mq4 |
//|                                    Copyright © 2008, salesman*** |
//|                                         http://www.forexgrand.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, salesman***"
#property link      "http://www.forexgrand.ru"
#include <WinUser32.mqh>
#include <stdlib.mqh>
extern double StopLoss=30;                        // Stop Loss
extern double TakeProfit=3;                       // Take Profit
extern double Lots=0.5;                           // Объем сделки в %
extern double Slippage =3;                        // Максимальное отклонение от запрошенной цены
extern double MagicNumber=0;                      // Order ID
int  ticket;
int Delta=30;                                     // Сигнал приказа в пунктах
int TimeForSleep = 10;                            // Время для отдыха после сделки

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
if(OrdersTotal()!=0)  return; //Выполнять только одну сделку.

//----
if (iOpen(NULL,0,0)-Ask>=Delta*Point) //Цена упала больше или = Delta пунктов
//Null-тек инструмент, 0-тек.график, 0-слежка за тек баром
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"Купил",MagicNumber,11111,Green);

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




//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

Here is the whole code.....
 

Yes indeed. Delta.... does not work

Apparently, here it is necessary with signs (polarity) of a Delta to understand at buying and at sale, "for" in the code above, for example, at buying value(iOpen(NULL,0,0)-Ask all time will be negative. And the trade is opened at the open price of the bar (iOpen(NULL,0,0)-Ask>=Delta...

If you try it this way (buy) -

if (Ask - iOpen(NULL,0,0)>=Delta*Point) //Цена выросла на больше или = Delta пунктов
 
i.e. eventually we need to test this variant:

int start()
{
if(OrdersTotal()!=0) return; //Follow only one trade.

//----
if (Bid - iOpen(NULL,0,0)<=Delta*Point) //The price fell by less or = Delta points
//Null-tek instrument, 0-tek.chart, 0-tracking tek bar
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point, "Buy",MagicNumber,11111,Green);

}
if (Ask - iOpen(NULL,0,0)>=Delta*Point) //The price rose by more or = Delta points
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point, "Sold",MagicNumber,22222,Green);
}
//----
return(0);
}
Am I guessing correctly or did I mix up Ask with Bid in lines:
if (Bid - iOpen(NULL,0,0)<=Delta*Point) //Цена упала на меньше или = Delta пунктов

if (Ask - iOpen(NULL,0,0)>=Delta*Point) //Цена выросла на больше или = Delta пунктов
Reason: