Download MetaTrader 5

opening conditions

To add comments, please log in or register
Brt88
132
Brt88  
plz help

How to code the lenght of candle shadow as a condition to order opening.
if (x
&& x
&& x
&& 1000*(Close[1]-Low[1]) < 15 ) // max 15 pips of shadow condition - doesnt work - at image there is 40 pips shadow.

{
res=OrderSend(Symbol(),OP_BUY,0.1,A sk,3,SL,TP,"",MAGICMA,0,Blue);

return;

}

Brt88
132
Brt88  
whroeder1
14781
whroeder1  
  1. Print your variables and calculations and find out why.
  2. 1000*(Close[1]-Low[1]) < 15 ) // max 15 pips 
    Don't hard code numbers, that fails on JPY pairs.
    double pips2dbl = Point; if(Digits % 2 == 0) pip2dbl = 10.0 * Point; 
    Close[1]-Low[1] < 15 * pips2dbl) // max 15 pips 

Brt88
132
Brt88  

thank you for remark. currently working only on a EURUSD.

I have change it a little bit. but still there is some bug in variables.

int    res;
     double SL, TP, Sm;
     SL= iLow(NULL,PERIOD_D1,0)-50*Point;
     TP= Close[1]- 2*(SL-Close[1]);

     Sm= Close[1]-iLow(NULL,PERIOD_D1,0)-50*Point;


 Sm*1000 < 25          // 1 of few conditions

{
      res=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP,"",MAGICMA,0,Blue);
      return;
     }

  
  

Fernando Carreiro
2279
Fernando Carreiro  
Brt88:

thank you for remark. currently working only on a EURUSD.

I have change it a little bit. but still there is some bug in variables.

  1. Please EDIT your post and use the "SRC" icon when including sample source code.
  2. Just because you are currently only using EURUSD", that should not serve as an excuse to hard coding numbers. WHRoeder is a very experienced coder and his suggestions should not be dismissed so lightly.
  3. WHRoeder, instructed you to insert "Print()" statements in order to debug and see the results of the various steps, yet you have dismissed that too.
Alain Verleyen
Moderator
31185
Alain Verleyen  
Brt88:


  
  

Should be

 Sm*10000 < 25          // 1 of few conditions
whroeder1
14781
whroeder1  
angevoyageur: Should be
 Sm*10000 < 25          // 1 of few conditions
No it shouldn't That assumes a non-JPY/non-metal pair.
Alain Verleyen
Moderator
31185
Alain Verleyen  
WHRoeder:
No it shouldn't That assumes a non-JPY/non-metal pair.
Yes as he trades EURUSD. Not everyone want lessons on how to become coder, some just need a solution to their issue.
Fernando Carreiro
2279
Fernando Carreiro  
WHRoeder: No it shouldn't That assumes a non-JPY/non-metal pair.
angevoyageur: Yes as he trades EURUSD. Not everyone want lessons on how to become coder, some just need a solution to their issue.

"Give a man a fish and you feed him for a day; teach a man how to fish and you feed him for a lifetime!"

Alain Verleyen
Moderator
31185
Alain Verleyen  
FMIC:

"Give a man a fish and you feed him for a day; teach a man how to fish and you feed him for a lifetime!"

Ok mister professor, but some people are vegetarians or just don't want to fish all their life, ask them before trying to feed them for life.
Fernando Carreiro
2279
Fernando Carreiro  
angevoyageur:
Ok mister professor, but some people are vegetarians or just don't want to fish all their life, ask them before trying to feed them for life.
How did you guess that my nick-name in high-school was "Prof"?
12
To add comments, please log in or register