| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| How to call an .ex4 file into an EA? https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3413 |
Page 1 of 2 |
| Author: | Arav [ Sun Jan 26, 2014 12:11 pm ] |
| Post subject: | How to call an .ex4 file into an EA? |
:hi: Guys, I have few indicators in .ex4 format. I intended to automate them i.e. when they changes color altogether it will give me an alert. But as they are in .ex4 format so I don't have the source code. But I heard that I can call those indicators in any EA without knowing the source code using buffer and iCustom() function. I have searched online for the process but got example for mq4 files where the source code is known. So I need such process for .ex4 file. If anyone have it then please share. And if don't then please suggest me. I have opened the Data window in the chart using Ctrl+D. There I found three value. Y,G,R. When I move the mouse over different bars, then the value of Y and G changes. R never changes for the indicator I have tested. I observed that when the color of indicator goes from Gray to Blue Y becomes 1to 0 and G becomes 0 to 1 and vice versa for Blue to Gray changing. So I concluded that Y is buffer '0', G is buffer '1' and R is buffer 2. So the iCustom() function lines for each buffer for current bar [i.e. 0 bar] can be like this? Code: Select all Thanks |
|
| Author: | garyfritz [ Sun Jan 26, 2014 6:06 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
You don't need any help -- you've figured it out on your own, well done. MQL can't change the color of an indicator. So color-changing indis like this use multiple indicator lines/bars/whatever with different colors. When the indicator is gray, the Y value goes to 0. Since the indicator is scaled to display the range 0.0-1.0, the 0 value isn't visible. At the same time G goes to 1, and you have a blue bar. You have the right idea with your iCustom() calls. The last param is the bar on which you want the indicator value. Pass it a value of 0 for the current (realtime) indicator value for the bar that is actively being formed, 1 if you want the value on the most recently completed bar, 2 for the bar before that, etc. |
|
| Author: | Arav [ Wed Jan 29, 2014 6:37 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
Hello, Thanks for the reply. I have a question. Now if I want to compare two such color changing indicators and open trades upon their simultaneous change of color, then how can I relate them or compare them? Because like in the attached screenshot, I have used 4 indicators where two of them are having Y,G and R. For Blue to Gray color change, Y of 1st Indicator and Y of 4th indicator both becomes '1.0'. So my condition will be like: Code: Select all As I am unable to modify the Indicators, so I can't assign anything like Y1, Y2. Then how to compare them? Thanks |
|
| Author: | garyfritz [ Wed Jan 29, 2014 7:08 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
You determined Y is buffer 0. So you need to call iCustom for each indicator (I assume you're calling it with different parameters or something?), and save the buffer 0 return value for each one: Code: Select all That also tells you if the current open bar is gray, but NOT if it just TURNED gray. If you want to detect when it just turned from blue to gray, you'll have to look at the same indicators on the previous bar, and see if the Y value changed from 0 to 1. |
|
| Author: | Arav [ Thu Jan 30, 2014 10:35 am ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
Yes, I want the change to grab at every Tick not on every Bar. So whenever the indicators change the color, EA will open order. As you suggested: Code: Select all Then I can compare two indicator's state of color by comparing their 'Returning' value? This is for the first 'Buffer' of each indicator? The function will be like: Code: Select all Thanks |
|
| Author: | SteveHopwood [ Thu Jan 30, 2014 12:08 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
Yes. You need to pass the same number of parameters in the iCustom() call as there are in the indi. You can also have these as extern's in your ea and call iCustom with these values. For example, say your indi has one input: Range = 1; Your ea can have an extern: extern int EaRange - 5; Your iCustom call would be double RangeVal = iCustom(Symbol(), TimeFrame, EaRange, IndiBuffer, shift); IndiBuffer is the buffer you are interrogating. shift is which ever candle you want the value returned for. RangeVal will hold the value of the return from the indi when EaRange = 5. This is how calls to an indi are made completely independent of those on your chart. |
|
| Author: | SteveHopwood [ Thu Jan 30, 2014 12:29 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
To take things a step further, imagine you have an indi that returns the average height of a range of candles. It has just one parameter, NoOfCandles, which is the number of candles to calculate the average. In your EA you would declare your variables. Code: Select all Code: Select all Code: Select all Code: Select all |
|
| Author: | garyfritz [ Thu Jan 30, 2014 6:26 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
Yes to all. The Buffer is indicated by the second-to-last parameter. You won't like that. That will place a Sell order on EVERY TICK that the two indicator Y values are 0. You need to use some method to place the order once, e.g. when Y1/Y2 change from 1 to 0. Gary |
|
| Author: | Arav [ Thu Jan 30, 2014 7:29 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
Ok. I have tried to write a short code for 2 indicators. Please correct me. Characteristic: When 1st Indicator goes from Gray to Blue, it's 'Buffer 1' [Here G] goes 0 to 1. When 2nd indicator goes from Red to Blue, it's 'Buffer 1' [Here G] goes 0 to 1. When 1st Indicator goes from Blue to Gray, it's 'Buffer 0' [Here Y] goes 1 to 0. When 2nd indicator goes from Blue to Red, it's 'Buffer 2' [Here R] goes 1 to 0. What I want: When G(1st) and G(2nd) become 1, EA will open a Buy order. When Y(1st) and R(2nd) become 0, EA will open a Sell order. My code: Code: Select all Thanks for the code. I have used it to express my thought. Yes, I have understood what selecting every Tick will do. I am planning a part of money management for it. Like no trade will be opened unless the current trade got closed or something like that. |
|
| Author: | SteveHopwood [ Thu Jan 30, 2014 10:10 pm ] |
| Post subject: | Re: How to call an .ex4 file into an EA? |
The indi you are calling needs to be inside quotes so: Y1 = iCustom(NULL,0,13 FIM,EarlySignal,M3_Coral_Filter,1,0); needs to be Y1 = iCustom(NULL,0,13 "FIM",EarlySignal,M3_Coral_Filter,1,0); |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|