Forex



Go Back   Forex Trading > Programming > MetaTrader
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
  #601 (permalink)  
Old 12-29-2007, 07:01 PM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by ingvar_e View Post
Hi,
I am new to Metatrader but very experienced in programming. I have created some sample Expert Advisors and some slightly complicated Indicators in MT. What is not clear is how to structure a rather complicated EA. I want the EA to call some "signal" functions to check for different setup condition.
How should I code these functions?
1. As "inline" functions in the EA
2. As "separate" Indicators that return a value instead of write on the screen?
3. some other "separate" function to call like calling iMA

If I choose alternative 1 can the inline function in the EA run thru the last 200 bars using Close[i] and call iMA?

Is alternative 2 OK?. When coding an indicator all bars "available" are processed which of course is not needed for the EA.

Alternative 3 to me seems like the logical choice but I am not sure how to structure it so it will work in backtesting and what I need to pass to it and what the function has access to by default, like for instance Close[i]

As an example of what I need to establish in the "signal" function is what is the current trend and when did it start. I have coded it in an indicator so I know how to do the actual code.

Grateful for any advice.

Ingvar
You probably already know how to do this, so sorry if you do.

Moving average of current bar:
iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,0);

Moving average of 200 bars ago.
iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,200);

You can call the moving average from whatever bar you want form current to any bar in the past.
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
  #602 (permalink)  
Old 12-29-2007, 08:19 PM
Member
 
Join Date: Dec 2007
Location: Outside Stockholm
Posts: 45
ingvar_e is on a distinguished road
Thanks Wolfe,

Yes I have seen that this is possible. That is not really my problem. One way to illustrate the problem is to try to use a library function as that is in manner that I am used to program. But in a library routine I dont seem to have access to things like Close[i]. Does that mean that I have to pass arrays for open, high, low and close fro the number of bars I need to the library routine? Seems a bit awkward since "everything" is available in a Indicator type of routine. So should I write 5 different indicator routines and call them from the EA routine? In that case can I just skip the screen writing in the Indicator routine and just return a value to the EA routine instead. Or do i have to return an array of values that match all the bars?

Struggling along
Ingvar
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
  #603 (permalink)  
Old 12-30-2007, 03:22 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 818
wolfe is on a distinguished road
Quote:
Originally Posted by ingvar_e View Post
Thanks Wolfe,

Yes I have seen that this is possible. That is not really my problem. One way to illustrate the problem is to try to use a library function as that is in manner that I am used to program. But in a library routine I dont seem to have access to things like Close[i]. Does that mean that I have to pass arrays for open, high, low and close fro the number of bars I need to the library routine? Seems a bit awkward since "everything" is available in a Indicator type of routine. So should I write 5 different indicator routines and call them from the EA routine? In that case can I just skip the screen writing in the Indicator routine and just return a value to the EA routine instead. Or do i have to return an array of values that match all the bars?

Struggling along
Ingvar
If you are just looking for the close of certain bars, and not the MA value of a certain bar, you could use the Close[] series array. I'm not sure if this will help you or not.

To call the close of current bar use Close[0]

To call the close of of 5 bars ago use Close[5]

Again, I'm not sure if this is helping you or not. You probably already know this. From reading your posts you seem to have more programming experience than me.

Hope this helps somehow.
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
  #604 (permalink)  
Old 12-30-2007, 08:39 AM
Member
 
Join Date: Dec 2007
Location: Outside Stockholm
Posts: 45
ingvar_e is on a distinguished road
Hi Wolfe,

Yes, I know about the CLose[i]. The problem is that this array is not readily available in a library routine it seems. When programming I like to strukture all code in functional "pieces" and ideally one "piece" should not exceed one page in length.

Happy New Year
Ingvar
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
  #605 (permalink)  
Old 01-02-2008, 05:44 AM
Junior Member
 
Join Date: Mar 2007
Posts: 5
biosq is on a distinguished road
Smile Anybody here can help me?...

Hello guys...

What i want is..I plan to use 3 indicator...when 3 indicator signal buy and ea make a BUY post then after Target Point, i dont want ea make a buy post again and ea waiting until indicator give signal SELL.Like BUY,SELL,BUY,SELL,BUY,SELL and forever.I don care if in one day the indicator give signal for BUY or for SELL only.
Thanks to who can help me.

Last edited by biosq; 01-02-2008 at 05:47 AM.
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
  #606 (permalink)  
Old 01-02-2008, 08:38 AM
Junior Member
 
Join Date: Nov 2005
Posts: 27
waleed9091 is on a distinguished road
sell,buy,sell,buy.....

hi..
i want to add a code to my expert that let expert close sell or buy position when certaine pips reached"say 50 pips"... then look only for opposite position of first closed position " if first closed position was sell, look for buy to close"...third position closed will be opposite for 2nd closed position....
report of account will be :
sell
buy
sell
buy
sll
buy

is this possible to be coded?
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
  #607 (permalink)  
Old 01-04-2008, 07:31 AM
Senior Member
 
Join Date: Sep 2006
Posts: 120
Dr.GM is on a distinguished road
use "comment(all you variables,v2,v3,v4...)" to preview all variables you have in the expert
and run a visual test ... and keep your eye in the upper left corner specially when long signal is expected
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
  #608 (permalink)  
Old 01-08-2008, 09:38 AM
MrM MrM is offline
Member
 
Join Date: Jul 2007
Posts: 81
MrM is on a distinguished road
Two indicators: from two in 1 window to 2 in 2 windows with different values...

Imagine you put two seperate (custom) indicators in the same seperate chart window on a chart in your terminal. They seem to correspond, cross over or whatever: they do have approximately the same values if you look at the graph, but when you place those two custom indicators in two other seperate chart windows, they turn out to have different values.

This looks like a pretty common problem to me, but I haven't found the answer on making those two indicators range between the same set of numbers (more or less) without changing the shape of the indicator. Please help.
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
  #609 (permalink)  
Old 01-09-2008, 02:10 AM
Linuxser's Avatar
User Root
 
Join Date: May 2006
Location: Helliconia (Winter)
Posts: 4,410
Blog Entries: 56
Linuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond repute
Quote:
Originally Posted by MrM View Post
Imagine you put two seperate (custom) indicators in the same seperate chart window on a chart in your terminal. They seem to correspond, cross over or whatever: they do have approximately the same values if you look at the graph, but when you place those two custom indicators in two other seperate chart windows, they turn out to have different values.

This looks like a pretty common problem to me, but I haven't found the answer on making those two indicators range between the same set of numbers (more or less) without changing the shape of the indicator. Please help.
Can you past a picture as example?

I´m trying to understand your question.
You refer to something like drop rsi above macd?
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
  #610 (permalink)  
Old 01-09-2008, 08:32 PM
Junior Member
 
Join Date: Aug 2007
Posts: 3
sorrex is on a distinguished road
Function for programmed scrolling of windows

I use MTF stochastic for trading.
When I manually backtest some ideas I have open more windows with various TF where I check actual status of indicators. My idea is to put vertical line on actual time in main TF windows and using global variables and joined "move" indicator on other TF windows for automatic scroll that I can see actual situation without manual scrolling every TF window.
But - I cannot find any function that allows me to scroll windows to defined position (shift). Have anybody an idea how to do it? thx in advn
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
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop


Currently Active Users Viewing This Thread: 2 (1 members and 1 guests)
sparow21
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
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 05:22 PM


All times are GMT. The time now is 02:47 PM.



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