DOW POINTS

 

Below there is a program to draw vertical lines at the second bottom point

which are higher than the previous bottom.

(It is like dow theory .

It will find bottoms and compare themselves and draw verticals to the second bottoms at the uppertrend )

never draws.

where its logic mistake?

 

<SNIP> 

 
pascalboy:

Below there is a program to draw vertical lines at the second bottom point

which are higher than the previous bottom.

(It is like dow theory .

It will find bottoms and compare themselves and draw verticals to the second bottoms at the uppertrend )

never draws.

where its logic mistake?

<SNIP>

You have been politely asked to use the SRC button . . .

https://www.mql5.com/en/forum/142696

https://www.mql5.com/en/forum/142482 

 
https://www.mql5.com/en/forum/141646

 

 Please edit your post . . .  if you want to add your code back in please do so . . .  using the  SRC  button.



Please use this to post code . . . it makes it easier to read.

 
extern int dip1,dip2;
int start()

{


if(Close[0]>Close[1]&&Close[1]<Close[2])
{
while(dip1==100)break;
dip1=100;
datetime zaman1=Time[1];
double nokta1=Close[1];
}

if(Close[0]>Close[1]&&Close[1]<Close[2]&&dip1==100)
{
dip2=100;
datetime zaman2=Time[1];
double nokta2=Close[1];

}


if(dip1==100&&dip2==100 && nokta2>nokta1&&zaman2>zaman1)
{
ObjectCreate("dip"+Time[1],0,0,zaman2,nokta2);

dip1=0;
dip2=0;
}

//if(Close[i]<Close[i+1]&&Close[i+1]>Close[i+2])
//{
//ObjectCreate("ZİRVE2"+Time[i+1],22,0,Time[i+1],Close[i+1]);
//int zirve2=100;
//while(dip2==100||zirve2==100)break;
//}



return;
}
 

i was always using src after copiying the text .

i learned it now.

 
  1. while(dip1==100)break;
    What do you think this line does? N O T H I N G !!
  2. ObjectCreate("dip"+Time[1],0,0,zaman2,nokta2);
  3. Always use defined constants
  4. What are Function return values ? How do I use them ? - MQL4 forum
 
pascalboy:

i was always using src after copiying the text .

i learned it now.


Thank you :-)
 
while(dip1==100)break;

What do you think this line does? N O T H I N G !!

it means , 

if dip1 (first bottom )  takes 100 value ,

exit "for cycle" and go to the next "for  cycle" .

 and after finding second bottom  program would draw a vertical line .

 

  1. ObjectCreate("dip"+Time[1],OBJ_VLINE,0,zaman2,nokta2);
    How many parameters does ObjectCreate take for a VLine?

 

for vline just one parameter .time parameter is useful . 

 
pascalboy:

What do you think this line does? N O T H I N G !!

it means , 

if dip1 (first bottom )  takes 100 value ,

exit "for cycle" and go to the next "for  cycle" .


But it won't . . .  you used a while so all the break does is exit the while,  not the for loop . . . .  you should read up on break  it says,  "A break operator terminates the execution of the nearest nested outward switch, while, or for operator. "

You don't have a for loop in your code  . . . . 

 
int start()


{

for(int i=0;i<=0;i++)
{
double x0=iClose(Symbol(),PERIOD_H1,i+1);
datetime t0=iTime(Symbol(),PERIOD_H1,i+1);
double x1=iClose(Symbol(),PERIOD_H1,i+2);
datetime t1=iTime(Symbol(),PERIOD_H1,i+2);
double x2=iClose(Symbol(),PERIOD_H1,i+3);
datetime t2=iTime(Symbol(),PERIOD_H1,i+3);
}

if(x0>x1 && x1<x2 )
{
int dip=dip+1;
}

if(dip==2)
{
Print("dipppp22222");
ObjectCreate("NULL"+t1,OBJ_VLINE,0,t1,x1);
dip=0;
}

return;
}

hello ,

first of all i will tell you about this program .

i will tell you its logic.

and then ask is it right or wrong.

 

 

1- at for cycle i am assigning values to "x" and "t" values .

2- at "if" conditional operator i am asking ,if provides the condition increase "dip" value  by one.

3- at the second "if" operator "if the dip=2",i say draw a vline at t1 point.

is it right ?

 

"it never draws.

 

But if i change the program like below ,

 it draws the vertical line.

if(dip==1 )
{
Print("dipppp22222");
ObjectCreate("NULL"+t1,OBJ_VLINE,0,t1,x1);
dip=0;
} 

 

why can't "dip " value can't take the value  "2" and the above program doesn't work?

what is wrong with it?

(P.S.i am just triying to draw verticals at second bottoms of the trend but program draws  verticals at every bottom of the trend .).


is src button  ok:)? 

 
pascalboy:

hello ,

first of all i will tell you about this program .

i will tell you its logic.

and then ask is it right or wrong.

1- at for cycle i am assigning values to "x" and "t" values .


Perhaps you could explain what your for loop does ?  start condition,  while condition and increment  . . . 
 
pascalboy:


 1.  "it never draws.

 

2.   why can't "dip " value can't take the value  "2" and the above program doesn't work?

what is wrong with it?

1.  Correct,  it never will . . . .  explain why it should  ?

2.   int dip  declares the variable equal to dip + 1,  for each tick start() is called and dip is declared afresh each time . . .  so each time it can only be dip + 1 = 1 

 

You need to learn what a static variable is and/or what global scope is. 

Reason: