Miscellaneous
0
Views
0
Downloads
0
Favorites
Floor_Pivots_Weekly
//+------------------------------------------------------------------+
//| Floor_Pivots_Weekly.mq4 |
//| Copyright © 2009, kris.pivo[at]gmail.com |
//+------------------------------------------------------------------+
#property copyright "© Kris, 2009" //|
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 C'000,100,000' // SeaGreen
#property indicator_color2 C'000,150,000' // Green
#property indicator_color3 C'000,200,000' // Lime
#property indicator_color4 C'150,150,150' // Silver
#property indicator_color5 C'200,000,000' // Red
#property indicator_color6 C'150,000,000' // Crimson
#property indicator_color7 C'100,000,000' // Maroon
//---- input parameters
int fontsize=8;
//---- buffers
double BufferR3[];
double BufferR2[];
double BufferR1[];
double BufferPP[];
double BufferS1[];
double BufferS2[];
double BufferS3[];
double WH,WL,WC,PP,PD,PRH,PRL;
double S1,R1,S2,R2,S3,R3;
double last_week_high, last_week_low, last_week_close, this_week_open;
//+------------------------------------------------------------------+
int deinit() {
ObjectDelete("PivR3");
ObjectDelete("PivR2");
ObjectDelete("PivR1");
ObjectDelete("PivPP");
ObjectDelete("PivS1");
ObjectDelete("PivS2");
ObjectDelete("PivS3");
ObjectDelete("LabPivR3");
ObjectDelete("LabPivR2");
ObjectDelete("LabPivR1");
ObjectDelete("LabPivPP");
ObjectDelete("LabPivS1");
ObjectDelete("LabPivS2");
ObjectDelete("LabPivS3");
Comment("");
return(0); }
//+------------------------------------------------------------------+
int init()
{
string short_name;
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,160);
SetIndexBuffer(0,BufferR3);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,160);
SetIndexBuffer(1,BufferR2);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,160);
SetIndexBuffer(2,BufferR1);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,167);
SetIndexBuffer(3,BufferPP);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,160);
SetIndexBuffer(4,BufferS1);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,160);
SetIndexBuffer(5,BufferS2);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,160);
SetIndexBuffer(6,BufferS3);
short_name="Floor Pivots Weekly";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexDrawBegin(0,1);
return(0); }
int start()
{
int counted_bars=IndicatorCounted();
int limit, i;
if (counted_bars==0)
{
ObjectCreate("PivR3", OBJ_TEXT, 0,0,0);
ObjectSetText("PivR3", " Weekly R3",fontsize,"Arial",indicator_color1);
ObjectCreate("PivR2", OBJ_TEXT, 0,0,0);
ObjectSetText("PivR2", " Weekly R2",fontsize,"Arial",indicator_color2);
ObjectCreate("PivR1", OBJ_TEXT, 0,0,0);
ObjectSetText("PivR1", " Weekly R1",fontsize,"Arial",indicator_color3);
ObjectCreate("PivPP", OBJ_TEXT, 0,0,0);
ObjectSetText("PivPP", " Weekly Pivot Point",fontsize,"Arial",indicator_color4);
ObjectCreate("PivS1", OBJ_TEXT, 0,0,0);
ObjectSetText("PivS1", " Weekly S1",fontsize,"Arial",indicator_color5);
ObjectCreate("PivS2", OBJ_TEXT, 0,0,0);
ObjectSetText("PivS2", " Weekly S2",fontsize,"Arial",indicator_color6);
ObjectCreate("PivS3", OBJ_TEXT, 0,0,0);
ObjectSetText("PivS3", " Weekly S3",fontsize,"Arial",indicator_color7);
}
if(counted_bars<0) return(-1);
//----
limit=(Bars-counted_bars)-1;
//----
for(i=limit; i>=0;i--)
{
// Monday
if(1==TimeDayOfWeek(Time[i]) && 1!=TimeDayOfWeek(Time[i+1]) ) // 0=Sunday, 1=Monday, ...
{
last_week_close=Close[i+1];
this_week_open=Open[i];
WH = last_week_high;
WL = last_week_low;
WC = last_week_close;
PP = (WH + WL + WC)/3;
PD = MathAbs(((WH + WL)/2) - PP);
PRH = PP + PD;
PRL = PP - PD;
R1 = (2*PP)- WL;
S1 = (2*PP)- WH;
R2 = PP+(R1-S1);
S2 = PP-(R1-S1);
R3 = (WH + (2*(PP-WL)));
S3 = (WL - (2*(WH-PP)));
last_week_low = Low[i];
last_week_high = High[i];
//----
ObjectMove("PivR3", 0, Time[i],R3);
ObjectMove("PivR2", 0, Time[i],R2);
ObjectMove("PivR1", 0, Time[i],R1);
ObjectMove("PivPP", 0, Time[i],PP);
ObjectMove("PivS1", 0, Time[i],S1);
ObjectMove("PivS2", 0, Time[i],S2);
ObjectMove("PivS3", 0, Time[i],S3);
}
last_week_high=MathMax(last_week_high, High[i]);
last_week_low=MathMin(last_week_low, Low[i]);
BufferR3[i]=R3;
BufferR2[i]=R2;
BufferR1[i]=R1;
BufferPP[i]=PP;
BufferS1[i]=S1;
BufferS2[i]=S2;
BufferS3[i]=S3;
DoLabel( "LabPivR3", BufferR3[0], indicator_color1 );
DoLabel( "LabPivR2", BufferR2[0], indicator_color2 );
DoLabel( "LabPivR1", BufferR1[0], indicator_color3 );
DoLabel( "LabPivPP", BufferPP[0], indicator_color4 );
DoLabel( "LabPivS1", BufferS1[0], indicator_color5 );
DoLabel( "LabPivS2", BufferS2[0], indicator_color6 );
DoLabel( "LabPivS3", BufferS3[0], indicator_color7 );
}
return(0); }
void DoLabel( string dName, double dValue, color dColor )
{
if (ObjectFind(dName) != 0)
{
ObjectCreate(dName,OBJ_ARROW,0,Time[0],dValue);
ObjectSet(dName,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(dName,OBJPROP_COLOR,dColor);
}
else
{
ObjectMove(dName,0,Time[0],dValue);
}
}
//+-----------------------------------------------------------------------------------------+
//| THE END |
//+-----------------------------------------------------------------------------------------+
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
---