ICustom function - page 12

 

Can anyone post a simple ea that buys and sells, by calling two indicators with icustom().

Is there a function for closing pending orders.

Thanks

 

iCustom help

Hi.

I'm attempting to modify one of FerruFX's indicators to use custom indicators. I've already gotten all the MAs to work correctly, but I'm not sure how to get the correct information for the other two indicators. I would ultimately like this to display the MTF data from the two indicators I've attached, PerkyAsctrend1 and HeikenAshi MTF. I'm using iCustom for both and I think I've used the correct commands to that extent.

I'm able to produce data (but not the correct data) for the PerkyAsctrend1. I thought I understood the logic to get it to display correctly, but I guess I don't. Ferru used MA, CCI, MACD, ADX, Bullspower and BearsPower in his indicator, but they're different kinds of indicators and unfortunately aren't very useful as a reference (to me) for PerkyAsctrend1 in this setting.

I thought the HeikenAshi MTF indicator would be easy enough to add to the indicator. Apparently I was wrong. The Heiken column is displaying "Label" inexplicably and they're all disappearing after the first tick.

Hopefully the code doesn't actually look as gross to you as it does to me. I'm an amateur programmer. If anyone can help, I'd really appreciate it. I need a more experienced pair of eyes on this. I feel it will be quite beneficial when complete.

-

Here are the bits of code that are giving me trouble. Both the iCustoms are giving me values of 2147483647, the total number of bars in the price history/chart.

int RISK = 4;

int AllBars = 250;

int MaMethod = 1;

int MaPeriod = 20;

//...

// Pesky

//...

string Pesky_Trend_1 //-- , Pesky_Trend_5, Pesky_Trend_15, Pesky_Trend_30, Pesky_Trend_60, Pesky_Trend_240, Pesky_Trend_1440, Pesky_Trend_10080;

double Pesky_m_1=iCustom(NULL,PERIOD_M1, "PerkyAsctrend1", RISK, AllBars,0,shift_1);

if ((Pesky_m_1 > 0)) { Pesky_Trend_1 = "UP"; x = 416; color_indic = Lime; UP_33 = 1; DOWN_33 = 0; }

if ((Pesky_m_1 < 0)) { Pesky_Trend_1 = "DOWN"; x = 406; color_indic = Red; UP_33 = 0; DOWN_33 = 1; }

// ...

// Indicator (Heiken)

//...

string HA_Trend_1 //-- , HA_Trend_5, HA_Trend_15, HA_Trend_30, HA_Trend_60, HA_Trend_240, HA_Trend_1440, HA_Trend_10080;

double HA_1_1=iCustom(NULL,PERIOD_M1,"Heiken MTF",MaMethod,MaPeriod,shift_1);

double HA_2_1=iCustom(NULL,PERIOD_M1,"Heiken MTF",MaMethod,MaPeriod,shift_1+1);

if ((HA_1_1 > HA_2_1)) { HA_Trend_1 = "UP"; x = 466; color_indic = Lime; UP_41 = 1; DOWN_41 = 0; }

if ((HA_1_1 < HA_2_1)) { HA_Trend_1 = "DOWN"; x = 456; color_indic = Lime; UP_41 = 0; DOWN_41 = 1; }

//...

I know the shift values are unorthodox but that's how the original author did it.

int start()

{

//...

// Shift calculation for indicators (tests only)

double shift_1, shift_5, shift_15, shift_30, shift_60, shift_240, shift_1440, shift_10080;

if( test == true )

{

shift_1=iBarShift(NULL,PERIOD_M1,look_time_shift,false);

shift_5=iBarShift(NULL,PERIOD_M5,look_time_shift,false);

shift_15=iBarShift(NULL,PERIOD_M15,look_time_shift,false);

shift_30=iBarShift(NULL,PERIOD_M30,look_time_shift,false);

shift_60=iBarShift(NULL,PERIOD_H1,look_time_shift,false);

shift_240=iBarShift(NULL,PERIOD_H4,look_time_shift,false);

shift_1440=iBarShift(NULL,PERIOD_D1,look_time_shift,false);

shift_10080=iBarShift(NULL,PERIOD_W1,look_time_shift,false);

}

else

{

shift_1=shift_indicators;

shift_5=shift_indicators;

shift_15=shift_indicators;

shift_30=shift_indicators;

shift_60=shift_indicators;

shift_240=shift_indicators;

shift_1440=shift_indicators;

shift_10080=shift_indicators;

Thank you...

 

Updated versions

Well I've rearranged everything as it needs to be visually and changed some parameter names. Everything still looks to be correct for iCustom but the PerkyAsctrend value is not being calculated correctly and the Heiken logic is apparently completely wrong. It seems that it's not evening providing a double value for the iCustom for the Heiken MTF indicator. I haven't checked them again yet but both of the iCustom double values for the indicators were equal to the number of bars in my history (2147483647)...! I've got to be doing something completely wrong with iCustom but I can't find it for the life of me.

If you have the time or energy to look over this, I'd be most appreciative.

Files:
 

To: Homicida & Ra457 re: iCustom

Hi.

That big number value that you get when you use iCustom, sounds like a difficulty that I had.

I hope this helps.

Make sure that the parameters that you enter into iCustom are exactly the same, and in the same order as those given in the external variables in the indicator code itself.

Cheers.

 

2147483647 has nothing to do with your history.

Its the bigest value that can have a signed 32 bits integer and is used by MT4 as the default "Empty Value" of indicators.

Indicators are returning "Empty Value" when the value are not to be showed.

 

iCustom()

Hi, I need to read three varaiables from an Indicator.

I have placed hem at the top of the indicator:

Variables

double eaBid=0;

double eaAsk=0;

string eaType="";

//==========================

Variables

#property indicator_separate_window

#property indicator_buffers 8

#property indicator_color1 Black

#property indicator_color2 Lime

#property indicator_color3 Lime

#property indicator_color4 Yellow

#property indicator_color5 Red

#property indicator_color6 Red

#property indicator_color7 Black

#property indicator_color8 Black

double eaEP=0;

double eaSL=0;

double eaType=0;

double iVars[];

Stuff

#property indicator_buffers 2

#property indicator_color1 Red

#property indicator_color2 ForestGreen

//---- input parameters

string IndicatorName="TradeWatch";

double EntryBid=0;

double EntryAsk=0;

string EntryType="";

double eaBid=0;

double eaAsk=0;

string eaType="";

int init()

{

return (0);

}

Start

{

EntryBid = iCustom(Symbol(), Period(), IndicatorName, eaBid, eaAsk, eaType, 1, 0);

EntryAsk = iCustom(Symbol(), Period(), IndicatorName, eaBid, eaAsk, eaType, 2, 0);

EntryType = iCustom(Symbol(), Period(), IndicatorName, eaBid, eaAsk, eaType, 3, 0);

}

How do I read the three variables in to my EA?

I can't see where I am going wrong?

Thanks.

 

Why don't you just read the results of the variables which should reflect in the indicator buffer values?? If you look at the colors in the indicator setup after you place the indicator on the graph, each color represents a buffer. The top color = buffer0, the second from the top color = buffer1 and so forth.

Use something like this in your EA:

Buff0=iCustom(NULL,0,"Indicator Name",0,0); //Top color of indicator

Buff0=iCustom(NULL,0,"Indicator Name",0,1); //1-Back

Buff1=iCustom(NULL,0,"Indicator Name",1,0); //Next to top color of indicator

Buff1=iCustom(NULL,0,"Indicator Name",1,1); //1-Back

Modify the variables in the indicator itself, and recompile the indicator which will update the buffers and the indicator on the graph!

If still confused, I will send you an actual EA and indicator for you to look at.

Dave

<<<

 

iCustom()

Thanks Dave.

Got it working.

 

have a nice day all

 

my EA

i have created my EA - ASCTrend.mq4 with MQ4 builder, which uses asctrend signal with ICustom function. it can open a BUY trade when UP signal, and SELL when DOWN.

i want to add to my EA some filter - with backtesting in some pairs, its look good fo filter with BBands ind, bud i dont know how to add this filter in my EA - something like that I think, but have no luck.

double Buy1_1 = iCustom(Symbol(),0,"PerkyAsctrend1",0,1);

double Buy2_1 = iCustom(NULL, 0, "BBands_Stop_v1", 4, 0, Current + 1);

double Buy2_2 = 1;

double Sell1_1 = iCustom(Symbol(),0,"PerkyAsctrend1",1,1);

double Sell2_1 = iCustom(NULL, 0, "BBands_Stop_v1", 5, 0, Current + 1);

double Sell2_2 = 1;

if (Buy1_1 && Buy2_1 > Buy2_2) Order = SIGNAL_BUY;

if (Sell1_1 && Sell2_1 > Sell2_2) Order = SIGNAL_SELL;

Reason: