One more average ... - page 26

 
plodds:
Re: Indicator Modification

i was wondering if sir mladen or any kind hearted person here could code divergence and divergence alerts into this timing indicator...

secondly, i have problems loading trendstrenght oma indicator into my chart as it has simply refused to show up each time i load it. thanks guys

Isn't "MBFX timing simply an rsx?

 
techmac:
Isn't "MBFX timing simply an rsx?

Yes it is :

Files:
mbfx.png  124 kb
 
mladen:

Yes it is :

Yep. Same old story ...

 
mladen:

Yes it is :

colors are slightly different...light green - dark green etc...

 
mladen:
I hare when we do not have an option to chose price, se here is this one with the usual set of 20 prices as a possible choices added )it does not use a fixed close price any more) : fatl_one_more_average_slope_speed_alerts_mtf_2.mq4

Hi,

I have had problems with several indicators that have a similar general structure as this indicator, and there are 2 sections that cause them to crash in my environment, but for some reason they work in yours?

These 2 problems are in the following sections of code:

1) In the main routine for the current timeframe (i.e. TimeFrame parameter = 0) :

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

if (returnBars) { diffhuu[0] = limit; return(0); }

if (TimeFrame==Period())

{

for (int i=limit; i>=0; i--)

{

prices = getPrice(Price,Open,Close,High,Low,i);

double fatl = +0.4360409450*prices +0.3658689069*prices +0.2460452079*prices ... <=== right here, i+2, when limit=Bars-1 will be outside the price[] array bounds and crashes.

To fix these I would have to go through the indicators and figure out the max range outside of the array the routine goes and adjust the limit (or similar), e.g. limit=MathMin(Bars-counted_bars, Bars-38-1) for this indicator, or often correct by the moving average or sum of moving averages in other indicators. And then so that it displays properly at start of timeseries, also then need to add some additional code (e.g. SetIndexDrawBegin or similar). This same issue would also have to be adjusted in the multi-timeframe handling if "limit" or similar array bound was used.

2) and in the multi-timeframe handling (i.e. TimeFrame parameter = HTF than the current one)

for (i=limit;i>=0; i--)

{

......

if (!Interpolate || y==iBarShift(NULL,TimeFrame,Time)) continue; <=== right here, i-1 when i=0 will be outside the Time[] array and crashes.

Not sure why they don't crash on you too?

Is there something I should be doing to get these indicators to work properly?

Thanks for your help !

 
profitabl:

Hi,

I have had problems with several indicators that have a similar general structure as this indicator, and there are 2 sections that cause them to crash in my environment, but for some reason they work in yours?

These 2 problems are in the following sections of code:

1) In the main routine for the current timeframe (i.e. TimeFrame parameter = 0) :

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

if (returnBars) { diffhuu[0] = limit; return(0); }

if (TimeFrame==Period())

{

for (int i=limit; i>=0; i--)

{

prices = getPrice(Price,Open,Close,High,Low,i);

double fatl = +0.4360409450*prices +0.3658689069*prices +0.2460452079*prices ... <=== right here, i+2, when limit=Bars-1 will be outside the price[] array bounds and crashes.

To fix these I would have to go through the indicators and figure out the max range outside of the array the routine goes and adjust the limit (or similar), e.g. limit=MathMin(Bars-counted_bars, Bars-38-1) for this indicator, or often correct by the moving average or sum of moving averages in other indicators. And then so that it displays properly at start of timeseries, also then need to add some additional code (e.g. SetIndexDrawBegin or similar). This same issue would also have to be adjusted in the multi-timeframe handling if "limit" or similar array bound was used.

2) and in the multi-timeframe handling (i.e. TimeFrame parameter = HTF than the current one)

for (i=limit;i>=0; i--)

{

......

if (!Interpolate || y==iBarShift(NULL,TimeFrame,Time)) continue; <=== right here, i-1 when i=0 will be outside the Time[] array and crashes.

Not sure why they don't crash on you too?

Is there something I should be doing to get these indicators to work properly?

Thanks for your help !

profitabl

That happens when you add strict to that code(when you try to change that existing code)

When you use strict some additional array handling code must be added. Use them as is (without the strict addition or use the code that is already adjusted for a strict mode) and then there will be no problem at all

 

Replaced the Tema in the Sentiment zone oscillator(szo) with the one more average, if you leave ColorsOnSlope = false then you will have the szo to be colored on szo/avg signal cross.

sentiment_zone_oscillator_oma_nrp.mq4

 
mladen:

profitabl

That happens when you add strict to that code(when you try to change that existing code)

When you use strict some additional array handling code must be added. Use them as is (without the strict addition or use the code that is already adjusted for a strict mode) and then there will be no problem at all

Hi mladen,

I have not added strict (or at least not intentionally).

All I am trying to do is to compile the .mq4 indicators so I can try them out and use them if they look promising.

So with the strict turned off, the compiler I'm using (MetaEditor version 5.0 build 1198 Oct 23 2015), it would stop (crash) when executing these out of bound conditions (as it should).

The code clippets that I provided above were just to show where this indicator had array problems (since the debugger breakpoint facility in my compiler is quite limited, I thought providing these might save updater considerable time). I also noticed other array issues but didn't mention those as they weren't as serious.

What I still don't understand is why others are not also having crashes as many of these indicators seems to be using invalid data outside of array bounds.

Maybe using the old compiler? or older versions? or somehow can adjust the compiler parameters?

And on use of strict, when I added strict into this indicator (fatl one more average slope speed alerts mtf 2) several undeclared identifiers were also flagged as errors (i, n, whichBar), which I presume the (old) compiler can make assumptions about to resolve (and possibly incorrectly).

If you would like, I can post attempts at correcting these issues, but it would help to know what the file naming conventions and the revision comment conventions are at this site so as to make it easier to determine which version is the latest and what changes have been made.

Thanks.

 
profitabl:

Hi mladen,

I have not added strict (or at least not intentionally).

All I am trying to do is to compile the .mq4 indicators so I can try them out and use them if they look promising.

So with the strict turned off, the compiler I'm using (MetaEditor version 5.0 build 1198 Oct 23 2015), it would stop (crash) when executing these out of bound conditions (as it should).

The code clippets that I provided above were just to show where this indicator had array problems (since the debugger breakpoint facility in my compiler is quite limited, I thought providing these might save updater considerable time). I also noticed other array issues but didn't mention those as they weren't as serious.

What I still don't understand is why others are not also having crashes as many of these indicators seems to be using invalid data outside of array bounds.

Maybe using the old compiler? or older versions? or somehow can adjust the compiler parameters?

And on use of strict, when I added strict into this indicator (fatl one more average slope speed alerts mtf 2) several undeclared identifiers were also flagged as errors (i, n, whichBar), which I presume the (old) compiler can make assumptions about to resolve (and possibly incorrectly).

If you would like, I can post attempts at correcting these issues, but it would help to know what the file naming conventions and the revision comment conventions are at this site so as to make it easier to determine which version is the latest and what changes have been made.

Thanks.

profitabl

To clarify

The code snippets that you posted are working correctly if no strict mode is used (indirectly strict mode is invoked when you try to debug a code). That is due to the security mechanism that metatrader 4 has when no strict mode is used (the additional controls are added to provide array access errors and so on and so on - that has been like that for years and years and all the previous metatrader 4 builds were working like that)

The addition of strict mode on new metatrader builds brings the MQL closer to C/C++ but not just in syntax, but in security mechanism too. C/C++ does not have any "automatic" security mechanism at all. That is entirely left to the coder to code it on its own, and if exceptions are not properly handled in the code in strict mode, then errors happen simply because of the lack of those necessary controls (that were not added by metatrader compiler)

_________________________

So, to conclude. As far as MQL is concerned that code is perfectly OK as long as strict mode is not invoked. A soon as it is invoked (directly, by using #property strict statement, or indirectly, by running a debugger for example) the rules for the code must be used that are used for normal C/C++ coding techniques.

 
profitabl:

Hi mladen,

I have not added strict (or at least not intentionally).

All I am trying to do is to compile the .mq4 indicators so I can try them out and use them if they look promising.

So with the strict turned off, the compiler I'm using (MetaEditor version 5.0 build 1198 Oct 23 2015), it would stop (crash) when executing these out of bound conditions (as it should).

The code clippets that I provided above were just to show where this indicator had array problems (since the debugger breakpoint facility in my compiler is quite limited, I thought providing these might save updater considerable time). I also noticed other array issues but didn't mention those as they weren't as serious.

What I still don't understand is why others are not also having crashes as many of these indicators seems to be using invalid data outside of array bounds.

Maybe using the old compiler? or older versions? or somehow can adjust the compiler parameters?

And on use of strict, when I added strict into this indicator (fatl one more average slope speed alerts mtf 2) several undeclared identifiers were also flagged as errors (i, n, whichBar), which I presume the (old) compiler can make assumptions about to resolve (and possibly incorrectly).

If you would like, I can post attempts at correcting these issues, but it would help to know what the file naming conventions and the revision comment conventions are at this site so as to make it easier to determine which version is the latest and what changes have been made.

Thanks.

profitabl

Just a PS: as far as I am aware of you are the unique user that has issues with those indicators. They are out there for years and so far nobody was complaining that they do not work or that they are having some execution errors - as long as the code was left intact. So, for the sake of simplicity, let us not change what works perfectly well for all these years. No need to fix what does not need to be fixed. If you feel that you can improve something, you are always welcome to do that. But, as I told already : those code parts need no change at all as long as strict mode is not used, so no need to change anything in those particular cases

When we use and post a code in a strict mode, then those parts are changed accordingly (as you can see from such cases) but just to make some changes that will not influence the work of the code at all in the result is hardly what people that are going to use that will feel as an improvement

all the best

Reason: