Questions from Beginners MQL5 MT5 MetaTrader 5 - page 318

 
barabashkakvn:

Here's more:

Must try it out.

Thank you, I need to bookmark it.

So, ready animation turns out (in gif format) in the chart can not be shoved, or progress has gone further and there is a simple solution?

 
pako:

To sound a trade event using MQL5 tools, you can useAlert() andPlaySound()functions. IfAlert() is used, the same sound will always be played and the message window will open.

Interesting idea of voicing events for Expert Advisors!

Would you be able to make this sound for MT4?

I try (in MT4) to sound the following event: "close order by SL or TP".

I cannot do it in a "simple" way.

(Or maybe all initial conditions should be "put" into an array ...?? ... how to do it correctly?)

Maybe someone has dealt with this voicing issue?

 
mobility-energy:

...

Maybe someone has faced this voicing issue?

Take a look at the examples in this article:MQL5 Recipes - Voicing Trade Events in MetaTrader 5

Function SoundNotification().

 

tol64:


Take a look at the examples in this article:MQL5 Recipes - SoundNotification of Trade Events in MetaTrader 5

Function SoundNotification().

Thanks for the comment.

I have (carefully) looked earlier, it is exactly what I need (!!!), but the version for MT5.

Ah, I need the same version (sounds) only for MT4 (Recipe for MT4),

I need a similar version (sounds) only for MT4 (Prescription for MT4).

I still can't correctly figure out how to make a sound in the code for MT4 when closing an order (exactly) by SL (TP).

The general aspects of opening/closing orders (sound) are already solved/developed.

I cannot correctly determine the conditions of SL (TP) and the functions to be executed.

i.e. the order is opened and modified, ok!

if the order is closed due to profit conditions, ok! The order closes and "sounds".

But if you set SL (TP) after the modification of the order, nothing will be "sounded". If SL(TP) was triggered, after the order modification nothing will be "sounded", i.e. the terminal closes the order "silently".

i.e. terminal closes the order "silently". simple indication (like order search and if()) does not help or i indicate it incorrectly.

Perhaps we should "put" all orders into an array and set a condition (array check, selection from an array) ,

and then when this condition is fulfilled SL(TP ) on "sound" ... But, how to correctly describe it in code?

I've tried some "kim's" variants of sounding events ,

When the pending orders trigger and the event is announced (conditions+array) everything works fine,

I've got a good working order, but similar to SL(TP) doesn't work (maybe I'm using something wrong), that's why I'm asking here. Maybe somebody has a solution, that's already proven and working in code?

I would like not to complicate things too much,

I wish it wasn't so complicated, because it's not the main thing in trading, but it needs to be used as an auxiliary indicator (sound accompanying all events).

================================

I found a solution, it worked, thanks to all for the discussion.

issue closed.


================================

 

Dear forum users!

I am trying to sort a one-dimensional array. The array is declared as a static one with the number of elements 150. First I tried ArraySort(). I got an overrun. I wrote a simple sorting by myself (the code below).

I printed out everything I could, including the array item values and indexes. The result is the same. The printout doesn't show any indices outside the array's bounds.

What can it be?

I appreciate it,

e2718

for(i=0;i<n;i++) ag[i]=pow(o[i]*h[i]*l[i]*c[i],0.25); //Создание массива

Print("ag0=",ag[0]," ag1=",ag[1]," ag2=",ag[2]," ag3=",ag[3]," ag4=",ag[4]," ag5=",ag[5]); //Печать значений проходит

for(i=1;i<=n;)//Начало сортировки методом вставки
 {
 Print("i=",i); 
  w=ag[i]; j=i-1;
  Print("j=",j); 
  while((w<ag[j]&&(j>=0)))
   {
    ag[j+1]=ag[j];j=j-1;
   }
  ag[j+1]=w; 
 } 
//if(!ArraySort(ag))return;//Стандартная сортировка

Result in both cases:
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 array out of range in 'EHHT.mq5' (145,14)
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 j=0
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 i=1
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 ag0=1.254399984056122 ag1=1.254224993272838 ag2=1.254049991029702 ag3=1.254024993271765 ag4=1.254 ag5=0.0
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 t5=1970.01.01 00:00:00o1=0.0 h1=0.0 l1=0.0 c1=0.0
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 t4=2014.11.21 00:00:00o1=1.254 h1=1.254 l1=1.254 c1=1.254

Question: What is wrong? Where is the output outside the array?

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Основы языка / Переменные - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
e2718:


The code is best inserted as follows:Insert code correctly in the forum

Which line has the number 145?

And then there's this condition:

for(i=1;i<=n;)//Начало сортировки методом вставки

looks like it should be:

for(i=1;i<n;)//Начало сортировки методом вставки
 

Good afternoon!

Can you please tell me how to evaluate the ACTIVITIES tab of the TERMINALS window (Ctrl + T) of the trading terminal?

Purely visually...

 
e2718:

Dear forum members!

Trying to do sorting on a one-dimensional array...

Don't make up a bicycle. Use the standard library, namely the classes of the CArray group... (CArrayObj, CArrayInt, etc.) The sorting is done as quickly and well as possible there. You can sort in these arrays by any criteria.
 
e2718:

Dear forum users!

I am trying to sort a one-dimensional array. The array is declared as a static one with the number of elements 150. First I tried ArraySort(). I got an overrun. I wrote a simple sorting by myself (the code below).

I printed out everything I could, including the array item values and indexes. The result is the same. The printout doesn't show any indices outside the array's bounds.

What can it be?

I appreciate it,

e2718


Result in both cases:
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 array out of range in 'EHHT.mq5' (145,14)
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 j=0
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 i=1
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 ag0=1.254399984056122 ag1=1.254224993272838 ag2=1.254049991029702 ag3=1.254024993271765 ag4=1.254 ag5=0.0
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 t5=1970.01.01 00:00:00o1=0.0 h1=0.0 l1=0.0 c1=0.0
2014.11.23 20:16:30 Core 1 2014.11.21 00:00:30 t4=2014.11.21 00:00:00o1=1.254 h1=1.254 l1=1.254 c1=1.254

Question: What is wrong? Where is the output outside the array?

Thanks for the code insertion science! I didn't get it myself. Line 145 is a line with the while loop. The first reference to the ag array is made there. The very first call leads to a conflict. The comment about the upper bound of the loop doesn't affect this. Besides, why does calling the standard sorting ArraySort(ag) lead to the same result?


 
e2718:

To understand where the error is, you need not only this piece of code, but also the declaration of variables. We can only guess what you have declared there.

And here is another link:Forum: when you reply, the cursor jumps into the quote