foreigner said:
que another one bites the dust?
LOL.... maybe... it's
your reject pile
foreigner said:
Thanks AusDoc all working fine except pivots themselves are in the wrong place... ???
All working fine... except! ... that's a big exception.
In the wrong place hey? That's interesting. There is no wrong place for pivots actually, but that's a whole tutorial. Anyway, how about you explain where you think the right place is and show the difference so I'll have an idea of what you think the problem is. Then I may be able to put the pivots where you would like them to be or perhaps explain why they are perfectly fine where they are.
There are various ways of calculating or simply reading historical data such as a prior period's open or close
etcetera, even ignoring the thorny issue of which timezone to use as a reference point. If the differences you are talking about are just a pip or two (or thereabouts) then I would have an idea of the issue. Assuming identical data sources, that would be a read versus calculated prior period I expect. In that case, neither one is really more correct or incorrect, they are just slightly different. If you think that makes a scrap of difference to trading then you need to work on how to use tools for trading (no offense foreigner, most people don't really use tools very well, certainly not automated horizontal line tools).
Of course you should know that there are a few different ways of calculating floor trader pivots, which is what these are (most people just call then Pivots, knowing little about their origins, uses or varied calculation methods).
These are standard floor trader pivots. The levels are calculated as follows:
First we access the daily data that MT4 is reading, as supplied by the broker.
ArrayCopyRates(D_rates_d1,Symbol(),1440);
From this array we can extract the prior day's high, low, open and close and bind them to variables we can use in the following formulae to calculate the levels.
// Central Pivot Level
D_P = (D_yesterday_high + D_yesterday_low + D_yesterday_close) / 3;
// Main Support & Resistance Levels
D_R3 = (2*D_P) + (D_yesterday_high - (2*D_yesterday_low));
D_R2 = D_P + (D_yesterday_high - D_yesterday_low);
D_R1 = (2*D_P) - D_yesterday_low;
D_S1 = (2*D_P) - D_yesterday_high;
D_S2 = D_P - (D_yesterday_high - D_yesterday_low);
D_S3 = (2*D_P) - ((2*D_yesterday_high) - D_yesterday_low);
// Mid Support & Resistance Levels
D_MR3 = (D_R2 + D_R3) / 2;
D_MR2 = (D_R1 + D_R2) / 2;
D_MR1 = (D_P + D_R1) / 2;
D_MS1 = (D_P + D_S1) / 2;
D_MS2 = (D_S1 + D_S2) / 2;
D_MS3 = (D_S2 + D_S3) / 2;
This is repeated for weekly and monthly periods. All very straight forward. All correct formulae. All correctly coded. ...but, of course, somehow in the wrong place.
An alternative central pivot calculation method adds the prior open and then divides by 4. Naturally this changes every pivot level. Another variation uses Fibonacci numbers. Different strokes for different folks. It doesn't really matter much though, because as I said, most people don't really know how to use them.
Anyway, please let me know what the wrong place means and I'll see what I can do for you.