A Better Way To Code - TheRumpledOne - page 2

 

I adjust some little things, not so important

let your MACD Sample run in your tester, pauze the visual mode, and put your indicator on the testing chart, let it run again...

TheRumpledOne:
WHAT'S WRONG WITH THIS PICTURE?

What don't I understand?

What did I do wrong or not do right?

Limit is always 68922.

So the for loop is running 68923 times each and every time?

Or is it because the market is closed this isn't working "right"?

Please shed some light on this.

Thanks.

NOTE: I am NOT trying to prove anyone wrong. I am trying to learn and understand.
Files:
 

Well it's true! IndicatorCounted() doesn't work like that, therefor it is a tool not a solution... but still you have to use it, it is necessary! It limits and shorten your loops. If you need previous bars other easier options are available. This article could be written much easier to understand, even the coding could be more simplified, the article is almost 2 years old, probably an over enthusiastic professional coder wanted to make a point

Big Be:
Some indicators make coding a lot more difficult. They operate on the last value (previous bar) to create the new value. Then IndicatorCounted() does not work!

This article tells you how to fix that. When I first read it, I thought, "I will have to read this six times before I can use it successfully." Fortunately I was wrong - it only took me four times. Plus some "trial and error."

The results: It sped up the backtesting by about 100 times, as it no longer recalculated every bar for the complicated indicator, for every tick. This obviously will speed up live execution the same.

Enjoy!

Multiple Null Bar Re-Count in Some Indicators - MQL4 Articles

Big Be
 
IN10TION:
Well it's true! IndicatorCounted() doesn't work like that, therefor it is a tool not a solution... but still you have to use it, it is necessary! It limits and shorten your loops. If you need previous bars other easier options are available. This article could be written much easier to understand, even the coding could be more simplified, the article is almost 2 years old, probably an over enthusiastic professional coder wanted to make a point

Thanks again, IN10TION.

One small favor, whenever you update someone else's code, please change the name in some way so the ORIGINAL code doesn't get stepped on. Just one of those coding conventions/standards.

To make my life easier, I have a version of the indicator, called IND000. That is the PRODUCTION VERSION and is used by the template.

The ORIGINAL indicator would be named IND.

The next version would be IND001. After I get IND001 debugged and tested, I then copy it into IND000 and compile it. I don't have to change the template.

If I ever need to go back to an earlier version, I just copy that version into IND000 and compile it.

This keeps things running smoothly.

Thanks again for adding to the discussion.

 

IN10TION:

Question: What is the reason you used

SetLevelValue(0,1);

SetLevelValue(1,2);

SetLevelValue(2,3);

instead of

#property indicator_level1 1.0

#property indicator_level2 2.0

#property indicator_level3 3.0

??

Just curious.

 

When IndicatorCounted() Will Not Work, comment

IN10TION:
If you need previous bars other easier options are available. This article could be written much easier to understand, even the coding could be more simplified, the article is almost 2 years old, probably an over enthusiastic professional coder wanted to make a point

Yes. It could be much better, but it would have to be written by one who really understands that subject, and can communicate clearly.

Any volunteers?

Big Be

 

Looks like we will figure this out together

 

please show a code of the issue you dealing with... it will make it simpler to illustrate... otherwise don't trouble yourself with something that is seldom needed.

Did you try with the tester? ( _TRO_Limit_test.mq4 )

no reason between those, only setlevelvalue can overpower a property indicator_level.

SetLevelValue(2,3);

or #property indicator_level1 1.0

 
IN10TION:
please show a code of the issue you dealing with... it will make it simpler to illustrate... otherwise don't trouble yourself with something that is seldom needed.

Did you try with the tester? ( _TRO_Limit_test.mq4 )

no reason between those, only setlevelvalue can overpower a property indicator_level.

SetLevelValue(2,3);

or #property indicator_level1 1.0

Didn't run tester.. waiting for market to open and run live.

Thanks again.

 

RESULTS ARE IN:

Files:
limit_test.gif  17 kb
 

Now that the results are in, it begs the question... HOW and WHEN DOES MT4 MOVE THE DATA IN THE BUFFERS?

Does anyone know the MT4 internals or where to read about them?