In the previous article, we walked you through the process of converting a custom indicator into an iCustom function as a necessary first step before it can be deployed in an expert advisor. We defined the 6 different parameters of an iCustom function, paying particular attention to the last three: Indicator Parameters, Mode, and Shift.

If you are not familiar with the 6 parameters of the iCustom function, I suggest you go back and read the the article Preparing a Custom Indicator for Strategy Deployment: Converting it into an iCustom Function. If you have forgotten or have not seen what a NonLagMA custom indicator looks like, here is a screenshot:. Now what you roughly know the four modes of the NonLagMA custom indicator, you can create at least three types of expert advisors based on the different modes:.

I went over the process of discovering the above indicator parameters in the previous article, but I will recap. The easiest way was to copy and paste the extern variables from the indicator source code over to the expert advisor, and then to populate the iCustom function indicator with the above identifiers, letting them fall AFTER the third parameter the indicator name and BEFORE the last two parameters the mode and shift. Note: While this particular indicator has 9 indicator parameters, it should be pointed out that the most important one is the Length.

Just like the moving average, changing the length changes the fundamental structure of the NonLagMA. The other parameters can be left at the default value of 0. There is not much to explain here. The end result will be more or less similar. In indicator calling, notice that mode parameter of my iCustom indicator functions the second from lastis set to 0. As we have seen above, 0 refers to the NonLagMA line itself. Notice that when I represent current close and previous close I use the iClose function.

The iClose function is useful if you wanted to work with the closing price of a different time frame, currency symbol, or shift value. If you worked with Close or Bid, you are referring to only current price of the current symbol. This function sets the drawing line to an empty value.

Empty values are not drawn or shown in the DataWindow. In the case of the NonLagMA, whenever the line is blue, the UP row in the data window shows the indicator data value, and at the same time the Dn row in the data window shows nothing, empty value.

Conversely, whenever the line is red, the Dn row in the data window shows the indicator data value, and at the same time the Up row shows nothing, empty value. The mode is 3, which as we have discovered, refers to the trend signal. The trend signal does not appear in the data window, like the previous modes, but it does appear in the code of the indicator:. The code calculates how the trend is formed. To put the above into an entry condition is very simple.

Skip to content.It was said earlier that according to MQL4 rules trade functions cannot be used in custom indicators, that is why for automated trading Expert Advisors or scripts should be used. However, the resource-saving technology used for calculations in indicators see Creation of Custom Indicators is widely used when creating trading programs.

In most cases in custom indicators one can efficiently calculate values of indicator array elements necessary for the formation of trading criteria and making of trading decisions in Expert Advisors. Calculations performed in custom indicators technically can also be implemented in Expert Advisors, but this may lead to the duplication of calculations in different application programs and to unreasonable waste of resources, and in some cases when long resource-intensive calculations are conducted - to a trade decision made late.

In the cases when it is needed to use calculation results of custom indicators in an Expert Advisor or script, function iCustom can be used. Calculation of the given custom indicator. The custom indicator must be compiled. NULL indicates the current symbol. Passed parameters must correspond with the order of declaring and the type of external variables of a custom indicator. Can be from - to 7 and must correspond to the index used by any of SetIndexBar functions.

The principle of construction of the custom indicator rocseparate.

Chapter 5: Adding a custom indicator to our EA

In point A the orange line crosses the red one from bottom upwards and the place of first intersection is below the level In point B the orange line crosses the red one in the downward direction and the cross point is above the level 0.

The fact of this crossing must be detected in the Expert Advisor and be considered as a signal to buy point A - close Sell and open Buy or to sell point B - close Buy and open Sell. Crossing of custom indicator lines is considered as a trading criterion. When solving such problems a ready Expert Advisor can be used, changing the order of calculation trading criteria in it.

In this case we can take as a basis the Expert Advisor tradingexpert. The EA shared. Let us analyze what amendments were made in the source code tradingexpert. The main part of the Expert Advisor used as basic has not changed. Changes have been made in two blocks - block and block In the block trading criteria are calculated.

In the described EA a trading strategy is based on two trading criteria - criterion to open Buy and criterion to open Sell. The strategy used in the Expert Advisor allows the presence of only one opened market order, pending orders are not allowed.

The strategy also presupposes closing an opposite order when a criterion for opening triggers; for example, if criterion to open a Buy order is relevant, it means that a Sell order must be closed. For using in the EA shared. H,P,B,A - list of adjustable parameters. In this case the custom indicator rocseparate. For a user to be able to set up values of these parameters from the EA, they are specified in the list of passed parameters of the function iCustom.

In the Expert Advisor values of these parameters can differ from those specified in the indicator. In such a case during calculations in the indicator exactly these passed values will be used. These parameters denote the following:. In the custom indicator rocseparate. In this case values of indicator lines on the zero bar are used, that is why index 0 is specified. For a user to be able to change the adjustable indicator parameters in the EA manually, external variables are specified in block 1a-1b of the Expert Advisor.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. A first thing to realise is, that iCustom is not a call to a function, but rather a method, that indirectly "asks" a by-a-filename referred Custom Indicator to retrieve one, specific, value from a "pre-calculated" DataSTORE. While it may sound complicated, it is the very nature of a CPU-efficient calculation factory, that the Custom Indicators were designed for in the early days of MQL4 world.

The iCustom passes the shift value, as a number of bars -- i. This is used for the sake of the EA being fully agnostic of the Custom Indicator internal variable names et al. Nevertheless, the responsibility of the value retrieval is on the Expert Advisor side, as it fills the parameters of the iCustom interface-proxy.

You do account for this in your code, by setting start, but in general for a complicated indicator that often involves referencing more than just the previous bar one needs to be mindful of this difference and never assume that if the indicator looks good on the chart that means it's actually working. It needs to be tested separately with an EA. Learn more. Asked 5 years, 5 months ago.

MQL4 iCustom Example Shift-Mode Signal Counting with Ordering

Active 2 years ago. Viewed 7k times. I wrote a custom indicator Speed. I'm not sure where's the problem. Stanislav Kralin 8, 4 4 gold badges 24 24 silver badges 47 47 bronze badges. Don Giulio Don Giulio 2, 3 3 gold badges 25 25 silver badges 54 54 bronze badges.

Active Oldest Votes. Caller-side interface how to reduce a risk on a weak-integration interface Nevertheless, the responsibility of the value retrieval is on the Expert Advisor side, as it fills the parameters of the iCustom interface-proxy. B Custer B Custer 7 7 bronze badges. Sign up or log in Sign up using Google.Next you should learn how to change the value onCalculate Event. Oncalculate is function to refresh the chart with indicator when the chart receive new price from the server.

In MT4, on receiving new price from the server, it is also called on receiving new tick. Our job onCalculate Event is to add on price on the to the buffer array that we have created Label1Buffer[]. Each of the buffer array is storing the price indicator. Upon filling the price into the buffer array, then we could draw the indicator in the chart.

icustom mql4

With this, you will get the two lines Similar idea, you could design your indicator to feed in different values into the indicator buffer. Example, I'm drawing the value of price with previous bar close price. You could access to the source code here. You could register free and access to the source code above. Example 1: I am using a loop to loop through all the uncounted bar with value with two prices.

Example 2: Similar idea, you could design your indicator to feed in different values into the indicator buffer. Post Views: 5,Wave Entry Alerts - How to get iCustom 18 replies. Need help, I can't get the value of the buffer using Icustom 5 replies. How to read values of indicators in offline Renko chart 8 replies. Problem with output values of indicators - has anybody noticed it? Similar Threads Wave Entry Alerts - How to get iCustom 18 replies Need help, I can't get the value of the buffer using Icustom 5 replies How to read values of indicators in offline Renko chart 8 replies Problem with output values of indicators - has anybody noticed it?

Attachments: How to get iCustom values from indicators. Exit Attachments. How to get iCustom values from indicators. First Post : Oct 3, am Oct 3, am. Joined May Status: Member Posts. I see many people ask this question but how to use iCustom; but so far no clear answers from people about the parameters issue.

The MQL help files are less than useless on the subject.

Subscribe to RSS

HOW do we find out what the parameters are? So what I need iCustom to give me is the Slope Value at the close of each bar. But what about the parameters? And in particular, what about the parameter that has the Slope Value information I want?

How do I list the parameters? They have names or just numbers?

IndicatorBuffers

Where can I find out how many and what descriptions these parameters have? Attached Files. Oct 3, pm Oct 3, pm. The parameters to the indicator go after the 3rd parameter of iCustom. The last 2 parameters to iCustom always go at the end, after the indicator's parameters. You are in a maze of twisty little passages, all alike.Easy iCustom and Alerts — indicator for MetaTrader 4 is a Metatrader 4 MT4 indicator and the essence of the forex indicator is to transform the accumulated history data.

Easy iCustom and Alerts — indicator for MetaTrader 4 provides for an opportunity to detect various peculiarities and patterns in price dynamics which are invisible to the naked eye. Based on this information, traders can assume further price movement and adjust their strategy accordingly. Easy iCustom and Alerts — indicator for MetaTrader 4. Save my name, email, and website in this browser for the next time I comment. Forex MT4 Indicators. Please enter your comment! Please enter your name here.

You have entered an incorrect email address! Top Downloaded MT4 Indicators.

icustom mql4

Infoboard — indicator for MetaTrader 4. Tma Slope MT4 Indicator. B-clock with Spread — indicator for MetaTrader 4. Forex Trading Strategies Explained.

Recommended Top Forex Brokers. Is FXOpen a Safe Is XM a Safe Is NordFX a Safe Is AvaTrade a Safe Is RoboForex a Safe Is FreshForex a Safe Is FBS a Safe Tickmill Broker Review — Must Read! Is Tickmill a Safe Recent Posts. Forex Committees - 0.Simple zigzag Expert Advisor - need help 4 replies.

Need help in coding MA zigzag 7 replies. Need help understanding ZigZag code 1 reply. Help implementing zigzag similarity concept indicator 0 replies. ZigZag indicator help pls 1 reply. Similar Threads Simple zigzag Expert Advisor - need help 4 replies Need help in coding MA zigzag 7 replies Need help understanding ZigZag code 1 reply Help implementing zigzag similarity concept indicator 0 replies ZigZag indicator help pls 1 reply.

Exit Attachments. First Post : Edited at pm Apr 22, pm Edited at pm. Joined Jun Status: forex newbee I hope you all have a great weekend. I have 2 request here regarding a standard ZigZag Metratrader 4 indicator 1. It use the standard ZigZag indicator.

icustom mql4

I manage to remove the error. But when I test using strategy tester, I got this error "SetIndexBuffer function must be called from custom indicator only" Below is the functions line. Inserted Code. Attached Files. Trading is a lifestyle Apr 27, pm Apr 27, pm. I try to adjust the standard indicator and put it the way the ZigZagsEA but still not success.

I'll continue working on it and hopefully can get it right the way I want. I also do some research about the EA. I cannot simply adjust the indicator and convert it into EA. At least this is what I got for now. Still trying. Please share if you guys know how to do it. Thanks in advance Jun 26, am Jun 26, am.

Joined Jan Status: Member 46 Posts. Quoting jamescrag. Jun 27, am Jun 27, am. Attached File. Quoting sangmane. It sounds like what you really want is to make an EA out of a ZigZag indicator. Is that correct? It was a very good thread about the mechanics of trading ZigZag and some useful mods to the original indicator.

You are in a maze of twisty little passages, all alike. Quoting PositivePiP. This is not what I originally wanted, the signal vertical black line keeps floating with the ZigZag, I would like it to stay on its original position where ZigZag line first appeared.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *