Lesson 12 - Your First Indicator (Part3)

 
Files:
lesson12.pdf  392 kb
 

won't show

Hi Guru!

First, thank you so much for all your FREE help!!!

Second, I seem to be having difficulty with the indicator. I cut and pasted the code directly into Meta Trader and it it isn't quite working.

If you don't mind, I've attached a picture of what I'm seeing.

Perhaps you might know why?

Agent2005

Files:
tsd.jpg  172 kb
 

Thanks!

Agent2005:
Hi Guru!

First, thank you so much for all your FREE help!!!

Second, I seem to be having difficulty with the indicator. I cut and pasted the code directly into Meta Trader and it it isn't quite working.

If you don't mind, I've attached a picture of what I'm seeing.

Perhaps you might know why?

Agent2005

agent2005,

Thanks for your kind words!

1- Did you play around the options: Fixed Minimum & Fixed Maximum in the indicator property window?

The image you sent shows Min -900000 & Max 900000

2- Could I see the code you cut-pasted, why don't you download the indicator and compile it instead od cut-paste?

 

I have a questions.

It was difficult for me to understand the logic but seems I got it.

1. int Counted_bars = IndicatorCounted ();

if (counted_bars > 0) counted_bars --;

It means that indicator is counting all the bars which was appeared on the chart.

counted_bars-- is minus 1 every time. So, it should be started from some maximum value.

Why it is counting like -- and not ++ (starting from zero and counted_bars ++?

2. if indicator is not counting the bars starting from zero we have pos = 0 in the beginning. Right?

int pos = Bars - counted_bars;

Because number of counted_bars is subtracted from the total numbers of the bar in the chart. And if counted_bar is started from zero, everything is ok. But counted_bars could not be started from zero because:

int Counted_bars = IndicatorCounted ();

if (counted_bars > 0) counted_bars --;

So, I do not understand something. May you explain?

3. What to write in the code if it is necessary for indicator to count already specified number of bars, 300 for example?

 

I have the same question

newdigital:
I have a questions.

It was difficult for me to understand the logic but seems I got it.

1. int Counted_bars = IndicatorCounted ();

if (counted_bars > 0) counted_bars --;

It means that indicator is counting all the bars which was appeared on the chart.

counted_bars-- is minus 1 every time. So, it should be started from some maximum value.

Why it is counting like -- and not ++ (starting from zero and counted_bars ++?

I have the same question, because counted bars should equal the total number of bars. What if it is 3994 bars? and you subtract 1, then you have 3993 bars, but what you want is the current bar, bar [0], correct? How is decrementing the counted_bars by 1 going to use bar 0??

 

It should be started from zero as I understand. Or from 1.

But according to this suggestion it is not started from zero, it was started from something, or from some max value may be:

if (counted_bars > 0) counted_bars --;

As Codersguru described before "pos" is the number of time for the loop to work.

Because:

int pos = Bars - counted_bars;

It means if counted_bars is equal to the total number of Bars in the charts the loop will be finished. So, counted_bars should be started from some miminum and finished with some maximum.

May be I do not understand something.

 

Bars

newdigital:
It should be started from zero as I understand. Or from 1.

But according to this suggestion it is not started from zero, it was started from something, or from some max value may be:

if (counted_bars > 0) counted_bars --;

As Codersguru described before "pos" is the number of time for the loop to work.

Because:

int pos = Bars - counted_bars;

It means if counted_bars is equal to the total number of Bars in the charts the loop will be finished. So, counted_bars should be started from some miminum and finished with some maximum.

May be I do not understand something.

I've written an appendix about the BARS, I hope it helps .

https://www.mql5.com/en/forum/173124

 

Further Lessons

Coders Guru,

This is a very good course, thank you very much. I never would have figured out all the information you have told us on my own.

Aside from checking back here every few days, how can I know when the next lesson is posted? Also, do you know how many lessons you intend to create?

Thanks,

Barry

 

Codesgure,

firstly I'd like to congratulate you for a job well done.

Since you are asking for feeback, I'd like to raise one. on your lesson 12, you defined the following:

double Volume[]

This function returns a double type value holds the average of the total amount of currency traded within a period of time, usually one day.

For example: Volume [0] will return this average for the current bar.

I'm not too sure if this is correct. Volume[0] normally means the first tick of the new bar. It's basically the first quote (or tick) at the beginning of new bar. For example, on an hourly chart, it's the first tick for the new hour.

I also thought initially that Volume is the quantity traded for the day (if it's a day chart); but it's nothing to do with that.

Cheers!

 
TheExponential:
Codesgure,

I'm not too sure if this is correct. Volume[0] normally means the first tick of the new bar. It's basically the first quote (or tick) at the beginning of new bar. For example, on an hourly chart, it's the first tick for the new hour.

TheExponential,

Try this code (in any time frame) and tell me what did you get:

int start()

{

Alert("Current market volume = " + DoubleToStr(Volume[0],0));

return(0);

}

Attached what I've got.

Files:
volume.jpg  30 kb
 

Thanks

codersguru,

thanks so much for all your work and sharing of your knowledge. I've read all the lessons you have created so far and they are very informative. Keep up the great work!

WRR

Reason: