Pivot - All Levels

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
Finally found a Pivots MT4 indicator that I liked the look of here https://forum.mql4.com/10128/page2

Wasn't able to edit line style in MetaEditor so I copied #property indicator_width1 1 and changed to #property indicator_style1 2 then added - it worked so i did that 7 times :)

The Support and Resistance lines looked too far apart so i searched for the formula being used

P = (LastHigh + LastLow + Close[i+1]) / 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);


H'mmm . . . I wonder who came up with that ?

So I changed to what I consider to be the recognised set-up as shown above

P = (LastHigh + LastLow + Close[i+1]) / 3;
R1 = (2*P) - LastLow;
S1 = (2*P) - LastHigh;
R2 = (P - Sup1) + Res1;
S2 = P - (Res1 - Sup1);
R3 = (P - Sup2) + Res2;
S3 = P - (Res2 - Sup2);


WARNINGS :( . . . so I changed to this

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


Rather pleased with myself :)

At the moment the line names are at the start of the day (who's bright idea was that ?) Trying to figure out how to get them at the current chart position

It's something to do with this

x = Period();
if(x > 240)
return(-1);
ObjectCreate . . . .

if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
// if(counted_bars>0) counted_bars--;
limit = (Bars - counted_bars) - 1;

H'mmm . . . Out of my depth . . . is there a coder in the forum ?
.
 

Attachments

  • pivots_original.mq4
    5.5 KB · Views: 41

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
I would have thought a HIGH was a HIGH as is a LOW is a LOW and a CLOSE was a CLOSE

So why is no two feeds are the same and none seem to agree with mine :(
 

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
What exactly do you mean by saying "current chart position"? Always at the right border of the screen?
Present time - always in view during the course of the day - So you can immediately see which line is in view.

Suppose it could be upto 10 bars back from price so as not to get in the way
.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,534
1,355
144
Odesa
www.earnforex.com
Present time - always in view during the course of the day - So you can immediately see which line is in view.

Suppose it could be upto 10 bars back from price so as not to get in the way
.

Changing
Code:
Time[i]
to
Code:
Time[0]
here should help:
MQL4:
           ObjectMove("Pivot", 0, Time[i], P);
           ObjectMove("Sup1", 0, Time[i], S1);
           ObjectMove("Res1", 0, Time[i], R1);
           ObjectMove("Sup2", 0, Time[i], S2);
           ObjectMove("Res2", 0, Time[i], R2);
           ObjectMove("Sup3", 0, Time[i], S3);
           ObjectMove("Res3", 0, Time[i], R3);
 
Last edited:

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
Excellent got my labels just where I wanted them after messing about with the spacing . . . Just to the right of price in the void . . . abbreviated Pivot Point to P P
MQL4:
ObjectSetText("Pivot", "          P P", fontsize, "Arial", Aqua);

So just supposing I wanted to move them to the left by 10 bars what would I change ?

What I can't understand is if my algebra is the recognised equation WHY are other peoples results different to mine ?

They work for me so I suppose why should I care . . . curiosity.
.
 

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
So would I be right in thinking that instead of leaving spaces in the code as I have done it could be
MQL4:
Time[-1]
to move to the right ?
Realise I could just try my idea to find out without fear of breaking it BUT it's easier to put my hand up and ask PLUS i might get some reasoning.

Whilst I have my hand up . . . How do you add grey information text in the code - do you just write it ?
.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,534
1,355
144
Odesa
www.earnforex.com
No, Time[-1] will not work. You could try something like:
MQL4:
Time[0] + PeriodSeconds() * 1

Whilst I have my hand up . . . How do you add grey information text in the code - do you just write it ?

Code comments? Just use "//" for one-line commentary or "/* */" for multi-line commentary.
 

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
Think I will stick with leaving spaces in the code - seems to be the norm
Code comments? Just use "//" for one-line commentary or "/* */" for multi-line commentary.
Thank you I will look out for real life examples to get a feel for it
.
 

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
Am I right in thinking that it would be a script if I wanted to create a rule.

When price crosses 8 EMA close position

It's an unwritten rule at the moment but I try to abide by it - needs too much screen time though - ever watching

Where would I start ?

The size and type of the MA would be variables
.
 

Maverick

Master Trader
Apr 3, 2014
453
6
79
Bournemouth UK
That would be an Expert Advisor.
I'm guessing that there could be problems with lots of little EA's running around and that has got me thinking BIGGER for a Rule Book EA - everything under one roof adding rules as and when.

"Someone put the kettle on - Let have a cup of tea whilst I think about this" :)
.