MACD HELP
Will any1 be able to help me code the signal line as soon as it crosses over the MACD under the 0 line, trigger buy order.
I know it sounds simple but really struggling with this for a few days now. Would appreciate any help!
Hello,
well I would like to, but what are these parameters, you pass the iMACD() ??
According to the doc, I can only find 6 parameters being taken by the function.
You need to use the CopyBuffer() function to get access to the values of the indicator.
double main[]; double signal[]; const int macd = iMACD(NULL,0,12,26,9,PRICE_CLOSE); int error_code = ERR_SUCCESS; if(CopyBuffer(macd, MAIN_LINE, 0, 1, main) == -1) { error_code = GetLastError(); } if(CopyBuffer(macd, SIGNAL_LINE, 0, 1, signal) == -1) { error_code = GetLastError(); } // Now you can compare values if(main[0] < signal[0]) { /* some action */ }
https://www.mql5.com/en/docs/indicators/imacd
https://www.mql5.com/en/docs/series/copybuffer
- www.mql5.com
OrderSend (_Symbol,OP_BUY,0.10,Ask,3,0,Ask+350*_Point,NULL,0,0,Green);
-
Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. -
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using 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 close to 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 spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
Hello,
well I would like to, but what are these parameters, you pass the iMACD() ??
According to the doc, I can only find 6 parameters being taken by the function.
You need to use the CopyBuffer() function to get access to the values of the indicator.
https://www.mql5.com/en/docs/indicators/imacd
https://www.mql5.com/en/docs/series/copybuffer
I would like to buy when the macd main line crosses over the signal line, Under the 0 line of the indicator. That is all, just trying to keep it as simple as possible!
Thank you!
Hello,
well I would like to, but what are these parameters, you pass the iMACD() ??
The code is MQL4 not 5.
The OP posted in the wrong section and I have since moved the topic.
Will any1 be able to help me code the signal line as soon as it crosses over the MACD under the 0 line, trigger buy order.
I know it sounds simple but really struggling with this for a few days now. Would appreciate any help!
if (macd<signalLine) { signal="sell"; } if (macd<signalLine) { signal="buy" ;}
You don't check for a cross and you don't check if it is below the 0 level.
Your condition for a buy signal is the same as for a sell signal.
Will any1 be able to help me code the signal line as soon as it crosses over the MACD under the 0 line, trigger buy order.
I know it sounds simple but really struggling with this for a few days now. Would appreciate any help!