• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 5:38am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 5:38am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Referencing custom indicator data 2 replies

Referencing higher timeframe data in an indicator 2 replies

Referencing offline charts for tick chart EAs 0 replies

Have a problem referencing iCustom 3 replies

IB referencing to my account 12 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: Referencing Indicator Arrays.
Cancel

Referencing Indicator Arrays.

  • Post #1
  • Quote
  • First Post: Edited 6:44pm Mar 14, 2009 5:05pm | Edited 6:44pm
  •  Cdavid
  • | Joined Apr 2008 | Status: Member | 112 Posts
Is it possible to reference an array that has already been initialized in an indicator. Something similar to the iCustom function, perhaps passing the window index, indicator name and buffer /array index.

I have an indicator that creates 6 buffers/arrays. I then have a couple of other indicators that run duplicated code to produce perhaps 2 or 3 of these same buffers. Everything is working fine but I am finding it can be costly in performance, the details of which I won’t go into at present.

If I understand it correctly, iCustom, with its parameters, actually runs the code ( in its own thread) to produce the desired return value, which is great but not what I need if my primary concern at the moment is performance.

What I am after is the ability to reference a particular array of an indicator that is ALREADY initialized. In this case the referencing would be from a different indicator mounted in the same window. But it would be handy if it could be referenced from elsewhere as I have other indicators in separate sub windows that again duplicate code to produce 1 or 2 of the base indicator's buffers.

I have read through a bunch of articles but not finding what I need. I don’t think it’s possible as surely this would be a well documented strategy for partially overcoming the 8 buffer limit on each indicator. (Why do they have that ?)

Hmmm…. Or am I answering my own question here… is the solution to redesign my indicators to utilize a series of iCustom calls…. Hmnmmmm….. complicated and probably beyond my novice programming skills.

Any thoughts/tips or a decisive “NO… it can’t be done” would be greatly appreciated. Sorry if this question has been addressed before and/or displays my ignorance of MQL.

Many thanks in advance to any replies.
  • Post #2
  • Quote
  • Mar 14, 2009 6:02pm Mar 14, 2009 6:02pm
  •  magnumfreak
  • Joined Nov 2007 | Status: Trying manual mode again | 2,210 Posts
Verify that your indicators are only calculating for candles that have changed. One of the biggest performance killers are indicators that go through every candle every tick.
 
 
  • Post #3
  • Quote
  • Edited 8:06pm Mar 14, 2009 6:43pm | Edited 8:06pm
  •  Cdavid
  • | Joined Apr 2008 | Status: Member | 112 Posts
Quoting magnumfreak
Disliked
Verify that your indicators are only calculating for candles that have changed. One of the biggest performance killers are indicators that go through every candle every tick.
Ignored

Thanks for the reply magnumfreak.

Yes, using counted_bars = IndicatorCounted()
ect ect.

I appreciate it is difficult to comment on code when I have none posted.... but I guess I was just hoping there would be a quick and easy answer....

YES .... you do it like this.

I am confident that the basic code is ok... I will post it if needed.... but I am confident the basic code is good because smjones wrote it ..... hahahahah.

The problem I am having is more theoretical than anything else... I am finding that I am duplicating a lot of code to reproduce a value that is already produced in an indicator ....... wouldnt it be great if I could reference that value instead of running the code again and again.... Like I said .... my code is running fine, but as I tweak it here and tweak it there experimenting with other indicators that use the same base inidicator buffers... this question keeps coming up for me .... prompting me to spend hours trawling help files and articles here and at tsd to see if there is a solution to what I am sure is a common problem.

Basically .... can an intialized array in an indicator be referenced from another separate indicator.

The indicator in question is one that plots a basket of currency pairs as a single currency pair ...ie it sums the HLOC of each currency pair and plots it as a candle.

Maybe I am not explaining it clearly enough. But I cant think of a better way to explain it other than posting pages and pages of code.


================================================================
ok here are some segments of the code that may help explain what I mean .... I can post the indicators if needed but it would take some time as I have made quite a lot of modifictions to the basic basket indicator that allow me to load different baskets quickly ... but I am sure you will see what I mean in relation to the threads question.


int start()
{
int counted_bars=IndicatorCounted();
double ch,cl,cb,co;
if(counted_bars<0) return(-1);

//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int pos=Bars-counted_bars;

while (pos>=0)
{

ch =gethigh(Pair1,Tperiod,pos)+gethigh(Pair2,Tperiod,pos)+gethigh(Pair3,Tperiod,pos)+
gethigh(Pair4,Tperiod,pos)+gethigh(Pair5,Tperiod,pos)+gethigh(Pair6,Tperiod,pos)+
gethigh(Pair7,Tperiod,pos)+
gethigh(Pair8,Tperiod,pos) ;

cl = getlow(Pair1,Tperiod,pos)+getlow(Pair2,Tperiod,pos)+getlow(Pair3,Tperiod,pos)+
getlow(Pair4,Tperiod,pos)+getlow(Pair5,Tperiod,pos)+
getlow(Pair6,Tperiod,pos)+getlow(Pair7,Tperiod,pos)+
getlow(Pair8,Tperiod,pos);

cb =getbid(Pair1,Tperiod,pos)+getbid(Pair2,Tperiod,pos)+getbid(Pair3,Tperiod,pos)+
getbid(Pair4,Tperiod,pos)+getbid(Pair5,Tperiod,pos)+
getbid(Pair6,Tperiod,pos)+getbid(Pair7,Tperiod,pos)+
getbid(Pair8,Tperiod,pos);

co =getopen(Pair1,Tperiod,pos)+getopen(Pair2,Tperiod,pos)+getopen(Pair3,Tperiod,pos)+
getopen(Pair4,Tperiod,pos)+getopen(Pair5,Tperiod,pos)+
getopen(Pair6,Tperiod,pos)+getopen(Pair7,Tperiod,pos)+
getopen(Pair8,Tperiod,pos);

.................................................
these values are then passed to a series of buffers and used to plot a candle.

the called fuctions are below:-
.................................................

double gethigh(string c,int tf, int ni)
{
if ( StringLen(c) < 6 ) return(0);
RefreshRates();
double chigh = iHigh(c,tf,ni)/MarketInfo(c,MODE_POINT);
return(chigh);
}
double getlow(string c,int tf, int ni)
{
if ( StringLen(c) < 6 ) return(0);
RefreshRates();
double clow = iLow(c,tf,ni)/MarketInfo(c,MODE_POINT);
return(clow);
}

double getbid(string c,int tf, int ni)
{
if ( StringLen(c) < 6 ) return(0);
RefreshRates();
double cbid = iClose(c,tf,ni)/MarketInfo(c,MODE_POINT);
return(cbid);
}

double getopen(string c,int tf, int ni)
{
if ( StringLen(c) < 6 ) return(0);
RefreshRates();
double copen = iOpen(c,tf,ni)/MarketInfo(c,MODE_POINT);
return(copen);
}
=========================================================


So now suppose I want to produce an RSI indicator or Stochs indicator for the basket.... instead of having to duplicate code to reproduce the buffers for say ... the bid (for RSI) .... or the High, low, bid buffers (for Stochs)

is it possible to Reference the Original Indicator in say .... sub Window1, indicator= BasketBars, buffer1, array element 27 or whatever.

Hopefully you can see where I am going with this. Is there something that I am missing in general MQL programming that could reduce all this redundant/duplicated code I am currently using.

As I said .... my indicators are working fine ..... but I have this nagging feeling that I am missing something that could make the whole thing SO much easier and possibly faster.

I appreciate that being able to reference the original indicator... would not result in much faster performance in this instance as both buffers ... in the orig and in the RSI basket indicator are only modifiying the latest changed candles as you pointed out.... but theoretically .... is it possible.

As the end result of my strategy uses multiple timeframes for each of 8 baskets, each timeframe uses RSI and Stochs with each having 3 different periods .... so even though in one instance the performance increase may be negligible, overall it could be significant.

Thanks again for any help or tips.... I appreciate it.
 
 
  • Post #4
  • Quote
  • Mar 14, 2009 7:57pm Mar 14, 2009 7:57pm
  •  magnumfreak
  • Joined Nov 2007 | Status: Trying manual mode again | 2,210 Posts
I see what you are asking for and unfortunately you cannot reference the buffers from a running indicator. That would actually be nice, and MT4 isn't about nice. LOL!

Your only hope is the iCustom function where you can reference each of the buffers individually.
 
 
  • Post #5
  • Quote
  • Last Post: Mar 14, 2009 8:38pm Mar 14, 2009 8:38pm
  •  Cdavid
  • | Joined Apr 2008 | Status: Member | 112 Posts
Quoting magnumfreak
Disliked
I see what you are asking for and unfortunately you cannot reference the buffers from a running indicator. That would actually be nice, and MT4 isn't about nice. LOL!
Ignored

Thanks magnumfreak.

I didnt think so.

Oh well .... at least Im not wondering anymore.

Cheers mate.
 
 
  • Platform Tech
  • /
  • Referencing Indicator Arrays.
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023