Forex



Go Back   Forex Trading > Discussion Areas > Setup Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 04-23-2007, 02:23 AM
jimven's Avatar
Senior Member
 
Join Date: Mar 2007
Location: Upstate New York
Posts: 140
jimven is on a distinguished road
Thumbs down Using Custom Indicator in EA (MT4)

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 04-23-2007, 07:22 PM
iscuba11's Avatar
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 398
iscuba11 is on a distinguished road
Smile

PHP Code:
buy_cur=iCustom(NULL,60,"Forex-Grail Trade Indicator [4]",period,0,0);//Buffer 0, Current Bar
    
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 1Current Bar-1 Bar in Past 
1) 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
<><<<<

Last edited by iscuba11; 04-23-2007 at 07:27 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 04-23-2007, 09:35 PM
european's Avatar
Senior Member
 
Join Date: Apr 2006
Posts: 282
european is on a distinguished road
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);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 04-23-2007, 11:57 PM
jimven's Avatar
Senior Member
 
Join Date: Mar 2007
Location: Upstate New York
Posts: 140
jimven is on a distinguished road
Red face

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.
Attached Images
File Type: jpg EA Results.jpg (133.0 KB, 543 views)
Attached Files
File Type: mq4 Test 5 Minute.mq4 (3.4 KB, 74 views)

Last edited by jimven; 04-24-2007 at 09:20 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 05-25-2007, 07:09 PM
nittany1's Avatar
Senior Member
 
Join Date: Dec 2006
Location: Sarasota, FL
Posts: 207
nittany1 is on a distinguished road
pull correct numbers from this SMI, don't know what statement to use

Quote:
Originally Posted by european
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.
Attached Files
File Type: mq4 SMI.mq4 (3.9 KB, 81 views)
__________________
The best things in life come from open source development.
Myspace Facebook My Indicators: Trade Assistant Trend Friend ToR CCI Helper
Holder of US Patent 6,774,788
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 05-28-2007, 12:35 PM
nittany1's Avatar
Senior Member
 
Join Date: Dec 2006
Location: Sarasota, FL
Posts: 207
nittany1 is on a distinguished road
Quote:
Originally Posted by nittany1
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!
Attached Images
File Type: gif screen-eurjpy-h4.gif (16.1 KB, 589 views)
__________________
The best things in life come from open source development.
Myspace Facebook My Indicators: Trade Assistant Trend Friend ToR CCI Helper
Holder of US Patent 6,774,788
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 06-04-2009, 02:15 PM
Junior Member
 
Join Date: May 2009
Posts: 2
wapzzoo is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 06-05-2009, 09:19 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Quote:
Originally Posted by wapzzoo View Post
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
You just bumped a thread from two years ago!

Welcome to the forum.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 06-06-2009, 03:45 PM
Junior Member
 
Join Date: May 2009
Posts: 2
wapzzoo is on a distinguished road
Thank you for receive me

Thank you for receive me in this forum.
wap
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
icustom mt4


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need an MT4 custom indicator wadeboxjr Metatrader 4 1 08-22-2006 09:50 PM
Custom Indicator Help FX-Hedger Indicators - Metatrader 4 4 03-05-2006 02:26 PM
Custom Indicator Roets Setup Questions 1 01-03-2006 08:54 AM
using a custom indicator forextrend Metatrader 4 2 12-02-2005 02:36 AM


All times are GMT. The time now is 03:05 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.