How to express a condition in which an downtrend of 15pips aroused

 

If I try to express a condition in which a downtrend of 15pips aroused ,

is a following code right ?

I think this code will be useful when we try to catch a trend of which a starting price is unspecified

( for example when we begin the trade newly) .

int y;
 
if( 
    Low[0]==Bid &&
    High[y]==Bid+15*Point &&
    iHighest(Symbol(),0,MODE_HIGH,y,0)==y &&
    High[iHighest(Symbol(),0,MODE_HIGH,y-1,0)]<High[y] &&
    iLowest(Symbol(),0,MODE_LOW,y,0)==0 &&
    Low[iLowest(Symbol(),0,MODE_LOW,y,1)]>Low[0] &&
    y>0
    ) 
Please answer if it is effect or not in MQL4's rule .
 
Maybe the test should be relaxed a bit for High[y] condition:
High[y]>=Bid+15*Point && High[y]==Bid+20*Point
And the two conditions seem unnecessary:
High[iHighest(Symbol(),0,MODE_HIGH,y-1,0)]<High[y
and
Low[iLowest(Symbol(),0,MODE_LOW,y,1)]>Low[0]
Because the two have been covered by their corresponding iHighest and iLowest condition.
 
fireflies:
Maybe the test should be relaxed a bit for High[y] condition:
High[y]>=Bid+15*Point && High[y]==Bid+20*Point
And the two conditions seem unnecessary:
High[iHighest(Symbol(),0,MODE_HIGH,y-1,0)]<High[y
and
Low[iLowest(Symbol(),0,MODE_LOW,y,1)]>Low[0]
Because the two have been covered by their corresponding iHighest and iLowest condition.


Thank you fireflies .

But , about the second indication , I think we will have to code like the first post , strictly speaking .

Because Highest price of a bar between Bar y and Bar 0 may be the same as High[y] .

If I try to add a complicated code to this code , Mt4 may aknowledge wrongly .

But anyway, I tested a following code in a practical trade . ( I only wrote the start function like this)

int start()
  {int y;
  if( 
     Low[0]==Bid &&
    High[y]==Bid+5*Point &&
    iHighest(Symbol(),0,MODE_HIGH,y,0)==y &&
    iLowest(Symbol(),0,MODE_LOW,y,0)==0 &&
    y>0
    ) 
    OrderSend(Symbol(),OP_SELL,0.10,Bid,0,0,0,NULL,10,0);
  
//----
//----
   return(0);
  }

But nothing occured when the condition came practically in the trade .

Is anything wrong ?

At least it is right to make the number of Array the valuable , isn't it ?

 
fireflies:
Maybe the test should be relaxed a bit for High[y] condition:
High[y]>=Bid+15*Point && High[y]==Bid+20*Point
Oops. I meant
High[y]>=Bid+15*Point && High[y]<=Bid+20*Point

maymay:


Thank you fireflies .

But , about the second indication , I think we will have to code like the first post , strictly speaking .

Because Highest price of a bar between Bar y and Bar 0 may be the same as High[y] .

In fact , I tested a following code . ( I only wrote start function like this)

int start()
  {int y;
if( 
   Low[0]==Bid &&
    High[y]==Bid+5*Point &&
    iHighest(Symbol(),0,MODE_HIGH,y,0)==y &&
    iLowest(Symbol(),0,MODE_LOW,y,0)==0 &&
    y>0
    ) 
High[y] is not maybe the same as highest price, but it is the highest price because of your next condition (iHighest condition).

The range (>= 15 && <= 20) or whatever range, instead of strict condition (as in == 5 ) may be needed because the price movement may be jumpy skipping exactly the price value you are testing.
 
fireflies:
fireflies:
Maybe the test should be relaxed a bit for High[y] condition:
High[y]>=Bid+15*Point && High[y]==Bid+20*Point
Oops. I meant
High[y]>=Bid+15*Point && High[y]<=Bid+20*Point

maymay:


Thank you fireflies .

But , about the second indication , I think we will have to code like the first post , strictly speaking .

Because Highest price of a bar between Bar y and Bar 0 may be the same as High[y] .

In fact , I tested a following code . ( I only wrote start function like this)

int start()
  {int y;
if( 
   Low[0]==Bid &&
    High[y]==Bid+5*Point &&
    iHighest(Symbol(),0,MODE_HIGH,y,0)==y &&
    iLowest(Symbol(),0,MODE_LOW,y,0)==0 &&
    y>0
    ) 
High[y] is not maybe the same as highest price, but it is the highest price because of your next condition (iHighest condition).

The range (>= 15 && <= 20) or whatever range, instead of strict condition (as in == 5 ) may be needed because the price movement may be jumpy skipping exactly the price value you are testing.

I tried to test a following code , ( I wrote only this code in the script . It was successful in compiling. )

int start()
  {int y;
  if( 
     Low[0]==Bid &&
    High[y]>=Bid+5*Point && High[y]<=Bid+10*Point &&
    iHighest(Symbol(),0,MODE_HIGH,y,0)==y &&
    iLowest(Symbol(),0,MODE_LOW,y,0)==0 &&
    y>0
    ) 
    OrderSend(Symbol(),OP_SELL,0.10,Bid,0,0,0,NULL,10,0);
  
//----
//----
   return(0);
  }
But Nothing occured in spite that the condition came practically in the trade .

What is wrong with it ?

 
If you only put the aforementioned code in your start function, the problem I see is that you declare the variable y and use it afterwards in your conditions without assigning any value to it what results in them not being fulfilled.
 
janklimo:
If you only put the aforementioned code in your start function, the problem I see is that you declare the variable y and use it afterwards in your conditions without assigning any value to it what results in them not being fulfilled.


Thank you for posting janklimo .

But I aknowledge that the valuables in MQL4 may not be neccesally assigned like " int x=1;"

but be only like " int x; ".

How do you rewrite an above cord ?

 
In MQL4 you can define and initialize a variable simultaneusly, like this
int  x = 1;
and I think the logic of comparing the recent price with the high of the previous bar is ok, so your start function will look something like this:
int start()
{
  int y = 1;
  if( 
     Low[0]==Bid &&
     (High[y] >= (Bid+15*Point)) && (High[y] <= (Bid+20*Point))
//    iHighest(Symbol(),0,MODE_HIGH,y,0)==y &&
//    iLowest(Symbol(),0,MODE_LOW,y,0)==0 &&
    ) 
    OrderSend(Symbol(),OP_SELL,0.10,Bid,0,0,0,NULL,10,0);
  
  return(0);
}
I hope this helps.
 
janklimo:
In MQL4 you can define and initialize a variable simultaneusly, like this
int  x = 1;
and I think the logic of comparing the recent price with the high of the previous bar is ok, so your start function will look something like this:
int start()
{
  int y = 1;
  if( 
     Low[0]==Bid &&
     (High[y] >= (Bid+15*Point)) && (High[y] <= (Bid+20*Point))
//    iHighest(Symbol(),0,MODE_HIGH,y,0)==y &&
//    iLowest(Symbol(),0,MODE_LOW,y,0)==0 &&
    ) 
    OrderSend(Symbol(),OP_SELL,0.10,Bid,0,0,0,NULL,10,0);
  
  return(0);
}
I hope this helps.


This code specifies a value of y as 1 .

In my condition , a value of y can be various .

It is unspecified .

 
Okay, this is more precise. This code calculates the ticks and each time a higher tick than the previous maximum occurs, it sets the new maximum. The down move is then calculated as the difference between the bid and the current maximum. Similarly for an up trend.

double Min = 0;
double Max = 0;
 
int start()
{
  if (Min == 0) Min = Bid;
  if (Max == 0) Max = Bid;
 
  if (Bid > Max) Max = Bid;
  if (Bid < Min) Min = Bid;
  
  Comment("Current up move : ", (Bid - Min)/Point, "\nCurrent down move : ", (Max - Bid)/Point);  
 
  
  return(0);
}
 
janklimo:
Okay, this is more precise. This code calculates the ticks and each time a higher tick than the previous maximum occurs, it sets the new maximum. The down move is then calculated as the difference between the bid and the current maximum. Similarly for an up trend.

double Min = 0;
double Max = 0;
 
int start()
{
  if (Min == 0) Min = Bid;
  if (Max == 0) Max = Bid;
 
  if (Bid > Max) Max = Bid;
  if (Bid < Min) Min = Bid;
  
  Comment("Current up move : ", (Bid - Min)/Point, "\nCurrent down move : ", (Max - Bid)/Point);  
 
  
  return(0);
}

In this code Min and Max have been assined as 0 at first .

Min and Max will be regarded as 0 whatever the condition is .

That is , it doesn't make a sence ?

Reason: