(iSAR(NULL, PERIOD_M15,0.02,0.02,1) > Ask)
Have you tried reversing the logic? Sometimes it helps.
You could try other part also since I think it is just logic problems and nothing much.
What I see is just common logic mistakes.
Iam sitting here for hours and can't find a mistake..
I have attached the SourceCode, so maybe someone can have a look inside and tell me what's wrong with it.
The Function is very easy.
Open a buy position if the SAR Indicator is below the market price and RSI is below 30.
Open a sell position if the SAR Indicator is above the market price and RSI is above 70.
Thank you!
The code is too complicated, symplify it
if( Buy == 0 ) { if ((iRSI(0,15,7,0,1) < 30)&& (iRSI(0,15,7,0,0) < 30) && (iSAR(0,15,0.02,0.02,1) < Ask) && (iSAR(0,15,0.02,0.02,0) < Ask)) { int ticket = -1; if ( ticket == -1) ticket = OrderSend(Symbol(), OP_BUY, BuyLots5, Ask, 4, 0, 0, "My Expert", 1, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BuyLots5, Ask, 4, 0, 0, "My Expert", 1, 0, Blue); } }
Simplification usually will not do any good unless the code is working like it should.
Once it is working, then you can start optimizing the code to make it more efficient. :)
Always happen to me by the way.
I think the EA is working the way it should :
https://charts.mql5.com/4/492/eurusd-m15-fxpro-financial-services.png
It is programmed for 15 Mn indicator, check TF, it should be 15 Mn or below : 5 Mn or 1Mn.
I agree deymacro, but often, one has to symplify the code to find where is the problem, and for us, the reader, it's easier to understand if the code is easy to read, be lazy ... :-)
Make sure that the SAR settings on the chart are the same as in the EA
if ((iSAR(NULL, PERIOD_M15,0.02,0.02,1) < Ask) && (iRSI(NULL, PERIOD_M15,7,PRICE_CLOSE,1) < 30))
I bet the SAR on your chart is 0.02,0.2 .
Iam sitting here for hours and can't find a mistake..
I have attached the SourceCode, so maybe someone can have a look inside and tell me what's wrong with it.
The Function is very easy.
Open a buy position if the SAR Indicator is below the market price and RSI is below 30.
Open a sell position if the SAR Indicator is above the market price and RSI is above 70.
Thank you!
DoJoYou should at least attempt basic debugging before you ask others to do it for you. Use Print().
if ((iSAR(NULL, PERIOD_M15,0.02,0.02,1) < Ask) && (iRSI(NULL, PERIOD_M15,7,PRICE_CLOSE,1) < 30)) { Print("Ask = ",Ask); Print("iSAR = ",iSAR(NULL, PERIOD_M15,0.02,0.02,1)); Print("iRSI = ",iRSI(NULL, PERIOD_M15,7,PRICE_CLOSE,1)); IfOrderDoesNotExist8(); }
Hello,
iam starting to write my first EA. But since the beginning, there's a strange behavior of my EA.
Ok my first problem is, that orders are opened in the air, while there is no trend..
Thank you
Chart is drawn from bid price. Your buy order is open from Ask price. You are running the Strategy Tester with current spread on week end. Which seems to be around 20 pips.
I didn't notice the dates on the chart.
I wish that people would actually make it clear when they are referring to a test and not live charts.
Come on now GumRai they all know you have psychic powers to mind read them, no point pretending ;)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
iam starting to write my first EA. But since the beginning, there's a strange behavior of my EA.
Ok my first problem is, that orders are opened in the air, while there is no trend..
and my second problem is, the order is opened while the conditions are FALSE!!
The value of
is round about 1.377~ and higher than the Ask price.
Hope you can help me!
Thank you