[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 753

 
Morzh09:

Please advise what the catch is:

1) I fill a two-dimensional array with the time of formation of the ZigZag extremum and the extremum value itself.

2) Filling the second array with ones or twos depending on whether the extremum corresponding to a given element is a local maximum or minimum.

3) I output the results through Alert.

but in a place where 1 or 2 should be printed zeros are always printed.

What's the catch?!?

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

//| Custom indicator initialization function |

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


string TimeSave1[100][2], TimeSave2[100][2];

double A[], B[];

double Number_of_extremum[];

extern string Currency = "EURUSD";


+------------------------------------------------------------------+

//| Custom indicator iteration function |

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

int start()

{

int counted_bars=IndicatorCounted();

//----

int k;

k=0;

double date;

int status;

for(int shift = 0; shift <= Bars-1; shift++)

{

date = iCustom(NULL, 0, "ZigZag", 12, 5, 3, 0, shift);

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

if(date > 0)

{

TimeSave1[k][0]=TimeToStr(Time[shift]);

TimeSave1[k][1]=date;

k++;

}

}

//====================================================

for (int u=1;u<=k;u++)

{

if (StrToDouble(TimeSave1[u][1])<=StrToDouble(TimeSave1[u-1][1]))

{

Number_of_extremum[u]=1;// значит под номером u - нашли min

}

else

if (StrToDouble(TimeSave1[u][1])>=StrToDouble(TimeSave1[u-1][1]))

{

Number_of_extremum[u]=2;// значит под номером u - нашли max

}

}

//====================================================

for (int j=1;j<10;j++)

{

Alert("время== ",TimeSave1[j][0], " значение== ", TimeSave1[j][1], " max/min== ", Number_of_extremum[j]);

}

//----

return(0);

}

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

And one more clarification:

how to compare dates and times in mql (for example, I need to determine which vertex of ZZ was formed earlier - for this I need to compare the time of their formation...)

datetime is essentially int, it contains the number of seconds, starting from 1970 and ending with the bar time. I check for more/less - it works...
Didn't look at the rest - just got here...
 

Friends, a question:


Faced this problem:

the indicator outputs some information via Alert.

But, gradually the Alert output field accumulates too much "crap"...

When I will start the indicator again, will it be possible to erase all old records in Alert?


Thanks in advance.

P.S.

Please comment on my post earlier (why null values are displayed instead of 1 and 2)

 

I didn't find it on the forum...

Question - is it possible to change the comment on the order? Well, when OrderSend() operation I put into the comment some value of "OrderNotModify", and doing further actions with this order, for example partial closing, I change OrderComment to "OrderIsModify"... or not?

 
Morzh09:

Can you tell me what the catch is:

Array is filled from 0, but here the 0th index is skipped, and we fill from the 1st, and

for (int u=1;u<=k;u++) // k при старте =0, u <= k не будет, считать счетчику незачем

{

if (StrToDouble(TimeSave1[u][1])<=StrToDouble(TimeSave1[u-1][1])) // выражение при старте всегда [1][1]<=[0][1]

{

Number_of_extremum[u]=1;// значит под номером u - нашли min

}

else

if (StrToDouble(TimeSave1[u][1])>=StrToDouble(TimeSave1[u-1][1])) // значит, всегда срабатывает [1][1]>=[0][1]

{

Number_of_extremum[u]=2;// значит под номером u - нашли max

}

}
 
Abzasc:

The array is filled from 0, but here the 0th index is skipped and filled from the 1st, and

I don't quite understand your comment.

1) k - at start - is not zero! k = the number of ZigZag vertices we have detected at a certain depth of history!

2) "so, it always work [1][1]>=[0][1]" - why does it always work? if previous element of TimeSave1 array > next element, it won't work.

repeat, please, what you meant to say.

 
Morzh09:

didn't quite understand your comment.

1) k - at start - is not equal to zero! k = the number of ZigZag vertices we have detected at a certain depth of history!

2) "so, it always work [1][1]>=[0][1]" - why does it always work? if previous element of TimeSave1 array > next element, it won't work.

Please tell me again what you want to say.

I understand k. This is what I don't understand.

for (int u=1;u<=k;u++) // на первом шаге счетчик присваивает u = 1

{

if (StrToDouble(TimeSave1[u][1])<=StrToDouble(TimeSave1[u-1][1])) // здесь, значит[u=1][1]<=[(u=1)-1][1]
// т. е. 1<=0, вы же от 1 еще 1 отнимаете

{

in the right part

 
Michelangelo:

is it possible to change the order comment?

In OrderModify only ticket price stoploss takeprofit expiration arrow_color

Looks like no.

 

so... it looks like it's the heat... And it's affecting my compiler too :)

see, I need to run through an array that records the date of formation of the max/min of the ZigZ and the value of that max/min.

I need to understand, in fact, which vertex of ZZ is a minimum and which is a maximum.

To do this I compare the next highest point of ZZ to the previous one.

If the consecutive top is larger, then it is a top.

if it is smaller, it is a trough.

Depending on whether it is a vertex or a trough, we add 1 or 2 to an element of another array, respectively.

I am curious about this, WHERE the error could be!!!!

Files:
 
I will go here with bows - I broke my calculator all the same... :)
I want to be able to calculate fiba levels based on two known values:
Fib zero level corresponds to 1.2807, level 23.6 corresponds to 1.2838.

We need to find the other 38.2, 50.0, 61.5, 100.0 levels and what prices they correspond to.

I couldn't even find any connection between 1.2807 and 1.2838 to understand the principles of
of finding all the other values.

Please, tell me, somebody ... :)

 
IgorM:
Has anyone met the indicator to see the time of the bar opening in a low TF, not how much time is interesting, and to draw the marks on the chart where the bar started and where it ended
#property indicator_chart_window
#property link      "IgorM"

extern int num    = 10;
extern color line = White;
int init()
{return(0);
}
  
void clear(){
   for(int i=ObjectsTotal()-1; i>=0;i--) {
      string name = ObjectName(i);
      if (StringFind(name,"timeH1_") !=-1) ObjectDelete(name);
    }
}

int deinit(){
clear();
return(0);
}

int start()
{   
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0)   return(-1);
   clear();
   for (int i=0;i<=num;i++){ 
      string name = "timeH1_"+TimeToStr(Time[i],TIME_DATE|TIME_MINUTES);
      ObjectCreate(name,OBJ_VLINE,0,iTime(NULL,PERIOD_H1,i),0);
      ObjectSet(name,OBJPROP_COLOR,line);
      ObjectSet(name,OBJPROP_STYLE,STYLE_DOT);
    }
return(0);
}

I think so. The code is not optimized, but it does draw what I would like to see.
Reason: