| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Changing indicator value from an EA https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=494 |
Page 1 of 1 |
| Author: | skinner36 [ Thu Apr 19, 2012 7:36 am ] |
| Post subject: | Changing indicator value from an EA |
Hi, I’m a real newbie to this game and this site has been recommended to me as a great learning tool. So after searching the Internet for an answer to this question I thought I would try here. I am a programmer by profession but I have had no experience with Empty4 and EA’s which puts me on a steep learning curve at the moment. My question is: I have created an indicator with two moving averages. A short one of 10 days and a long one of 50 periods. In an EA I have used icustom to read the values of the moving averages for each day testing for a cross. Is it possible to programmatically change the values of the moving averages in the indicator from the EA? Thanks in advance for your help John |
|
| Author: | garyfritz [ Sun Apr 22, 2012 4:01 am ] |
| Post subject: | Re: Changing indicator value from an EA |
You mean e.g. change the lengths of the MAs? You can pass that as inputs to the indicator in the iCustom call. If you mean, can you change the way the indicator calculates its results, then no. You'd have to change the indicator code to do that. I strongly suggest you forget using iCustom for any basic indicator. Empty4 doesn't handle it very efficiently, so you end up loading and unloading the indicator for every call. (Or so I've read.) iCustom is handy if you want to use a black-box indicator you don't understand or don't have the code for. But if you can drop the code in the EA, it should run a lot more efficiently. |
|
| Author: | SteveHopwood [ Sun Apr 22, 2012 9:42 pm ] |
| Post subject: | Re: Changing indicator value from an EA |
Gary is dead right here again - he always is. I have a lot of experience coding ea's that call various indi's. Try to avoid custom calls (iCustom) to indis wherever possible. Here is the advice I offer to punters wanting me to code an ea with calls to umpteen custom indis: "The problem with custom indis is one that lies at the heart of Empty4. When an EA consults an indicator, the platform loads it into memory, then unloads it again once it has responded to the EA call. This takes time. Custom indis typically consist of a number of calls to the regular indicators that ship with Empty4, and manipulate the information thus gleaned according to what the coder requires. An indicator such as AllAverages will make a number of calls to standard indicator at each tick; each indi is loaded, used, then unloaded. This takes a long time. Ridiculous, but that is how it works, and is the reason that indis such as AA and VQ slow your machine. And then, we put the EA on multiple charts................................." You have coded your own indi, so instead of umpteen calls to various base indi's via your own, subsume the code within your EA. Your processor will thank you. As a pro programmer, the biggest source of confusion you will find with mq4 is its simplicity; you will find yourself looking for complications that do not exist. A child could program using this language. |
|
| Author: | garyfritz [ Sun Apr 22, 2012 11:32 pm ] |
| Post subject: | Re: Changing indicator value from an EA |
Oy. That would be a very twisted child. |
|
| Author: | skinner36 [ Tue Apr 24, 2012 10:19 am ] |
| Post subject: | Re: Changing indicator value from an EA |
Does this mean that if I want to write an EA that calculates a buy signal when two moving averages cross along with other price calculations, that I have to duplicate the code. Once in the EA to make the trade and then in the indicator to display it on the screen? Cheers, John |
|
| Author: | garyfritz [ Tue Apr 24, 2012 5:07 pm ] |
| Post subject: | Re: Changing indicator value from an EA |
Not if you call it with iCustom. You just use the indicator's values. You don't need to duplicate the code in your EA. You don' t even have to know how it works. If you incorporate the indicator's code into your EA, you'll use the code logic to make your buy/sell decisions. In that case, that logic is thus in both your EA and your indicator. I'm not sure if you'd also have to run the indicator, or if an EA can do all the indicator display stuff that an indicator can -- e.g. I'm not sure if you can set up display buffers &etc. Somebody who's comfortable with EAs *and* indicators would have to answer that one. (Steve, I think that disqualifies you. |
|
| Author: | autoabacus [ Fri Dec 19, 2014 11:16 pm ] |
| Post subject: | Changing indicator value from an EA |
iCustom performance appears to have improved a lot since the 2012 posts here. I have started writing an EA to attempt to automate HGI and so needed to make iCustom() calls. I was concerned about the efficiency of those calls given what Steve had to say here, so I ran some tests, and am pleased to report that these days Empty4 (Build 752) does a very much better job. I found that if iCustom() call parameters apart from the buffer and shift ones are not changed from one call to the next, as they not when calling HGI thanks to the iCustom input, then: • the indicator is loaded only once, and is NOT unloaded after every call as Steve reported was the case • the indicator's start()/OnCalculate() runs only ONCE for multiple iCustom() calls to obtain different buffer values which is good. So, with current builds of Empty4, making iCustom() calls is relatively efficient compared with how it used to be as advised by Steve. By way of interest, I also tested what happens if iCustom() calls are made to the same indicator with different parameters values. (Not needed for HGI.) That also is much better, and the indicator is loaded just once for each different set of parameter values. Each instance of the indicator runs its start()/Oncalculate() just once, no matter how many iCustom() calls are made to obtain different buffer values. Great! So, this is an area where things have improved, and improved a lot, from how they used to be as described above by Steve. |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|