Download MetaTrader 5

Need help with lowest point !!

To add comments, please log in or register
No time to learn MQL5? The source code library is at your service!
harm
10
harm 2015.03.24 17:18 

 Hey guys,

 

I am new to this forum and i really hope you can help me out.

The problem is that i want to take profit at the lowest point from 30 bars back

and i want my stop loss at OPEN[0]  - LOWEST POINT + OPEN[0] but i doesnt work the way i did it :p

 

Look below and i really hope you can help me  

 

 

double Var1 = Open[0];


double Sell1_1 =  Var1  - Low[iLowest(NULL,0,MODE_OPEN,40,0)]  +  Var1 ;
double Sell1_2 = Open[0];

   

  
   //--  Close Short Conditions
   TrueCloseShort = Low[iLowest(NULL,0,MODE_OPEN,40,0)] > Open[0] || Sell1_1 < Sell1_2 ; 
  
Keith Watford
Moderator
9626
Keith Watford 2015.03.24 22:34  
double Var1 = Open[0];


double Sell1_1 =  Var1  - Low[iLowest(NULL,0,MODE_OPEN,40,0)]  +  Var1 ;
double Sell1_2 = Open[0];

   

  
   //--  Close Short Conditions
   TrueCloseShort = Low[iLowest(NULL,0,MODE_OPEN,40,0)] > Open[0] || Sell1_1 < Sell1_2 ; 

A simple Print of Sell1 will tell you if you are not getting what you expect

Low[iLowest(NULL,0,MODE_OPEN,40,0)] > Open[0]

It is impossible for the lowest open price to be > the current bar's  open price

Sell1_1 < Sell1_2 

 Again, impossible

whroeder1
14504
whroeder1 2015.03.25 00:59  
GumRai: It is impossible for the lowest open price to be > the current bar's  open price
Low[iLowest(NULL,0,MODE_OPEN,40,0)] > Open[0]
If the lowest open price can't be > Open[0] then the Low of that bar also can't be.
harm
10
harm 2015.03.25 11:38  
Oke i understand what i did is impossible but i want to make that if the current price is lower then the lowest price 30 bar ago he takes profit
harm
10
harm 2015.03.25 11:52  
So i did this and the take profit now works.

 

double val=Low[iLowest(NULL,0,MODE_OPEN,40,10)];
double val2=Bid - val + Bid;
   //--  Long Conditions
   
   
   //--  Close Short Conditions

   TrueCloseShort = val > Bid || val2 < Bid; 

 

But i need the stoploss set at the distance between actual price - lowest point + actual price 

To add comments, please log in or register