Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1174

 
Valeriy Yastremskiy:

OrderSelect on the ticket has been made earlier. The order is pending. How to get the order to be marketable, other than by checking the order type on every tick. In the logs, this time is recorded, but it seems that the field for this time in the order structure is not provided, or am I wrong? When we change the order type, OrdersTotal() and OrdersHistoryTotal also don't change, if I understand correctly.

I think that everything else is somewhat clearer)

Have you tried OrderOpenTime? I do not even remember if it changes when a position is triggered.

I do not know when it is necessary to check if the pending order has triggered every tick(and not before key action or every 1...5 min), but MT4 has no other way.

In MT5 it's more convenient. In OTT you find out about the transaction, if you need to work with lists you do the processing in OTT

 
datetime some_time=TimeCurrent();

extern string Symbol3 = ""; //Инструмент (""текущий по умолчанию)

extern double P=15;       //Таймфрейм

int start()

{

//Инициализация переменных

bool  FractalsUp=false;

bool  FractalsDown=false;

int   FractalsUpPrice=0;

int   FractalsDownPrice=0;

int   FractalsLimit=100;

double EMA=iMA(NULL,P,5,3,MODE_EMA,PRICE_CLOSE,0);

   //Цикл сканирования последних свечей FractalsLimit, начиная с самых старых и заканчивая самыми последними.

   for (int i=FractalsLimit; i>=0; i--)

{

      //Если на свече есть фрактал, значение будет больше нуля и будет равно самой высокой или самой низкой цене.

      double fu=iFractals(NULL,0,MODE_UPPER,i);

      double fl=iFractals(NULL,0,MODE_LOWER,i);

      //Если есть верхний фрактал, я сохраняю значение и устанавливаю true для переменной FractalsUp.

      if(fu>0)

{

FractalsUp=true;

FractalsDown=false;

FractalsUpPrice=fu;



if (((Close[0])>fu)&&(OrdersTotal() == 0)&&(Close[0]>Open[0])&&(Close[0]>High[1]&&(Close[0]>EMA))) 

{  

if ((OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS, MODE_HISTORY)==true))

{

datetime Cd=OrderCloseTime();

int hd=+iBarShift(Symbol3,P,Cd)+1;

if (hd<=2)

{

return(-1);

}

}



metka1();

}

}

//Если есть нижний фрактал, я сохраняю значение и устанавливаю true для переменной FractalsDown.

      if(fl>0)

{

FractalsUp=false;

FractalsDown=true;

FractalsDownPrice=fl;

if (((Close[0])<fl)&&(OrdersTotal() == 0)&&(Close[0]<Open[0])&&(Close[0]<Low[1]&&(Close[0]<EMA))) 

{  

if ((OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS, MODE_HISTORY)==true))

{

datetime Cd1=OrderCloseTime();

int hd1=+iBarShift(Symbol3,P,Cd1)+1;

if (hd1<=2)

{

return(-1);

}

}

metka2();

}

}

      //Если свеча имеет верхний и нижний фрактал, значения сохраняются, но мы не считаем его последним фракталом.

      if(fu>0 && fl>0)

{

         FractalsUp=false;

         FractalsDown=false;

         FractalsUpPrice=fu;        

         FractalsDownPrice=fl;

}

}

return(0);

}

int metka1()

{              

int send1=OrderSend(Symbol3,OP_BUY,0.01,Ask,3,Bid-70*Point,Bid+70*Point);

return(0);

}

int metka2()

{                        

int send2=OrderSend(Symbol3,OP_SELL,0.01,Bid,3,Ask+70*Point,Ask-70*Point);

return(0);

}

Good afternoon!

I am working on an owl on fractals. There is a problem. Help. The essence is this:

The script searches for the last top or bottom fractal from the last 100 candlesticks with variable [FractalsLimit=100;] and opens BUY position - if a fractal is broken through, and vice versa for SELL.

The last 100 candlesticks should be used to find the maximum or minimum fractals and open a position. It means, it focuses only on the maximal and minimal fractals, not on the last ones.

Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
Aleksey Mavrin:

Have you tried OrderOpenTime? I don't remember if it changes when a pending order is triggered.

I don't know when it is necessary to check every tick(and not before key actions or every 1...5...minutes) if a pending order has triggered, but there is no other way to do it in MT4.

In MT5 it's more convenient. In OTT, you learn about conducting a transaction. If you need to work with lists, you will conduct processing in OTT.

OrderOpenTime shows the time of pending order opening. It's a question of understanding the operation more. So, the time is written to the log and the journal and is not shown anywhere else. Respectively, if we haven't fixed it, then we can view it later, according to the fact)))))

If I understand correctly, it will be opening of position / deal in MT5. Although I don't understand the division into order/trade/position as an optimal solution, but there is more data, of course.

 
Aleksey Mavrin:

it happens)) 1 gets very lost in the background of English letters l i etc., it is more convenient to call then suffixes 001, 2... etc.

