Coding help - page 258

 
Tomcat98:
Hi Mladen , hi all,

Damned new Build!

With B625 I've now got new warnings.

"return value of 'OrderSelect' should be checked"

for following code:

"OrderSelect(i,SELECT_BY_POS,MODE_TRADES);"

How to correct that?

Thanks for all.

Tomcat98

Tomcat98

Do the following :

declare one global boolean variable (like this, for example) :

bool dummyResult;

And then simply place "dummyResult =" in front of the OrderSelect -then you will have the following :

dummyResult = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

 
Tomcat98:
Hi Mladen , hi all,

Damned new Build!

With B625 I've now got new warnings.

"return value of 'OrderSelect' should be checked"

for following code:

"OrderSelect(i,SELECT_BY_POS,MODE_TRADES);"

How to correct that?

Thanks for all.

Tomcat98

Well, you can get rid of it for cost of some effort.

But I am having a permanent warning, that I cannot remove by any means (except of removing the line of the source code):

struct Empty {};[/CODE]

results in

[CODE]! struct has no members, size assigned to 1 byte

which is useless info, if I use it as a supertype for dll calls only (I have no idea of any other use of the empty structure).

 

Hi Mladen,

Yes it works:

Great job.

Thanks very much for your help.

Sincerely.

Tomcat98

 

Hi All,

since some days I'm getting sporadically the following error in one of my indicators which i use in my EA.

2014.04.10 09:01:49.533 2014.01.08 03:45 Access violation write to 0xFFFFFFFE in 'C:\Users\...\AppData\Roaming\MetaQuotes\Terminal\D5D5AE2430FC68F628F143CAFA9XXXX\MQL4\indicators\MyDailyFibo.ex4'

I use MT Version 4. Build 625

Please help me to find the root cause of this issue. Let me know if you need to look in to the indicator. It does not appear all the time but very often...

Thx and best regards,

Antony

 
Antony1:
Hi All,

since some days I'm getting sporadically the following error in one of my indicators which i use in my EA.

2014.04.10 09:01:49.533 2014.01.08 03:45 Access violation write to 0xFFFFFFFE in 'C:\Users\...\AppData\Roaming\MetaQuotes\Terminal\D5D5AE2430FC68F628F143CAFA9XXXX\MQL4\indicators\MyDailyFibo.ex4'

I use MT Version 4. Build 625

Please help me to find the root cause of this issue. Let me know if you need to look in to the indicator. It does not appear all the time but very often...

Thx and best regards,

Antony

Antony

That is not a problem with your indicator

It is a problem with new metatrader 4 (it is having problems with proper memory allocation and access - build 628 is a bit better but not much)

 

Hi,

i need help with this indicator i was trying to write (Wilder trailing stop candles MTF).

First problem: my indicator draws buy signal 1 bar before of that one should be and i know this is due to the way the slope is calculated but i don't know how to fix it.

Second problem: Colors don't match, probably i messed up with buffers in this part but i'm garbling myself i can't fix it :

if (UpLineBuffer!=EMPTY_VALUE)

{

UpBodyBuffer = High;

DnBodyBuffer = Low;

UpWickBuffer = MathMax(Open,Close);

DnWickBuffer = MathMin(Open,Close);

}

else

{

DnBodyBuffer = High;

UpBodyBuffer = Low;

DnWickBuffer = MathMax(Open,Close);

UpWickBuffer = MathMin(Open,Close);

wilders_trailing_stop_candles_mtf.mq4

wilders_trailing_stop_mtf_1.mq4

wilders_trailing_stop.mq4

 
thefxpros:
Hi,

i need help with this indicator i was trying to write (Wilder trailing stop candles MTF).

First problem: my indicator draws buy signal 1 bar before of that one should be and i know this is due to the way the slope is calculated but i don't know how to fix it.

Second problem: Colors don't match, probably i messed up with buffers in this part but i'm garbling myself i can't fix it :

if (UpLineBuffer!=EMPTY_VALUE)

{

UpBodyBuffer = High;

DnBodyBuffer = Low;

UpWickBuffer = MathMax(Open,Close);

DnWickBuffer = MathMin(Open,Close);

}

else

{

DnBodyBuffer = High;

UpBodyBuffer = Low;

DnWickBuffer = MathMax(Open,Close);

UpWickBuffer = MathMin(Open,Close);

wilders_trailing_stop_candles_mtf.mq4

wilders_trailing_stop_mtf_1.mq4

wilders_trailing_stop.mq4

mmmhh, colors match. Maybe i need to write first wickbuffers and then bodybuffers?

 
thefxpros:
mmmhh, colors match. Maybe i need to write first wickbuffers and then bodybuffers?

thefxpros

The easiest way is to change the Wilders trailing stop indicator (otherwise you will be caught in some complicated if then else constructions). Here is a version with one internal buffer that you want : trend. If it is equal to 1, the trend is up, if it is equal to -1, the trend is down. Use this indicator instead of the original and simply read the value of buffer 4 - after that all is simple

 
mladen:
thefxpros The easiest way is to change the Wilders trailing stop indicator (otherwise you will be caught in some complicated if then else constructions). Here is a version with one internal buffer that you want : trend. If it is equal to 1, the trend is up, if it is equal to -1, the trend is down. Use this indicator instead of the original and simply read the value of buffer 4 - after that all is simple

Like this ?

//------------------------------------------------------------------

#property copyright "thefxpros"

#property link "thefxpros@katamail.com"

//------------------------------------------------------------------

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 DarkGreen

#property indicator_color4 FireBrick

#property indicator_width1 1

#property indicator_width2 2

//

//

//

extern int TimeFrame = 0;

extern int Length = 2;

extern double Coeff = 1.75;

extern color UpBodyColor = LimeGreen;

extern color DnBodyColor = Orange;

extern color UpWickColor = DarkGreen;

extern color DnWickColor = FireBrick;

extern int WickWidth = 1;

extern int BodyWidth = 2;

//

double UpBodyBuffer[];

double DnBodyBuffer[];

double UpWickBuffer[];

double DnWickBuffer[];

double TrendBuffer[];

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

//| |

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

int init()

{

IndicatorBuffers(6);

SetIndexBuffer(0,UpWickBuffer); SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, WickWidth, UpWickColor);

SetIndexBuffer(1,DnWickBuffer); SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, WickWidth, DnWickColor);

SetIndexBuffer(2,UpBodyBuffer); SetIndexStyle(2,DRAW_HISTOGRAM, EMPTY, BodyWidth, UpBodyColor);

SetIndexBuffer(3,DnBodyBuffer); SetIndexStyle(3,DRAW_HISTOGRAM, EMPTY, BodyWidth, DnBodyColor);

SetIndexBuffer(4,TrendBuffer);

IndicatorShortName("Wilders trailing stop MTF candles("+Length+","+Coeff+")");

Length = MathMax(Length,1);

switch(TimeFrame)

{

case 1 : string TimeFrameStr="Period_M1"; break;

case 5 : TimeFrameStr="Period_M5"; break;

case 15 : TimeFrameStr="Period_M15"; break;

case 30 : TimeFrameStr="Period_M30"; break;

case 60 : TimeFrameStr="Period_H1"; break;

case 240 : TimeFrameStr="Period_H4"; break;

case 1440 : TimeFrameStr="Period_D1"; break;

case 10080 : TimeFrameStr="Period_W1"; break;

case 43200 : TimeFrameStr="Period_MN1"; break;

default : TimeFrameStr="Current Timeframe";

}

IndicatorShortName("Wilders trailing stop MTF candles("+TimeFrameStr+")");

return(0);

}

//----

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

//| MTF function |

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

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,Symbol(),TimeFrame);

limit= MathMin(Bars-counted_bars+3*TimeFrame/Period(),Bars-1);

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

{

if (Time<TimeArray[y]) y++;

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

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

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

int slope=iCustom(Symbol(),TimeFrame,"Wilders trailing stop with trend",Length,Coeff,4,y);

if (slope == 1)

{

UpWickBuffer = High;

DnWickBuffer = Low;

UpBodyBuffer = MathMax(Open,Close);

DnBodyBuffer = MathMin(Open,Close);

}

if (slope == -1)

{

DnWickBuffer = High;

UpWickBuffer = Low;

DnBodyBuffer = MathMax(Open,Close);

UpBodyBuffer = MathMin(Open,Close);

}

}

return(0);

}

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

I can't believe, it works at first attempt .....Is there anything else i can write better (delete trendbuffer yes, i saw now) than i made?

thanks Mladen

Files:
cattura_2.jpg  72 kb
 
mladen:
You can not draw lines with length in inches on chart (it is completely impossible using metatrader and I doubt that it is possible in any trading platform). And those lines are horizontal lines objects not trend lines (trend lines can be limited but horizontal lines can not). If there is no exact mathematical rule how the lines should be drawn (depending on price, not inches) they simply can not be drawn, and from those sequence of numvers it seems that the rules are unique for each and every line

Ok thanks I found a better indy which you can edit. It was an unfinished project a coder did in forexfactory and can't locate him anymore. Please replace 00, 20, 50, 80 with my numbers. Lines are also cluster together instead of just placing on special numbers 5, 15, 31, 45 and 67.

Thanks

Files: