Useful features from KimIV - page 99

 
TarasBY писал(а) >>
I have noticed a bug in the TypeNearPos function when the condition is met:
Market price = open order price, then this order is not taken into account by this function.
I had to add this simple condition to the code.
This condition will also be useful in functions like TypeNearPos() and PriceOpenNearPos().


It makes more sense to compare ti with zero in the condition instead of pp

if (ti==0 || pp>MathAbs(OrderOpenPrice()-mi)/p)
{
   pp=MathAbs(OrderOpenPrice()-mi)/p;
   ti=OrderTicket();
}
But if we leave the condition as it is, we'd better exit the loop by break instead of return.
if (pp==0 || pp>MathAbs(OrderOpenPrice()-mi)/p)
{
   pp=MathAbs(OrderOpenPrice()-mi)/p;
   ti=OrderTicket();
   if (pp==0)
      break;
}
 
Hello, Igor. Hello, everyone.
Igor, I am speaking to you as an excellent specialist and expert in your field.
The essence of my problem is as follows:
I use five indicators in my TS, one of them is TRAP. It removes all unnecessary "noises" very well, but it is just as "good". It has three drawing buffers: 0 for the signal line, 1 and 2 for the two-colour chart. When the TRAP signal line is down and has a red chart underneath it - Sell. When the signal line rises and the chart is blue - Buy.
Manually, everything is fine, but when I try to get its data from the Expert Advisor, torture begins, which continues to this day.
The design...
   TRAPsig0=iCustom(NULL,0,"TRAP",12,5,0,4,0.5,0,0);  // Сигнальная линия,       0 бар
   TRAPsig1=iCustom(NULL,0,"TRAP",12,5,0,4,0.5,0,1);  // Сигнальная линия,       1 бар
   TRAPmnR0=iCustom(NULL,0,"TRAP",12,5,0,4,0.5,1,0);  // Буфер цвета 1 (красн.), 0 бар
   TRAPmnR1=iCustom(NULL,0,"TRAP",12,5,0,4,0.5,1,1);  // Буфер цвета 1 (красн.), 1 бар
   TRAPmnB0=iCustom(NULL,0,"TRAP",12,5,0,4,0.5,2,0);  // Буфер цвета 2 (син.),   0 бар
   TRAPmnB1=iCustom(NULL,0,"TRAP",12,5,0,4,0.5,2,1);  // Буфер цвета 2 (син.),   1 бар
...reads the data, but the data is not at all what I expected. Tried to read data from all three buffers for bars 0 - 7 and display them on the screen. Zero bar contains 2147483647, first bar the price, second bar the price, third bar the price, fourth bar again 2147483647 etc. At the same time, all the data does not change on a tick-by-tick basis, but when it does. Sometimes after a rather long period of time, sometimes quickly, and they change their content according to a strange system that I have not yet understood. If first there is a price there, then it may be this mysterious number, or it may be a different price or the same (although the line goes up and the price should go up), etc. ...
In short, all my attempts to systematise these readings have led to the fact that my brains should already be given to the systematisation of the sanitarians.... :)
I'm crying out for help... Igor, maybe you can advise me on how to beat this indicator?
Or any of the gurus already dealing with this problem.
Help please, all the work costs...
Thanks in advance!
The indicator itself is in the trailer:
Files:
trap.ex4  4 kb
 
do not use zero bar.... It is just forming, which means the indicator value changes with every tick....
 

By the way - where is Igor himself? He hasn't been seen for four or five months!

 
kharko >>:
не используйте нулевой бар.... Он только формируется, а значит, значение индикатора меняется с каждым тиком....

The thing is, I've tried first and second and third and... tried every bar up to seven on every buffer. The signals are wrong. The signal that displays the price, say, 1.3478 may be held up to the next rise of the price to the level of 1.3478, and then sharply become 1.3486 or the price disappears and an unknown value of 2147483647 appears, it may wander from one bar to another in the readings of all three buffers... God willing... It may be present in the readings of three buffers in different bars, and when you change the price of one bar, this reading will move to another bar or buffer... I couldn't beat his logic...

 
artmedia70 >>:

вообще цена пропадает и появляется непонятное значение 2147483647...

2147483647 is 0x7FFFFFFFF.

Special constants used to indicate the state of parameters and variables. Can be the following values:

EMPTY_VALUE 0x7FFFFFFFF Default value, pointer to an empty value. Used in custom indicators
 
artmedia70 писал(а) >>

The thing is, I've tried first and second and third and... tried every bar up to seven on every buffer. The signals are wrong. The signal that displays the price, say, 1.3478 may be held up to the next rise of the price to the level of 1.3478, and then sharply become 1.3486 or the price disappears and an unknown value 2147483647 appears, it may wander from one bar to another in the readings of all three buffers... God willing... It may be present in the readings of three buffers in different bars, and when you change the price of one bar, this reading will move to another bar or buffer... I couldn't beat his logic...


open data window (Ctrl+D), move mouse over your indicator and see what it has in bars. It's not calculated on zero bars, and about EMPTY_VALUE you've already been written.

 
PapaYozh >>:


откройте окно данных (Ctrl+D), поводите мышью по своему индикатору и посмотрите что он имеет в барах. На нулевом баре он не рассчитан, а про EMPTY_VALUE Вам уже написали.

Oh, shit! You live and learn! And I used to make a non-trading Expert Advisor, which plotted this data on a chart... :))) A teapot, and it was boiling... :)
It all turned out so easy... Thanks a lot!!!!

 
PapaYozh >>:


Логичнее, в условии сравнивать с нулём не pp, a ti

Если же оставить условие как есть, то из цикла лучше выходить не по return, а по break.

Explain why: "it's better to exit the loop by break instead of return." ???
I exit a function by return, but I only exit a loop by break. What's the trick?

 

Help, please... Already tried everything... I can't....=( I need to find the intersection of the indicators... All the tips I have been given have not helped me...=( maybe you can help...

Files:
lastlast.mq4  13 kb