ICustom function - page 15

 

is there is any example for using icustom fuction to get two time frame same buffer?

since 2 tf buffer has same name, how am I able to determine the different time frame?

current time frame

double trend = iCustom(NULL, 1, "HA01", 0, 1500, 0, 0);

higher time frame

double trend = iCustom(NULL, 5, "HA01", 0, 1500, 0, 1);

 
Try like this :
double trend1minute = iCustom(NULL, 1, "HA01", 0, 1500, 0, 0); double trend5minute = iCustom(NULL, 5, "HA01", 0, 1500, 0, 1);

And then use the 2 variables as you need (for example : if (trend1minute == ... && trend5minute ==... ) do something)

mtuppers:
is there is any example for using icustom fuction to get two time frame same buffer?

since 2 tf buffer has same name, how am I able to determine the different time frame?

current time frame

double trend = iCustom(NULL, 1, "HA01", 0, 1500, 0, 0);

higher time frame

double trend = iCustom(NULL, 5, "HA01", 0, 1500, 0, 1);
 

Using iCustom in an EA, Single instance

Hello all,

I am working on writing an EA to use a custom indicator, when I backtest, I notice that it seems to load a new instande of the indicator everytime is calls to the iCustom function. Does anyone know a way to load the Custom indicator once and the reference back to it on each succession ?

void OnBar()

{

RSIPL = iCustom(NULL,0,"NCH_DI",0,4,BarIndex);

TSL = iCustom(NULL,0,"NCH_DI",0,5,BarIndex);

HAOpen = iCustom(NULL,0,"HeikenAshi",0,2,BarIndex);

HAClose = iCustom(NULL,0,"HeikenAshi",0,3,BarIndex);

PACHigh = iMA(NULL,0,5,0,MODE_SMMA,PRICE_HIGH,BarIndex);

PACLow = iMA(NULL,0,5,0,MODE_SMMA,PRICE_LOW,BarIndex);

// DO MY OTHER STUFF HERE

}

The above code loads a new instance of the NCH_DI with every call........

Thanks

 

Cannot Do

That is the way MT4 works. The best solution is to minimize the number of iCustom() calls in your code. HA usually only needs to be called when a new bar is formed. Calling it every tick is not optimal.

 
CodeMeister:
That is the way MT4 works. The best solution is to minimize the number of iCustom() calls in your code. HA usually only needs to be called when a new bar is formed. Calling it every tick is not optimal.

I do have all of my calls on a new bar formation. The NCH_DI is unfortunately a relatively memory intensive piece of code. Would you have any suggestions on way that I can dump old instances?

 

Try This

Strategy Tester isn't the ultimate goal of this EA. Running it live on a chart is. I believe that the iCustom() loading happens once on a chart provided you have sufficient memory, so I wouldn't spend a lot of time working on something to suit the peculiarities of Strategy Tester. The only other alternative to iCustom() is to code the indicator directly in the EA.

 

I thought about recoding it into the EA.... I decided that would not be practical in this instance. I have found that if I comment out #property indicator_separate_window in the indicator it will load and unload once call is complete, Im going to finish the main coding and demo it for a week or so and monitor my memory usage. Thanks guys, Ill let you know how it goes.

 

Problems on iCustom Indicator

Hi there,

my EA is using own indicator with iCustom.

On opening of a new candle the indicator is called by iCustom.

Now I realized that the value of iCustom[1] is not equal to iCustom[0] of the previous bar.

The value is similar but not exact the same what it shud be and what I verified for the RSI f.e.

Any idea where problem could be based on?

Thanks for every hint on that.

Camilo

 

It depends of the price that is used by Custom indicator. If your custom indicator is using close, high,low or any other price that is changing during the current candle development then the value of [0] index will be changed.

For example if you will call indicator that is using custom price and compare value [0] and after the bar is closed you will compare it with result at [1] it's almost sure as the egg is egg that the value will be different. But, if you will set custom indicator to use OPEN price instead of close, then the value will be equal (it's simply because open price does not change during candle development)

 

Thx quick answer, Kalenzo.

I checked values for [2] and realized that for [1] -> [2] everything looks ok

Here i have anexample of the values of my indicator

.... [0]..........[1].........[2]

t4 31,8711 42,6700 52,1915

t3 44,6881 52,1915 60,3014

t2 53,0572 60,3014 67,6553

t1 59,8860 67,6553 74,5797

So it looks like the problem is the identifying of the opening of the bar.

I am just using as check before:

if(Volume[0]>1) return;

Isn't that ok?

Reason: