Values which are coming from Print are matching with indicator ones. Interesting, what could be the problem?
Best regards,
Roberts
extern int MaxOpen=1; extern double Lots =1; extern double StopLoss =1000; extern double TakeProfit =1000; extern int TrailingStop =0; extern int Slippage =10; extern int MagicNumber =10001; int EURLongUSD=0; int start() { double x=iCustom(NULL,0,"ADXEURMom",Red,0,0); Print("Indicator: ", x); if(OrdersTotal() < MaxOpen) if ((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,0)>(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,0)))&&(iCustom(NULL,0,"ADXEURMom",Red,0,0)>10)) { OrderSend("EURUSD",OP_BUY,Lots,Ask,Slippage,0,0,0,MagicNumber,0,Blue); EURLongUSD++; } return(0); }
extern int MaxOpen=1; extern double Lots =1; extern double StopLoss =1000; extern double TakeProfit =1000; extern int TrailingStop =0; extern int Slippage =10; extern int MagicNumber =10001; int EURLongUSD=0; int start() { double x=iCustom(NULL,0,"ADXEURMom",Red,0,0); Print("Indicator: ", x); if(OrdersTotal() < MaxOpen) if ((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,0)>(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,0)))&&(x>10)) { OrderSend("EURUSD",OP_BUY,Lots,Ask,Slippage,0,0,0,MagicNumber,0,Blue); EURLongUSD++; } return(0); }
is x > 10 ?
I think it's pretty rare that x will be > than 10
Thats the main problem, the EA is opening position even if x < 10. When I close it, it opens it again :)
Best regards,
Roberts
Found something,
Print shows that indicator values are ok, like 0,8, 0,9, 1,2, 0,7 and then suddenly comes one 7 digit number as x. In indicator window suddenly anly values disapears. Could it be that indicator hangs up?
Best regards,
Roberts
double x=iCustom(NULL,0,"ADXEURMom",28,0,0);
Simple solution,
30>x>10, everything seems to work.
Thanks gjol!
Best regards,
Roberts
- Franko: 30>x>10, everything seems to work.
I hope you didn't write that literally because it isn't what you think. Int and bool are interchangeable (true=1, false=0) so if X==20 you get
30 > x > 10 30 > 20 > 10 true > 10 1 > 10 false
- Franko: When I close it, it opens it again :)You don't have any OrderClose calls in you code. Opening an order in the opposite direction is NOT a close, that is hedging.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
Im writing simple EA code:
The problem is that positions are opened without iCustom value approval ( if x<10)
This is the indicator code:
Maybe you see some simple mistakes. Many thanks.
Best regards,
Roberts