Could someone please help me ? I just started programming and I have n idea what I'm supposed to do, because the EA won't buy/sell when I putr a condition in. If my condition is "true" it works, but not with another condition, such as for example : MA1_value > MA2-value. Could some one pls help me ? My file is here attached. :)
Files:
EA_ROH.mq5
15 kb
- My EA does buy and sell automatically when I backtest it is there anyone that can help me to solve this issue?
- buy and sell orders Not obeying all my conditions
- MQL4 Learning
-
Please post only in English on this forum. "n", "putr", "pls" are not words.
Please don't write ur - it's "you are" or "your" - MQL4 programming forum 2014.03.04 - You are supposed to fix your broken code.
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?
-
if(MA1_value > MA2_value > MA3_value)
True = non-zero and false = zero so you get:if( 3 < 2 < 1 ) if( false < 1 ) if( 0 < 1 ) if( true )
if( 3 > 2 > 1 ) if( true > 1 ) if( 1 > 1 ) if( false )
-
//SELL if(false)
Your sell condition is always false. -
trade.Sell(Lot_Size,_Symbol,Bid,Bid - STOPLOSS* _Point,Bid + TAKEPROFIT* _Point,NULL); trade.Buy(Lot_Size,_Symbol,Ask,Ask - STOPLOSS* _Point,Ask + TAKEPROFIT* _Point,NULL);
You buy at the Ask and sell at the Bid.- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
Comments that do not relate to this topic, have been moved to "Off Topic Posts".

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