# Source code library - Expert Advisors, Indicators and Scripts

Subscribe to signal
SteveAAAfx2
41.12%, 14 100.62 USD
Try product
CreateGridOrders
Author: Konstantin83
Screenshot
EURJPY, M5
Demo
Expert Advisor
Exp_Arrows_Curves
Author: GODZILLA
To post a new code, please log in or register

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2012.04.24 12:38

## Pivot Point [ru]

Downloads:
2830
Views:
4344
Rating:
votes: 14
Files:
\MQL5\Indicators\
pivotpoint.mq5 (6.17 KB)view

### Description:

Classic Pivot Point indicator paints pivot point and three resistance and support levels for all data points.

Calculation period: Day, Week, Month.

### Image:

Last comments | Go to discussion (1)

Lucero | 7 Jan 2013 at 22:21

Hi niuniu, thanks for your contribution, it comes in handy considering MT5 laks of this indicator.

I was double checking the math routine on your script to make sure it would correspond to how I would calculate pivot points based on different sources (e.g. Wikipedia, BabyPips, etc), and it seems we have a difference on how you calculate the third support (S3).  You have this:

`S3 = (2*P)-((2* LastHigh)-LastLow);`

I would instead have done it this way:

`S3 = (2*P)-((2* LastHigh)+LastLow);`

Notice the positive sign for the LastLow variable.

In fact, if MQL5 does proper order of operations --which I believe it does--, you could safely simplify your routine by getting rid of most of the parenthesis, from this:

```         P=(LastHigh+LastLow+close[i])/3;
R1 = (2*P)-LastLow;
S1 = (2*P)-LastHigh;
R2 = P+(LastHigh - LastLow);
S2 = P-(LastHigh - LastLow);
R3 = (2*P)+(LastHigh-(2*LastLow));
S3 = (2*P)-((2* LastHigh)+LastLow);```

To this:

```         P=(LastHigh+LastLow+close[i])/3;
R1 = 2*P - LastLow;
S1 = 2*P - LastHigh;
R2 = P + LastHigh - LastLow;
S2 = P - LastHigh - LastLow;
R3 = 2*P + LastHigh - 2*LastLow;
S3 = 2*P - 2*LastHigh + LastLow;```

Please double check the S3 calculation to check if you got ir right, and thanks again for the script!