Introduction
To make use of indicator buffers in your Skilled Advisors or just to learn information from indicator buffers, you’ll want to carry out a number of steps:
1. Defining Enter Parameters
It’s essential decide which enter parameters the indicator has and which of them you wish to modify or use when loading the indicator into your Skilled Advisor. In our case, right here is my checklist of enter parameters that I exploit within the indicator Haven Market Construction Hl Ll Hl Lh.
We see these values within the Inputs window when loading the indicator onto the chart.
enter group "===== Construction Evaluation ====="; enter int SwingPeriod = 2; enter int HistoryBars = 500; enter bool ShowCHoCH = true; enter group "===== BOS Settings ====="; enter bool UseBodyForBreakout = false; enter int LabelSize_Line = 8; enter shade BOSUpColor = clrRoyalBlue; enter shade BOSDownColor = clrRed; enter int BOSLineWidth = 2; enter ENUM_LINE_STYLE bosStyle = STYLE_SOLID; enter group "===== CHoCH Settings ====="; enter shade CHoCHUpColor = clrDodgerBlue; enter shade CHoCHDownColor = clrFireBrick; enter int CHoCHLineWidth = 2; enter ENUM_LINE_STYLE chchStyle = STYLE_DASH; enter group "===== Label Settings ====="; enter int LabelSize = 10; enter shade HHColor = clrGreen; enter shade HLColor = clrBlue; enter shade LHColor = clrOrange; enter shade LLColor = clrRed; enter group "===== Notification Settings ====="; enter bool EnablePushNotifications = false; enter bool EnableAlerts = false;
2. Creating the Indicator Deal with
Subsequent, you’ll want to create an indicator HANDLE and specify the specified indicator parameters for it (that is how we load into our program a model of the indicator with the proper settings), after which we will use it in our code. On this instance, we load all out there parameters by way of ICustom. Nonetheless, you possibly can omit them, and the indicator will load with its default settings outlined in its code. Crucial parameters listed below are “SwingPeriod“, “ShowCHoCH” and “UseBodyForBreakout“; all others solely have an effect on the graphical illustration of the indicator.
Notice that in MQL5 you could go parameters to ICustom precisely as they seem within the indicator code, preserving their order. You can’t specify solely UseBodyForBreakout—ICustom will go our parameter to the primary listed parameter within the indicator code (which, oddly sufficient, is “===== Construction Evaluation =====”, as a result of “enter group” counts as a parameter although it ought to solely separate the inputs).
int marketStructureHandle = iCustom( _Symbol, PERIOD_CURRENT, "IndicatorsMarketHaven Market Construction Hl Ll Hl Lh.ex5", "===== Construction Evaluation =====", SwingPeriod, HistoryBars, ShowCHoCH, "===== BOS Settings =====", UseBodyForBreakout, LabelSize_Line, BOSUpColor, BOSDownColor, BOSLineWidth, bosStyle, "===== CHoCH Settings =====", CHoCHUpColor, CHoCHDownColor, CHoCHLineWidth, chchStyle, "===== Label Settings =====", LabelSize, HHColor, HLColor, LHColor, LLColor, "===== Notification Settings =====", EnablePushNotifications, EnableAlerts);
3. Utilizing the CopyBuffer Perform
Subsequent, we use CopyBuffer to repeat information from the buffers to be used in our program. Instance:
int bars_to_copy = 100; CopyBuffer(marketStructureHandle, 0, 0, bars_to_copy, HH_Buffer); CopyBuffer(marketStructureHandle, 1, 0, bars_to_copy, LL_Buffer); CopyBuffer(marketStructureHandle, 2, 0, bars_to_copy, HL_Buffer); CopyBuffer(marketStructureHandle, 3, 0, bars_to_copy, LH_Buffer); CopyBuffer(marketStructureHandle, 4, 0, bars_to_copy, BOS_UP_Buffer); CopyBuffer(marketStructureHandle, 5, 0, bars_to_copy, BOS_DOWN_Buffer); CopyBuffer(marketStructureHandle, 6, 0, bars_to_copy, CHoCH_UP_Buffer); CopyBuffer(marketStructureHandle, 7, 0, bars_to_copy, CHoCH_DOWN_Buffer);
Now, our arrays (HH_Buffer[], LL_Buffer[], HL_Buffer[], LH_Buffer[], BOS_UP_Buffer[], BOS_DOWN_Buffer[], CHoCH_UP_Buffer[], CHoCH_DOWN_Buffer[]) comprise the indicator buffer values for the final bars_to_copy candles on the chart (together with empty values when no buffer worth exists for a given candle). That is essential to precisely know which candle and when a particular indicator sign occurred.
5. Printing Information or Additional Use in Your Logic
Now, merely print the values of our arrays together with the corresponding date and time.
for (int i = 0; i < bars_to_copy; i++) CHoCH UP = ", DoubleToString(CHoCH_UP_Buffer[i], _Digits)); if (CHoCH_DOWN_Buffer[i] != EMPTY_VALUE) Print(time_str, "
Conclusion
After acquiring the indicator buffer values in your Skilled Advisor, you should use them in your advisor’s buying and selling logic.
For a extra detailed article on find out how to use indicator buffers in your Skilled Advisors: MQL5 for Newbies: Information to Utilizing Technical Indicators in Skilled Advisors
🔵 My different merchandise: https://www.mql5.com/en/customers/maks19900/vendor
🔵Telegram Channel: https://t.me/maks_haven
The script file from the instance: