| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| iConfused with iCustom!!! https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5323 |
Page 1 of 2 |
| Author: | Bruster400 [ Thu Nov 02, 2017 11:27 am ] |
| Post subject: | iConfused with iCustom!!! |
Hi, I've written an indicator that draws breakout boxes and it works fine. I now want to call this indi from an EA using iCustom(). I've made an "EA" version of the indicator for this purpose where I've changed all the inputs that don't affect the result (line styles and colours etc) to internal globals so the indicator now only has three user inputs: I know the buffer that I need to call and I want the signal from the last closed candle so it should be an easy case of using a call such as this: Code: Select all Code: Select all I really don't want to take up people's time unnecessarily so before I get into posting pages and pages of indicator, EA and include code, has anyone else had a similar problem? Can anyone think of the things I could try differently? Thanks Bruster |
|
| Author: | tomele [ Thu Nov 02, 2017 12:50 pm ] |
| Post subject: | iConfused with iCustom!!! |
Hi Bruster. What happens if you define the inputs as "input int" instead of "extern int"? |
|
| Author: | Bruster400 [ Thu Nov 02, 2017 1:01 pm ] |
| Post subject: | iConfused with iCustom!!! |
Hi, Thanks for helping. The same thing happens with both extern and input. I actually had them as input originally - extern was my attempt to check them both. I've also tried changing the names of the variables in the EA vs the Indicator but that hasn't changed anything. It's very strange, I've never had this issue calling iCustom before, just thought maybe someone else had come across it. Thanks again for your help, Bruster. |
|
| Author: | tomele [ Thu Nov 02, 2017 1:21 pm ] |
| Post subject: | iConfused with iCustom!!! |
Very strange. You could try it in a fresh installed environment. As what I know, iCustom sometimes can be problematic. I would always prefer to integrate the indi code directly into the EA or put it into a library. That also makes it faster. Good luck. |
|
| Author: | Bruster400 [ Thu Nov 02, 2017 3:57 pm ] |
| Post subject: | iConfused with iCustom!!! |
I'll try the fresh install. I think you're probably right about the integration but having got it working well as an indicator, the thought of needing to re-write it for EA is painful! Thanks again Bruster |
|
| Author: | tomele [ Thu Nov 02, 2017 5:46 pm ] |
| Post subject: | iConfused with iCustom!!! |
Dont be scared. There is some code in the indi that fills the buffer. Take that code and cast it into a function in the EA. Instead of assigning the value to the buffer, the function simply returns the value. Then you call this function instead of iCustom. No rocket science at all. If you run into problems, just ask. There will be people in this brilliant forum to help you. Me included. Good luck. |
|
| Author: | SteveHopwood [ Thu Nov 02, 2017 10:38 pm ] |
| Post subject: | iConfused with iCustom!!! |
Bruster, just to back up what Thomas has written here: incorporate an indi code into your EA whenever you possibly can. The saving on cpu resources is huge. Here is what I write to EA commissioners whinging to me that the EA I wrote for them calling 5 Crap Custom Abortions has slowed their machine to a crawl. Back in the days when I was daft enough to accept such commissions, I saved it in a doc so I could merely copy/paste it to them:
|
|
| Author: | simplex [ Fri Nov 03, 2017 10:26 am ] |
| Post subject: | iConfused with iCustom!!! |
To reduce your pain, start with your indicator again: move the main logic that's required in your EA from OnCalculate() into a separate function, which then is called from OnCalculate(). This is not really difficult. Once this is working, try the very same function in your EA. Keep in mind that nor every action your indi might perform like drawing rectangles on a chart or something will make sense in the EA. To sort this out, divide your code into separate functions, if applicable: functions that perform trading related calculations (the analytical layer) and separate functions that display the results on chart (the visual layer). In most cases, the analytical functions should work in indicators and EAs as well. Visualization in EAs as compared to indicators will be quite different. |
|
| Author: | Bruster400 [ Wed Nov 08, 2017 9:22 pm ] |
| Post subject: | iConfused with iCustom!!! |
Steve and Simplex, Thanks guys for the additional help, really appreciate it. I'm working on putting the indicator into my EA directly. I was avoiding it because it uses multiple buffers for the internal calculations and I'm having to recreate these with arrays in the EA which is a pain. On a separate note, I read somewhere that iCustom had been improved in one of the recent build changes and it is now much faster. I can't find the post ( Thanks again, Bruster |
|
| Author: | renexxxx [ Thu Nov 09, 2017 12:24 am ] |
| Post subject: | iConfused with iCustom!!! |
Yes, that is true. An EA will load and cache in memory an instance of the indicator for each unique combination of its input parameters, as specified in the iCustom call. This can be demonstrated by the attached TestEA and TestIndicator: In the OnInit of TestIndicator there is a print statement telling us that it is being initialized. The TestEA loads TestIndicator with three different sets of input parameters: therefore Empty4 loads three different instances of the indicator and keeps them cached in memory -- resulting in only three print statements. |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|