double MA2 = iMA(_Symbol, _Period, 15, 0, MODE_SMA, PRICE_CLOSE);Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020.03.08)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020.07.05)
How to call indicators in MQL5 - MQL5 Articles (2010)
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020.03.08)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020.07.05)
How to call indicators in MQL5 - MQL5 Articles (2010)
Okay, I think I understand. So I should set it up similarly to the way I have my moving averages?
double MASIGNAL = iMA(_Symbol, _Period, maSignalSmoother, 0, MODE_SMA, PRICE_CLOSE); double MA1 = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); double MA2 = iMA(_Symbol, _Period, 15, 0, MODE_SMA, PRICE_CLOSE); double MA3 = iMA(_Symbol, _Period, 20, 0, MODE_SMA, PRICE_CLOSE); double MA4 = iMA(_Symbol, _Period, 25, 0, MODE_SMA, PRICE_CLOSE); double MA5 = iMA(_Symbol, _Period, 30, 0, MODE_SMA, PRICE_CLOSE); double MA6 = iMA(_Symbol, _Period, 35, 0, MODE_SMA, PRICE_CLOSE); double MA7 = iMA(_Symbol, _Period, 40, 0, MODE_SMA, PRICE_CLOSE); double MA8 = iMA(_Symbol, _Period, 45, 0, MODE_SMA, PRICE_CLOSE); double MA9 = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); double MA10 = iMA(_Symbol, _Period, 55, 0, MODE_SMA, PRICE_CLOSE); double MASIGNALarr[]; double MA1arr[]; double MA2arr[]; double MA3arr[]; double MA4arr[]; double MA5arr[]; double MA6arr[]; double MA7arr[]; double MA8arr[]; double MA9arr[]; double MA10arr[]; CopyBuffer(MASIGNAL, 0, 0, 3, MASIGNALarr); CopyBuffer(MA1, 0, 0, 1, MA1arr); CopyBuffer(MA2, 0, 0, 1, MA2arr); CopyBuffer(MA3, 0, 0, 1, MA3arr); CopyBuffer(MA4, 0, 0, 1, MA4arr); CopyBuffer(MA5, 0, 0, 1, MA5arr); CopyBuffer(MA6, 0, 0, 1, MA6arr); CopyBuffer(MA7, 0, 0, 1, MA7arr); CopyBuffer(MA8, 0, 0, 1, MA8arr); CopyBuffer(MA9, 0, 0, 1, MA9arr); CopyBuffer(MA10, 0, 0, 1, MA10arr);
Would like some help here, I'm unable to get a "posOpen" value (Comment(posOpen)) without an "undeclared identifier" error.
Here is a segment of the code
The obvious thing is that you forgot to select the position before call PositionGet* functions.
for (int i = PositionsTotal()-1; i >= 0; i--) { if(!PositionSelectByTicket(PositionGetTicket(i))) continue; string posSymbol = PositionGetString(POSITION_SYMBOL); double posOpen = PositionGetDouble(POSITION_PRICE_OPEN); double posProfit = PositionGetDouble(POSITION_PROFIT); int posSwap = (int) PositionGetDouble(POSITION_SWAP); double posNetProfit = posProfit + posSwap; }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Would like some help here, I'm unable to get a "posOpen" value (Comment(posOpen)) without an "undeclared identifier" error.
Here is a segment of the code