Miscellaneous
0
Views
0
Downloads
0
Favorites
Pivot (Midnight to Midnight)_M
//+------------------------------------------------------------------+
//| Pivot (Midnight to Midnight)_M .mq4 |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Pivot.mq4 |
//| Copyright © 2004, Poul_Trade_Forum |
//| Aborigen |
//| http://forex.kbpauk.ru/ |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link "http://forex.kbpauk.ru/"
#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Gray
#property indicator_color2 Gray
#property indicator_color3 Gray
#property indicator_color4 Gray
#property indicator_color5 Gray
#property indicator_color6 Gray
//---- input parameters
//---- buffers
double M0Buffer[];
double M1Buffer[];
double M2Buffer[];
double M3Buffer[];
double M4Buffer[];
double M5Buffer[];
string m0="M 0", m1="M 1";
string m2="M 2", m3="M 3", m4="M 4", m5="M 5";
int fontsize=10;
double M0,M1,M2,M3,M4,M5;
double P,S1,R1,S2,R2,S3,R3;
double LastHigh,LastLow,x;
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
ObjectDelete("m0");
ObjectDelete("m1");
ObjectDelete("m2");
ObjectDelete("m3");
ObjectDelete("m4");
ObjectDelete("m5");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(7);
//---- indicator line
SetIndexStyle(0,DRAW_LINE,0,0,Gray);
SetIndexStyle(1,DRAW_LINE,0,0,Gray);
SetIndexStyle(2,DRAW_LINE,0,0,Gray);
SetIndexStyle(3,DRAW_LINE,0,0,Gray);
SetIndexStyle(4,DRAW_LINE,0,0,Gray);
SetIndexStyle(5,DRAW_LINE,0,0,Gray);
SetIndexBuffer(0,M0Buffer);
SetIndexBuffer(1,M1Buffer);
SetIndexBuffer(2,M2Buffer);
SetIndexBuffer(3,M3Buffer);
SetIndexBuffer(4,M4Buffer);
SetIndexBuffer(5,M5Buffer);
//---- name for DataWindow and indicator subwindow label
short_name="Pivot Point M";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,1);
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit, i;
//---- indicator calculation
if (counted_bars==0)
{
x=Period();
if (x>240) return(-1);
ObjectCreate("m0", OBJ_TEXT, 0, 0, 0);
ObjectSetText("m0", " M 1",fontsize,"Arial",White);
ObjectCreate("m1", OBJ_TEXT, 0, 0, 0);
ObjectSetText("m1", " M 2",fontsize,"Arial",White);
ObjectCreate("m2", OBJ_TEXT, 0, 0, 0);
ObjectSetText("m2", " M 3",fontsize,"Arial",White);
ObjectCreate("m3", OBJ_TEXT, 0, 0, 0);
ObjectSetText("m3", " M 4",fontsize,"Arial",White);
ObjectCreate("m4", OBJ_TEXT, 0, 0, 0);
ObjectSetText("m4", " M 5",fontsize,"Arial",White);
ObjectCreate("m5", OBJ_TEXT, 0, 0, 0);
ObjectSetText("m5", " M 6",fontsize,"Arial",White);
}
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
// if(counted_bars>0) counted_bars--;
limit=(Bars-counted_bars)-1;
for (i=limit; i>=0;i--)
{
if (High[i+1]>LastHigh) LastHigh=High[i+1];
if (Low[i+1]<LastLow) LastLow=Low[i+1];
if (TimeDay(Time[i])!=TimeDay(Time[i+1]))
{
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);
M0 = (S2 + S3)/2;
M1 = (S1 + S2)/2;
M2 = (P + S1)/2;
M3 = (P + R1)/2;
M4 = (R1 + R2)/2;
M5 = (R2 + R3)/2;
LastLow=Open[i]; LastHigh=Open[i];
ObjectMove("m0", 0, Time[i],M0);
ObjectMove("m1", 0, Time[i],M1);
ObjectMove("m2", 0, Time[i],M2);
ObjectMove("m3", 0, Time[i],M3);
ObjectMove("m4", 0, Time[i],M4);
ObjectMove("m5", 0, Time[i],M5);
}
M0Buffer[i]=M0;
M1Buffer[i]=M1;
M2Buffer[i]=M2;
M3Buffer[i]=M3;
M4Buffer[i]=M4;
M5Buffer[i]=M5;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---