I see what you mean) corrected the mistake, now the value of the second handle is 1,0. If you put a larger timeframe in the first handle than in the second handle, the value of the second handle is 0. Can you please tell me what else I need to fix to get the second handle value right?

void OnTick()
  {
   double PriceArray[];
   
   int AOhandle = iAO(_Symbol,PERIOD_M15);
   
   ArraySetAsSeries(PriceArray, true);
   
   CopyBuffer(AOhandle, 0, 0, 3, PriceArray);
   
   double AOvalue = NormalizeDouble(PriceArray[0], 6);

   double PriceArray01[];
   
   int AOhandle01 = iAO(_Symbol,PERIOD_H1);
   
   ArraySetAsSeries(PriceArray01, true);
   
   CopyBuffer(AOhandle01, 1, 0, 3, PriceArray01);
   
   double AOvalue01 = NormalizeDouble(PriceArray01[0], 6);
    
   Comment ("Awesome Oscillator Value: ", AOvalue, "\n", "\n",
            "Awesome Oscillator Value: ", AOvalue01);
  }
 
Valeriy Yastremskiy:

OrderOpenTime shows the opening time of the pending order. It's a question of understanding the operation more. It turns out that the time is recorded in the log and the journal and is not reflected anywhere else. Accordingly, if we have not fixed it, then we can look later, according to the fact)))))

You have been bringing up this issue for a week. I offered to review the principles of placing orders in the trading strategy

but if this issue is important to you, it is not a problem to "fix" it with a readjustment of one tick.

If you want to try it, you'll have to do it with a certain speed, but if you don't have a real tick, you'll probably end up with a lot of errors, because the speed of placing pending orders is much higher.


What I would like to propose to study is theCArrayInt SB https://www.mql5.com/ru/docs/standardlibrary/datastructures/carrayint

in CArrayInt you will add tickets and this data type will allow you to easily delete "tickets which became marketable".


as I wrote above accuracy - 1 tick, the check code will be minimal

Valeriy Yastremskiy:

In MT5 it will be a position / trade opening, if I understand correctly. Although I don't understand the division to order / deal / position as an optimal solution, but there is more data of course.

If you can write for MT5 - then why are we discussing it? the platform is more powerful, the functionality is higher - comparing MT4 and MT5 makes no sense, MT4 is easier to enter, but MT5 has more features

 
Igor Makanu:

You have been raising this issue since a week, I suggested you to reconsider the principles of placing orders in the trading strategy


I still do not understand. The strategy is of course different. The question comes from the fact that quite an important event is only reflected in the log. And no one directly answered that there is nowhere but the log of the time when an order became marketable))))

And the logic of the strategy does not depend on the terminal. If the logic is lame, then you can certainly make it up, but the limp will not go away))))

 
Valeriy Yastremskiy:

It remains unclear. The strategy is of course different. The question comes from the fact that a rather important event is only reflected in the log. And no one has directly answered that there is nowhere other than the log of the time when the order became market))))

no this information - nooooo!!!

importance... well it does matter to you, before that, how many years of writing strategies and how it worked, even in profit ;)

as a rule, do not place many pending orders, follow market orders, if necessary, add a pending order - pending orders become market orders

we use everything - averaging, pyramiding, orders grid and ... and lots... I do not remember these antics on traders forums, I haven't read them for more than a year now - I have more of my own thoughts than other people's )))

 
Igor Makanu:

there is no such information - nooooo!!!

importance... well it is important to you, before that, how many years of writing a strategy and it would work, even in profit ;)

as a rule, you should not place many pending orders, follow the market orders, if necessary, add a pending order - pending orders become market orders

we use everything - averaging, pyramiding, orders grid and ... and lots... If you do not know, you should read these tricks on traders forums, I haven`t done it for more than a year - I`ve got more thoughts of my own than of others )))

Thanks))))

Martin and averaging is self-deception and prohibitive (because you can neither calculate nor predict the risk by the definition of BP properties))))) risk, which sometimes, but only sometimes, is justified))))

If the strategy is right, one order is enough))))

 
Valeriy Yastremskiy:

If the strategy is correct, one order is enough))))

If in your TS the number of orders is strictly set, then you should not have problems with determining what has happened to the pending orders on the current tick

Knowing the exact time will not give you anything - all information is received upon tick arrival - no tick, no information

 

Hello, I am facing a problem, how to change the parameters of a custom indicator in the EA. The problem is that when I change any parameter in the list of indicators, a new copy is created. When I go to the properties of these copies, each copy has its own parameter. The more I change the parameter, the more copies are created. I use it via iCustom.

For example:

#resource "\\Indicators\\\inicator.ex4"

extern Var1=1;

//------------------------------------------

void OnTick()

{

int A;

Var1++;

A=iCustom(Symbol(),PERIOD_CURRENT,"::Indicators\\\indicator",Var1,0,0);

As a result, we see in the list of indicators:

Indicator (with parameter Var1=2)

Indicator (with parameter Var1=3)

Indicator (with parameter Var1=4)

.... etc.