Your code if(iHigh(_Symbol, PERIOD_CURRENT,1)>iHigh(_Symbol, PERIOD_CURRENT,1)
Equivalent.
When will that ever be true?double h=iHigh(_Symbol, PERIOD_CURRENT,1); if(h>h
- Ahmed Abd El Aziz: But it dose not making what i want!
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)
Your code Equivalent.
When will that ever be true?-
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)
1- It is not important for me, but thanks anyway.
2- I guess you didn't understand me. If i get the last error or last price ..ETC, it will not help me in this case.
For example:
I want to tell the expert to:
- open 1 buy position if the close price > moving average 100
&& open another buy position if the close price > moving average 200
if(Close[i+1]>MA100[i+1]) { result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"Test",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; if ( ! OrderSelect(result, SELECT_BY_TICKET)){return(0);} if ( ! OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green)){return(0);} } return(0); } if(Close[i+1]>MA200[i+1]) { result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"Test",MagicNumber,0,Blue); if(result>0) { TheStopLoss=0; TheTakeProfit=0; if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint; if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint; if ( ! OrderSelect(result, SELECT_BY_TICKET)){return(0);} if ( ! OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green)){return(0);} } return(0); }
In this case, the expert will open unlimited buy positions if one or more conditions are achieved!
The question is how to make the expert to open 1 position for each condition.
Now i think that i can do this by get ticket number but it is also inaccurate.
1- It is not important for me, but thanks anyway.
2- I guess you didn't understand me. If i get the last error or last price ..ETC, it will not help me in this case.
For example:
I want to tell the expert to:
- open 1 buy position if the close price > moving average 100
&& open another buy position if the close price > moving average 200
In this case, the expert will open unlimited buy positions if one or more conditions are achieved!
The question is how to make the expert to open 1 position for each condition.
Now i think that i can do this by get ticket number but it is also inaccurate.
if ( iHigh ( _Symbol , PERIOD_CURRENT , 0 )> iHigh ( _Symbol , PERIOD_CURRENT , 1 )
I guess you didn't notice the logic error in the code you asked the question! Maybe your code could be like above. The solution to your problem may be to use two different magic numbers for two different transaction conditions and to impose a single transaction constraint for each magic no.
It is important. It is extremely important. Pay attention please and read it again.
This is intentional that H>H to avoid this condition or maybe change it later.
I guess you didn't notice the logic error in the code you asked the question! Maybe your code could be like above.
The solution to your problem may be to use two different magic numbers for two different transaction conditions and to impose a single transaction constraint for each magic no.
Thanks i will try to use the magic number in this case.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
to be the total deals are unlimited, but every buy condition is equal to just 1 deal
I tried to use this code:
But it dose not making what i want!
Any help!