Miscellaneous
0
Views
0
Downloads
0
Favorites
MonthlyPivot_mids
//+------------------------------------------------------------------+
//| Monthly Pivot |
//| Copyright © 2006, Profitrader |
//| Coded/Verified by Profitrader |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Profitrader."
#property link "profitrader@inbox.ru"
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Navy
#property indicator_color2 White
#property indicator_color3 White
#property indicator_color4 White
#property indicator_color5 White
#property indicator_color6 White
#property indicator_color7 White
//---- buffers
double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];
double S3Buffer[];
double R3Buffer[];
double P,S1,R1,S2,R2,S3,R3,last_month_high,last_month_low,last_month_close,this_month_open;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,PBuffer);
SetIndexBuffer(1,S1Buffer);
SetIndexBuffer(2,R1Buffer);
SetIndexBuffer(3,S2Buffer);
SetIndexBuffer(4,R2Buffer);
SetIndexBuffer(5,S3Buffer);
SetIndexBuffer(6,R3Buffer);
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexStyle(1,DRAW_LINE,2,1);
SetIndexStyle(2,DRAW_LINE,2,1);
SetIndexStyle(3,DRAW_LINE,2,1);
SetIndexStyle(4,DRAW_LINE,2,1);
SetIndexStyle(5,DRAW_LINE,2,1);
SetIndexStyle(6,DRAW_LINE,2,1);
SetIndexLabel(0,"Monthly Pivot Point");
SetIndexLabel(1,"Monthly MidSupport 1");
SetIndexLabel(2,"Monthly MidResistant 1");
SetIndexLabel(3,"Monthly MidSupport 2");
SetIndexLabel(4,"Monthly MidResistant 2");
SetIndexLabel(5,"Monthly MidSupport 3");
SetIndexLabel(6,"Monthly MidResistant 3");
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("Monthly Pivot");
ObjectDelete("Monthly MSup1");
ObjectDelete("Monthly MRes1");
ObjectDelete("Monthly MSup2");
ObjectDelete("Monthly MRes2");
ObjectDelete("Monthly MSup3");
ObjectDelete("Monthly MRes3");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(Period()>PERIOD_D1) return(-1);
if(counted_bars==0)
{
ObjectCreate("Monthly Pivot",OBJ_TEXT,0,0,0);
ObjectSetText("Monthly Pivot"," Monthly Pivot Point",8,"Arial",Navy);
ObjectCreate("Monthly MSup1",OBJ_TEXT,0,0,0);
ObjectSetText("Monthly MSup1"," mmS 1",8,"Arial",White);
ObjectCreate("Monthly MRes1",OBJ_TEXT,0,0,0);
ObjectSetText("Monthly MRes1"," mmR 1",8,"Arial",White);
ObjectCreate("Monthly MSup2",OBJ_TEXT,0,0,0);
ObjectSetText("Monthly MSup2"," mmS 2",8,"Arial",White);
ObjectCreate("Monthly MRes2",OBJ_TEXT,0,0,0);
ObjectSetText("Monthly MRes2"," mmR 2",8,"Arial",White);
ObjectCreate("Monthly MSup3",OBJ_TEXT,0,0,0);
ObjectSetText("Monthly MSup3"," mmS 3",8,"Arial",White);
ObjectCreate("Monthly MRes3",OBJ_TEXT,0,0,0);
ObjectSetText("Monthly MRes3"," mmR 3",8,"Arial",White);
}
for(i=limit-1; i>=0; i--)
{
// 1sts Days of Month
if(TimeDay(Time[i])<=3 && TimeDay(Time[i+1])>=26)
{
last_month_close=Close[i+1];
this_month_open=Open[i];
P=(last_month_high+last_month_low+last_month_close+this_month_open)/4;
R1=(((2*P)-last_month_low)-P)/2 +P;
S1=(((2*P)-last_month_high)-P)/2 +P;
R2=((P+(last_month_high-last_month_low))-((2*P)-last_month_low))/2 + (2*P)-last_month_low;
S2=(((2*P)-last_month_high)-(P-(last_month_high-last_month_low)))/2 + P-(last_month_high-last_month_low);
R3=((2*P)+(last_month_high-(2*last_month_low)) - (P+(last_month_high-last_month_low)))/2 + P+(last_month_high-last_month_low);
S3=((P-(last_month_high-last_month_low))-((2*P)-((2*last_month_high)-last_month_low)))/2 + (2*P)-((2*last_month_high)-last_month_low);
ObjectMove("Monthly Pivot",0,Time[i],P);
ObjectMove("Monthly MSup1",0,Time[i],S1);
ObjectMove("Monthly MRes1",0,Time[i],R1);
ObjectMove("Monthly MSup2",0,Time[i],S2);
ObjectMove("Monthly MRes2",0,Time[i],R2);
ObjectMove("Monthly MSup3",0,Time[i],S3);
ObjectMove("Monthly MRes3",0,Time[i],R3);
last_month_low=Low[i];
last_month_high=High[i];
}
last_month_low=MathMin(last_month_low,Low[i]);
last_month_high=MathMax(last_month_high,High[i]);
PBuffer[i]=P;
S1Buffer[i]=S1;
R1Buffer[i]=R1;
S2Buffer[i]=S2;
R2Buffer[i]=R2;
S3Buffer[i]=S3;
R3Buffer[i]=R3;
}
//----
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
---