i'd like to make my EA to close a position if any of these conditions were met :
-profit on the position is 100 points
-price hit RSI 30 OR 70 depending if it's a Sell or buy
Here's my code but for some reason it doesn't work !!
Also i'm not quite sure whether "PositionGetDouble " return profit value in points or dollar value ?!
double tp = PositionGetDouble (POSITION_PROFIT);
// rsi_0 is the RSI value for the current candle
if ( (trade.RequestType() == ORDER_TYPE_BUY) && ((rsi_0 >70 ) || (tp > 100) ) )
if ( (trade.RequestType() == ORDER_TYPE_SELL) && (( rsi_0 < 30) || (tp > 100) ) )
Thanks for your comment , and sorry the attached code was misleading , i have updated it
the problem is that code isn't doing what it supposes to do
i don't want to just close order once hit 100 points , it should look if EITHER of conditions were met , whichever happens first , then close it .
Perhaps you should read the manual. How To Ask Questions The Smart Way. 2004 How To Interpret Answers. RTFM and STFW: How To Tell You've Seriously Screwed Up.
You keep saying 100 points. That is not what POSITION_PROFIT returns.
You keep using rsi_0 but never show the definition and the update. There are no mind readers here.
You use PositionGetDouble but never show where you select a position. There are no mind readers here. Post all relevant code.
i don't know if POSITION_PROFIT return profit in points or dollar value !! that's why i asked that above . it's not clear in the documentation
i have commented in code above also that rsi_0 is the RSI value of the current candle (candle 0 ) !!
maybe i'm using the function the wrong way but code complies fine , so please correct me the function or the way i should use it .