Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
Welcome to the third part of “Your First Indicator” lesson.
In the previous lesson we studied the code of our first indicator line by line and we reached the function dinit().
I hope you’ve came from the previous lessons with a clear idea about what we have done.
Today we are going to study start() function and its content. And –finally- we will compile and run our first Indicator.
Are you ready? Let’s hack the code line by line:
Why don't you download the lesson and enjoy? (I hope)
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 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.
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 . Appendix 1 - BARS
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
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.
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: