Elite indicators :) - page 183

 

DTosc message...

Mladen,

I get a message in the Expers Folder that says......."incorrect start position 10148 for Array Maximum function" - the indicator seems to behave perfectly though.

Any explanation please?

Thanking you in advance.

 

ValeoFX

Without knowing which indicator it is about, it usually is something like this Find where the limit is determined and change it to something like this :

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

The second parameter in this expression (Bars-1) in this case ensures that limit is not greater than the number of bars on chart.

But, as you already have noticed, it is a "benign" error : it will happen only once (when the indicator is loaded or when the time frame is changed) and, unlike some other errors, it does not stop indicator calculation so all the rest of calculation is done correctly and values are calculated properly

regards

mladen

ValeoFX:
Mladen,

I get a message in the Expers Folder that says......."incorrect start position 10148 for Array Maximum function" - the indicator seems to behave perfectly though.

Any explanation please?

Thanking you in advance.
 

Thanks...

mladen:
ValeoFX

Without knowing which indicator it is about, it usually is something like this Find where the limit is determined and change it to something like this :

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

The second parameter in this expression (Bars-1) in this case ensures that limit is not greater than the number of bars on chart.

But, as you already have noticed, it is a "benign" error : it will happen only once (when the indicator is loaded or when the time frame is changed) and, unlike some other errors, it does not stop indicator calculation so all the rest of calculation is done correctly and values are calculated properly

regards

mladen

======================

Sorry Mladen, I had the name of the indicator in the "Title" window (DTOsc) and did not think to repeat it again. However, thank you for the explanation - I will look at it immediately.

On Line 124 I found:

limit = MathMax(limit,MathMin(Bars,iCustom(NULL,timeFrame,IndicatorFileName,"getBarsCount",0,0)*timeFrame/Period()));

As it is different to what you suggested, would you mind elaborating on what I should do to rectify it, please?

Much appreciated.

 

ValeoFX

I did not pay attention to the subtitle of the message, sorry

Anyway, if you are using the one from this post : https://www.mql5.com/en/forum/general then you are getting that message

On the other hand, if you are using the one from this post : https://www.mql5.com/en/forum/general (the newer one) then you are not going to get that message

I do not remember when exactly did I make the one from the first post but have changed some coding styles since (hence the lack of that error message) and frankly, before I did not care too much for that error message since it really does not change anything. After that I simply decided not to leave any space for any eventual errors, hence the "safety check" when determining the limit

____________________________________

PS: that line works in multi time frame mode. It 'asks" the target time frame how many bars have changed in the target time frame in order to be able to recalculate the exact number of bars in current time frame needed. So that line is effective only when in mtf mode

 

mladen,

I'm new in coding. And its difficult. But if I have only CodersGuru's book to do an EA....... won't be enough...

see my post page 183

 

Tradefx1

Of the daily trend you are trying to find : you need to redefine it (rewrite it). Right now it is written like this :

int GetDailyTrend (int res){

double MA5_1 = double iMA(NULL,1440,5,0,1,0,1);

double MA5_0 = double iMA(NULL,1440,5,0,1,0,0);

double MA8_1 = double iMA(NULL,1440,8,0,1,0,1);

double MA8_0 = double iMA(NULL,1440,8,0,1,0,0);

if (MA5_1 MA8_0) res =1;//Cross up

if (MA5_1 > MA8_1 && MA5_0 < MA8_0) res =2;//Cross down

BarCount=Bars;

return (res);

}[/php]and you are calling it like this :

if (GetDailyTrend(1) && ...) Order = SIGBNAL_BUY;

if (GetDailyTrend(2) && ...) Order = SIGNAL_SELL;

[/php]The way it is used and called now expressions GetDailyTrend(1) and GetDailyTrend(2) are always true (in metatrader any value not equal to 0 is considered a true.

_________________________

Redefine the GetDailyTrend() to something like this:

[php]int GetDailyTrend ()

{

int res = 0;

double MA5_1 = double iMA(NULL,1440,5,0,1,0,1);

double MA5_0 = double iMA(NULL,1440,5,0,1,0,0);

double MA8_1 = double iMA(NULL,1440,8,0,1,0,1);

double MA8_0 = double iMA(NULL,1440,8,0,1,0,0);

if (MA5_1 MA8_0) res =1;//Cross up

if (MA5_1 > MA8_1 && MA5_0 < MA8_0) res =2;//Cross down

return (res);

}

And then use it this way :

[php]if (GetDailyTrend()==1 && ...) Order = SIGBNAL_BUY;

if (GetDailyTrend()==2 && ...) Order = SIGNAL_SELL;

_________________________

As of book and coding : I have always believed that the best way to learn coding is from examples and working programs. Believe it or not but Microsoft people are excellent to learn from (they do write the code uniformly (which means that they have firm team rules how the code should be written) very clean and they are trying to make it as efficient as they can).

There are a lot of examples and working EAs in elite section that anybody can use (I can recommend you this one https://www.mql5.com/en/forum/180383 ) for reasons I stated at that thread already and I think it can easily be used as a "frame" for other EAs. But also, there is a lot of other very useful EAs that can be used to learn and to make working EAs.

And always remember one thing : coding languages are exactly that : "languages". Which means it is a simple talk as any other talk. Just be careful what do you "tell" to computer because computer, unlike people, does not question what you tell it but simply executes it (and then sometimes it is not what we want it to do ) And then, after some time, you get used to "talk" to PC and then everything gets much easier

 

Just in case ...

In case someone is wondering what is the basic logic behind the adxvma indicator, here is one middle step of it that might be as useful as the indicator itself. (there are additional steps after this one, so do not compare the 2 indicators, but this step seems particularly interesting)

If it seems familiar to anyone, the answer is "yes". It seems that it is the power trend indicator (the "real" power trend, not the ones that are posted and published as it - of this I am not 100% sure (all I have seen from the "real" one are pictures of it), but it sure as hell looks a lot like it)
Files:
 
mladen:
ValeoFX

I did not pay attention to the subtitle of the message, sorry

Anyway, if you are using the one from this post : https://www.mql5.com/en/forum/general then you are getting that message

On the other hand, if you are using the one from this post : https://www.mql5.com/en/forum/general (the newer one) then you are not going to get that message

I do not remember when exactly did I make the one from the first post but have changed some coding styles since (hence the lack of that error message) and frankly, before I did not care too much for that error message since it really does not change anything. After that I simply decided not to leave any space for any eventual errors, hence the "safety check" when determining the limit

____________________________________

PS: that line works in multi time frame mode. It 'asks" the target time frame how many bars have changed in the target time frame in order to be able to recalculate the exact number of bars in current time frame needed. So that line is effective only when in mtf mode

=========================================================

Thanks very much for the explanation. Much appreciated and also helping me to understand the coding better.

I will download the 2nd one immediately.

Best wishes.

 

adxvma

mladen,

Would I be out of line to ask you to post the Tradestation version??

Ray

mladen:
Guys, I have noticed one illogical thing in the indicator (the first step how adx part is calculated) I did use tradestation indicator as a model and it seems that there is an error in it that I inherited without thinking of it . In these that error is corrected. Even the results are better this way.
This calculation is much closer to the one from the public section (so the one from the public section is a fairly correct indicator) with much faster code in 99% of time and extras that are specific just to these posted in the elite section. So if you downloaded the indicators from previous posts, please use these instead. Also added one more option to the "regular" version : MultiColorMode- if set to false just one color is going to be used to display adxvma (useful if one wants to use a couple of adxvma to check for crosses as signals)

regards

Mladen
 

Ray,

Here it is. The indicator :

inputs:

Price (close),

length (14);

vars:

av (0);

av = ADXVMA(Price, length);

Plot1(av, "Rising");

Plot2(av, "Falling");

Plot3(av, "Neutral");

Plot4(av, "ADXVMA", iff(av = av[1], GetPlotColor(3), iff(av > av[1], GetPlotColor(1), GetPlotColor(2))));

NoPlot(1);

NoPlot(2);

NoPlot(3); [/php]and the adxvma function

[php]inputs:

Price (NumericSeries),

Length (NumericSimple);

vars:

TR(0),

DI_Diff(0),

DI_Sum(0),

ma(0),

pdm(0),

mdm(0),

pdi(0),

mdi(0),

DI_Factor(0),

VI(0),

diff(0),

HHV(0),

LLV(0),

WeightDM(Length),

WeightDI(Length),

WeightDX(Length),

ChandeEMA(Length),

out(0),

j(0);

once ma=Price;

//

// in order to make it right the "pdm=0; mdm=0;" must be added (it does not

// exist in original and that is an error, tradestation inherits values fom

// a previous loop and they must be zeroed before these calculations)

//

pdm=0; mdm=0;

if(Price>Price[1]) then pdm=Price-Price[1] else mdm=Price[1]-Price;

pdm=((WeightDM-1)*pdm[1] + pdm)/WeightDM;

mdm=((WeightDM-1)*mdm[1] + mdm)/WeightDM;

TR=pdm+mdm;

if (TR>0) then begin pdi=pdm/TR; mdi=mdm/TR; end

else begin

pdi=0;

mdi=0;

end;

pdi=((WeightDI-1)*pdi[1] + pdi)/WeightDI;

mdi=((WeightDI-1)*mdi[1] + mdi)/WeightDI;

DI_Diff=pdi-mdi;

if (DI_Diff<0) then DI_Diff= -DI_Diff;

DI_Sum=pdi+mdi;

DI_Factor=0;

if (DI_Sum>0) then out=DI_Diff/DI_Sum else out=0;

out=((WeightDX-1)*out[1] + out)/WeightDX;

if (out>out[1]) then begin HHV=out; LLV=out[1]; end

else begin

HHV=out[1];

LLV=out;

end;

for j = 1 to Length-1 begin

if(out[j+1]>HHV)then HHV=out[j+1];

if(out[j+1]<LLV) then LLV=out[j+1];

end;

diff = HHV - LLV;

VI=0;

if (diff>0) then VI=(out-LLV)/diff;

ma=((ChandeEMA-VI)*ma[1]+VI*Price)/ChandeEMA;

ADXVMA = ma;

Added comment and a code correction that did not exist in the original (that is the only change I made in it). Some of the variable names are misleading : there is no EMA calculation on any of the steps. That is a smoothed moving average used in intermediate smoothing steps, not EMA. Also you will notice that even if the basic logic of calculation is from ADX it actually is not an ADX, but it is close enough to deserve the name in the case of this "hybrid" indicator

regards

Mladen

traderduke:
mladen,

Would I be out of line to ask you to post the Tradestation version??

Ray
Reason: