Coding help - page 384

 

I'm getting an error/warning when I compile. Can someone please make this compatible with latest MT4 builds...unless this error is not a big deal.

Much thanks

jbozman

Files:
 
jbozman:
I'm getting an error/warning when I compile. Can someone please make this compatible with latest MT4 builds...unless this error is not a big deal.

Much thanks

jbozman

jbozman

Try it out now : price_lines_jlmv_1.mq4

Files:
 
mladen:
jbozman Try it out now : price_lines_jlmv_1.mq4

No errors. Compiled and looks fine. You rock.

j

 

please help ... if i compile ... no have error

but at Expert Tab metatrader have error

2014.11.02 15:20:17.495 array out of range in '#MTF__B.mq4' (84,25)[/PHP]

[PHP]

//+------------------------------------------------------------------+

//| #MTF__B.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//| https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2014, MetaQuotes Software Corp."

#property link "https://www.mql5.com"

#property version "1.00"

#property strict

#property indicator_chart_window

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrDodgerBlue

#property indicator_color2 clrDeepPink

#property indicator_width1 0

#property indicator_width2 0

//---- input parameters

/*************************************************************************

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE 0 Close price.

PRICE_OPEN 1 Open price.

PRICE_HIGH 2 High price.

PRICE_LOW 3 Low price.

PRICE_MEDIAN 4 Median price, (high+low)/2.

PRICE_TYPICAL 5 Typical price, (high+low+close)/3.

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

**************************************************************************/

extern int TimeFrame=30;

extern int barn=1000;

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicator line

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(0,DRAW_ARROW,0,5);

SetIndexStyle(1,DRAW_ARROW,0,5);

SetIndexArrow(0,158);

SetIndexArrow(1,158);

return(0);

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,NULL,TimeFrame);

limit=Bars-counted_bars;

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++; ///// line of error here ...

/***********************************************************

Add your main indicator loop below. You can reference an existing

indicator with its iName or iCustom.

Rule 1: Add extern inputs above for all neccesary values

Rule 2: Use 'TimeFrame' for the indicator time frame

Rule 3: Use 'y' for your indicator's shift value

**********************************************************/

ExtMapBuffer1=iCustom(NULL,TimeFrame,"indicator",1,4,0,y) ;

ExtMapBuffer2=iCustom(NULL,TimeFrame,"indicator",1,4,1,y) ;

}

//

return(0);

}

//+------------------------------------------------------------------+

thanks

 
rizkyd:
please help ... if i compile ... no have error

but at Expert Tab metatrader have error

2014.11.02 15:20:17.495 array out of range in '#MTF__B.mq4' (84,25)[/PHP]

[PHP]

//+------------------------------------------------------------------+

//| #MTF__B.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//| https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2014, MetaQuotes Software Corp."

#property link "https://www.mql5.com"

#property version "1.00"

#property strict

#property indicator_chart_window

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrDodgerBlue

#property indicator_color2 clrDeepPink

#property indicator_width1 0

#property indicator_width2 0

//---- input parameters

/*************************************************************************

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE 0 Close price.

PRICE_OPEN 1 Open price.

PRICE_HIGH 2 High price.

PRICE_LOW 3 Low price.

PRICE_MEDIAN 4 Median price, (high+low)/2.

PRICE_TYPICAL 5 Typical price, (high+low+close)/3.

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

**************************************************************************/

extern int TimeFrame=30;

extern int barn=1000;

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicator line

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(0,DRAW_ARROW,0,5);

SetIndexStyle(1,DRAW_ARROW,0,5);

SetIndexArrow(0,158);

SetIndexArrow(1,158);

return(0);

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,NULL,TimeFrame);

limit=MathMin(Bars-counted_bars,Bars-1);

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++; ///// line of error here ...

/***********************************************************

Add your main indicator loop below. You can reference an existing

indicator with its iName or iCustom.

Rule 1: Add extern inputs above for all neccesary values

Rule 2: Use 'TimeFrame' for the indicator time frame

Rule 3: Use 'y' for your indicator's shift value

**********************************************************/

ExtMapBuffer1=iCustom(NULL,TimeFrame,"indicator",1,4,0,y) ;

ExtMapBuffer2=iCustom(NULL,TimeFrame,"indicator",1,4,1,y) ;

}

//

return(0);

}

//+------------------------------------------------------------------+

thanks

Try replaceing this line

limit=Bars-counted_bars;

with this :

limit=MathMin(MathMax(Bars-counted_bars,2*TimeFrame/Period()),Bars-1);

 
mladen:
Try replaceing this line

limit=Bars-counted_bars;

with this :

limit=MathMin(MathMax(Bars-counted_bars,2*TimeFrame/Period()),Bars-1);

thanks mladen

 

Hi Mladen,

I'm having trouble coding this EA since the entry rules are something I've never done before.

For example, in this trade, it's simple to write the entry rule since the green and red arrow appear at the same time. So on the open of next candle, we take a short position.

But, in this next example, I first get the green arrow without a red arrow. So I don't take the trade until the red arrow appears. On top of that, all candles that are after that green arrow and before that red arrow must be UP ones since otherwise this is not a valid trade.

How the hell do I code this specific rule? I know how to code it for current candle, but I don't know how to specify these conditions. Any help would be great!

Files:
capture1.jpg  19 kb
capture.jpg  22 kb
 
Jason2005:
Hi Mladen,

I'm having trouble coding this EA since the entry rules are something I've never done before.

For example, in this trade, it's simple to write the entry rule since the green and red arrow appear at the same time. So on the open of next candle, we take a short position.

But, in this next example, I first get the green arrow without a red arrow. So I don't take the trade until the red arrow appears. On top of that, all candles that are after that green arrow and before that red arrow must be UP ones since otherwise this is not a valid trade.

How the hell do I code this specific rule? I know how to code it for current candle, but I don't know how to specify these conditions. Any help would be great!

Jason

Why don't you copy the logical conditions from the code that is creating those arrows?

 
mladen:
Jason Why don't you copy the logical conditions from the code that is creating those arrows?

I'm not quite sure I understand what you're saying...

What I'm trying to find out is how in my buy or sell conditions I make the EA understand that when the red arrow appears (that is trigger) the condition is that there must have been a green arrow before and that all the candles that follow that arrow must be UP or DOWN depending on what is needed. But I don't know when that green arrow would have appeared...

 
Jason2005:
I'm not quite sure I understand what you're saying... What I'm trying to find out is how in my buy or sell conditions I make the EA understand that when the red arrow appears (that is trigger) the condition is that there must have been a green arrow before and that all the candles that follow that arrow must be UP or DOWN depending on what is needed. But I don't know when that green arrow would have appeared...

Hi Jason2005,

The Red and Green Arrows are values in the buffers of your indicator....not your EA....

Use iCustom in your EA to call your indicator values in the buffers...and then use them for your trading strategy.

There are many good posts here in this forum about how to use iCustom in your EA...

In the meantime...if you attach your indicators here...someone may be able to help show you which indicator buffers you can use in your iCustom statements.

Hope this helps,

Robert