sell_cur=iCustom(NULL,60,"Forex-Grail Trade Indicator [4]",period,1,0);//Buffer 1, Current Bar
buy_cur1=iCustom(NULL,60,"Forex-Grail Trade Indicator [4]",period,0,1);//Buffer 0, Current Bar-1 in Past
sell_cur1=iCustom(NULL,60,"Forex-Grail Trade Indicator [4]",period,1,1);Buffer 1, Current Bar-1 Bar in Past1) Make sure you are setup with the right buffer for the right information desired. Many indicators start with buffer 0 (The actual first buffer) and may end up with 3 for a total of 4 actual buffers. If buffer 0, or 1, or 2, or 3 is the buffer in the indicator that has the data you are wanting imported into your EA, then your EA custom indicator buffer must match the same buffer number that is being used by your indicator. Apples to Apples when it comes to buffer numbers. It may be that the information you seek for your EA may be created in buffer 2 versus buffer 0 in your indicator.
In my example using my Forex-Grail Trade Indicator [4] you can create a print statement below your custom indicator statements to see what the EA Buffer 0, and Buffer 1 (Example Below): P.S. The values will show up in your Experts Tab below your graphs! If the values equal those showing up on your indicator window, then you have the right buffer number.
Print(" ",TradeLast," buy_cur= ",buy_cur,"|", "buy_cur1= ",buy_cur1);
This will print out the values for buffer 0 for the current (buy_cur) and the value for buffer 1 for the current -1 bar in past (buy_cur1).
2) Make sure the Indicator File name (Such as Forex-Grail Trade Indicator [4]) is the actual same name as the indicator file name, otherwise weird data can be acquired by the EA in each buffer input.
I hope this will help some??
Peace and Love, in Jesus Name!
Dave
<<<<
testing buffers
or you can use a script and check what each buffer returns, place text label called say 'lx' on your chart, compile your code and d.click on the script - results will be shown in your label
ex:
double vFMACD=iCustom("GBPUSD",5,"FlatTrend w MACD",5,5,6,25,2,0);
string text = vFMACD;
ObjectSetText("lx", text, 10, "Arial", White);
I greatly appreciate replies from both of you, however I would like to add the following.
I have inserted print statements in my test EA to see what the indicator is returning and have found that these values are correct for the EA. That is, they make sense in terms of the range and values. Also, I have verified that I am using the correct indicator name and buffer number.
But here's what I think might be happening:
When the indicator displays on the screen, it uses historical data, which consists only of OHLC values and time. When I perform a backtest (and this is where the problem occurs), the MT4 simulator injects fractal price values and/or lower timeframe values so that for a specific period, the indicator now reports to the EA a different value than it did when it was just displaying and using just the OHLC values.
Therefore, what looked like a good strategy on the screen does not work out in practice because the indicator results are different. I believe that if I could get the indicator to report exactly as it did on historical data, it would again become useful because it would do what it does on the screen.
I have attached a test EA and a picture of some of the results. Clearly, the test EA is not doing what is intended or expected, based on the indicator. It should never close a "BUY" trade unless the indicator bar is RED, which is buffer 3, and has a value of -4. In the jpg attached, this doesn't happen except on the far right. So how do I get the indicator value shown on the screen to be reported to the EA? What I expected was that a "Buy" trade would open if there are any light green or dark green bars showing and would close only when the Red bar appeared.
pull correct numbers from this SMI, don't know what statement to use
or you can use a script and check what each buffer returns, place text label called say 'lx' on your chart, compile your code and d.click on the script - results will be shown in your label
ex:
double vFMACD=iCustom("GBPUSD",5,"FlatTrend w MACD",5,5,6,25,2,0);
string text = vFMACD;
ObjectSetText("lx", text, 10, "Arial", White);Does anyone know how to pull the numbers from this SMI indicator? I'm writing an EA for it, actually it's written already and I'm using stochastic crosses but I want to try this indicator too.
Does anyone know how to pull the numbers from this SMI indicator? I'm writing an EA for it, actually it's written already and I'm using stochastic crosses but I want to try this indicator too.
Nevermind, I figured it out!
Hello Jimven,
Did you found an answer to your problem ?
I have the same problem, data indicator in EA are different from data indicator on screen.
Regards
Hello Jimven,
Did you found an answer to your problem ?
I have the same problem, data indicator in EA are different from data indicator on screen.
RegardsYou just bumped a thread from two years ago!
Welcome to the forum.
Lux
Thank you for receive me
Thank you for receive me in this forum.
wap
Hello,
I apologize for upping this old thread, but since not public answer have been posted, I would like too, know the solution !
Thanks,
keyrama
Hello,
I apologize for upping this old thread, but since not public answer have been posted, I would like too, know the solution !
Thanks,
keyramaIt would be
double x = iCustom(NULL,0,"SMI",14,10,14,5,0,0);
Comment(x);
-guyver
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've been trying to code an EA in MT4 using custom indicators and I always have the following problem:
When the EA tests the value of the indicator at any shift value (I usually use 0 or 1), it often returns a value quite different for that period than the corresponding indicator value displayed on the screen. This results in opening or closing trades at the wrong time.
Is there any technique to get what the EA sees to agree with what the indicator displays for a specific period?