Navigation´╝ÜHome > Content >

pVS.mq4

Time: 2010-09-28 | Download file:pVS.mq4

//+------------------------------------------------------------------+
//|                                                pVS.mq4 |
//|                                                                  |
//|This indicator provides visual signals for multiple timeframes    |
//|the given Symbol. M5, M15, M30, H1, and D1.                       |
//|                                                                  |
//|PSAR:  When PSAR is above the price, Color.When.Above is          |
//|displayed.  When below the current price, Color.When.Below is     |
//|displayed.                                                        |
//|                                                                  |
//|T3: Moving average of Moving Averages. Same color scheme as PSAR. |
//|MAs use EMA.                                                      |
//|                                                                  |
//|Vol (Volatility): Measure of volatility using ATR.  When in       |
//|high volatility, Color.When.Above displayed.  When volatility     |
//|is dropping from high volatility, PaleGreen is displayed.  When   |
//|in very weak volatility, Color.When.Below is displayed.  When     |
//|volatility is improving from weak, LightCoral is displayed.  In   |
//|times of average volatility, Color.When.Neutral is displayed.     |
//|                                                                  |
//|ADX: Same color scheme except Color.When.Neutral when ADX is      |
//|between a strong and a weak trend.                                |
//+------------------------------------------------------------------+

#property indicator_chart_window
extern   string   Pick.Chart.Location = "---True=Right Corner, False=Left---";
extern   bool     Place.Chart.In.Upper.Right=true;
extern   string   Select.Colors = "---Pick Colors For Indicator---";
extern   color    Color.When.Above=DarkGreen;
extern   color    Color.When.Below=Red;
extern   color    Color.When.Neutral=DarkGray;
//extern   string   Momentum.Parameters="----------------------------";
//extern   int      Momentum.Period=10;
extern   string   T3.Parameters="----------------------------";
extern   int      T3.Periods=10;
extern   double   T3.Volume.Factor=0.7;
extern   string   Volatility.Parameters="----------------------------";
extern   int      Volatility.Periods=10;
//extern   string   ADX.Parameters="----------------------------";
//extern   int      ADX.Periods=14;
//extern   int      ADX.Strong.Trend=40;
//extern   int      ADX.Weak.Trend=20;
int               numRows=5;
//bool              RunOnce=false;
int               Corner.Of.Chart.Right.Top=1;
//+------------------------------------------------------------------+
int init()
   {
   if(!Place.Chart.In.Upper.Right) Corner.Of.Chart.Right.Top=0;
   return(0);
   }
//+------------------------------------------------------------------+
int deinit()
   {
   ObjectsDeleteAll(0,OBJ_LABEL);
   return(0);
   }
//+------------------------------------------------------------------+
int start()
   {
   //int      counted_bars=IndicatorCounted();
   //if(counted_bars<0) return(0);    //No bars have changed.  Go ahead and exit
   int      Adjust_Side_to_side=0,Shift_UP_DN=0;
   color    Color.Bar.Label = LightSteelBlue;
   string   BarSymbol="-";
   string   R1Label="NLMA",R2Label="T3",R3Label="PSAR",R4Label="Vol",R5Label="HAS";
   int      R1M5,R1M15,R1M30,R1H1,R1D1;
   int      R2M5,R2M15,R2M30,R2H1,R2D1;
   int      R3M5,R3M15,R3M30,R3H1,R3D1;
   int      R4M5,R4M15,R4M30,R4H1,R4D1;
   int      R5M5,R5M15,R5M30,R5H1,R5D1;
   int      Col1Offset=15,Col2Offset=42,Col3Offset=62,Col4Offset=82,Col5Offset=102,Col6Offset=122;
   double   B0=0,B1=0;
   string   tString="";


//--------------------------Calculate Colors for Indicators--------------------------------
RefreshRates();
//-----------------mNLMAv6---R1
R1M5=Color.When.Above;R1M15=Color.When.Above;R1M30=Color.When.Above;R1H1=Color.When.Above;R1D1=Color.When.Above;
if(iCustom(Symbol(),PERIOD_M1,"mNLMAv6",1,0)==EMPTY_VALUE) R1M5=Color.When.Below;
if(iCustom(Symbol(),PERIOD_M5,"mNLMAv6",1,0)==EMPTY_VALUE) R1M15=Color.When.Below;
if(iCustom(Symbol(),PERIOD_M15,"mNLMAv6",1,0)==EMPTY_VALUE) R1M30=Color.When.Below;
if(iCustom(Symbol(),PERIOD_M30,"mNLMAv6",1,0)==EMPTY_VALUE) R1H1=Color.When.Below;
if(iCustom(Symbol(),PERIOD_H1,"mNLMAv6",1,0)==EMPTY_VALUE) R1D1=Color.When.Below;
//-----------------T3---R2
R2M5=Color.When.Below;R2M15=Color.When.Below;R2M30=Color.When.Below;R2H1=Color.When.Below;R2D1=Color.When.Below;
if(iCustom(Symbol(),PERIOD_M1,"mT3",T3.Volume.Factor,T3.Periods,0,0)B0) R5M5=Color.When.Above;
B0=iCustom(NULL,PERIOD_M5,"mHeikenAshi_DM",0,0);
B1=iCustom(NULL,PERIOD_M5,"mHeikenAshi_DM",1,0);
if(B1>B0) R5M15=Color.When.Above;
B0=iCustom(NULL,PERIOD_M15,"mHeikenAshi_DM",0,0);
B1=iCustom(NULL,PERIOD_M15,"mHeikenAshi_DM",1,0);
if(B1>B0) R5M30=Color.When.Above;
B0=iCustom(NULL,PERIOD_M30,"mHeikenAshi_DM",0,0);
B1=iCustom(NULL,PERIOD_M30,"mHeikenAshi_DM",1,0);
if(B1>B0) R5H1=Color.When.Above;
B0=iCustom(NULL,PERIOD_H1,"mHeikenAshi_DM",0,0);
B1=iCustom(NULL,PERIOD_H1,"mHeikenAshi_DM",1,0);
if(B1>B0) R5D1=Color.When.Above;

//----------------------------PAINT INDICATOR SECTION-------------------------------------

   //---------------Add top row labels
   ObjectCreate("TF_D1",OBJ_LABEL,0,0,0);
   ObjectSetText("TF_D1","H1",6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("TF_D1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("TF_D1",OBJPROP_XDISTANCE,Adjust_Side_to_side + 48);
   ObjectSet("TF_D1",OBJPROP_YDISTANCE,Shift_UP_DN + 25);   

   ObjectCreate("TF_H1",OBJ_LABEL,0,0,0);
   ObjectSetText("TF_H1","M30",6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("TF_H1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("TF_H1",OBJPROP_XDISTANCE,Adjust_Side_to_side + 63);
   ObjectSet("TF_H1",OBJPROP_YDISTANCE,Shift_UP_DN + 25);   
   
   ObjectCreate("TF_M30",OBJ_LABEL,0,0,0);
   ObjectSetText("TF_M30","M15",6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("TF_M30",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("TF_M30",OBJPROP_XDISTANCE,Adjust_Side_to_side + 85);
   ObjectSet("TF_M30",OBJPROP_YDISTANCE,Shift_UP_DN + 25);   
   
   ObjectCreate("TF_M15",OBJ_LABEL,0,0,0);
   ObjectSetText("TF_M15","M5",6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("TF_M15",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("TF_M15",OBJPROP_XDISTANCE,Adjust_Side_to_side + 107);
   ObjectSet("TF_M15",OBJPROP_YDISTANCE,Shift_UP_DN + 25);   

   ObjectCreate("TF_M5",OBJ_LABEL,0,0,0);
   ObjectSetText("TF_M5","M1",6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("TF_M5",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("TF_M5",OBJPROP_XDISTANCE,Adjust_Side_to_side + 127);
   ObjectSet("TF_M5",OBJPROP_YDISTANCE,Shift_UP_DN + 25);   


   //---------------Indicators  R1--------------------------
   ObjectCreate("LabelR1",OBJ_LABEL,0,0,0);
   ObjectSetText("LabelR1",R1Label,6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("LabelR1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("LabelR1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col1Offset);
   ObjectSet("LabelR1",OBJPROP_YDISTANCE,Shift_UP_DN + 35);

   ObjectCreate("SignalR1D1",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR1D1",BarSymbol,45,"Tahoma Narrow",R1D1);
   ObjectSet("SignalR1D1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR1D1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col2Offset);
   ObjectSet("SignalR1D1",OBJPROP_YDISTANCE,Shift_UP_DN + 2);

   ObjectCreate("SignalR1H1",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR1H1",BarSymbol,45,"Tahoma Narrow",R1H1);
   ObjectSet("SignalR1H1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR1H1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col3Offset);
   ObjectSet("SignalR1H1",OBJPROP_YDISTANCE,Shift_UP_DN + 2);

   ObjectCreate("SignalR1M30",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR1M30",BarSymbol,45,"Tahoma Narrow",R1M30);
   ObjectSet("SignalR1M30",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR1M30",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col4Offset);
   ObjectSet("SignalR1M30",OBJPROP_YDISTANCE,Shift_UP_DN + 2);

   ObjectCreate("SignalR1M15",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR1M15",BarSymbol,45,"Tahoma Narrow",R1M15);
   ObjectSet("SignalR1M15",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR1M15",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col5Offset);
   ObjectSet("SignalR1M15",OBJPROP_YDISTANCE,Shift_UP_DN + 2);

   ObjectCreate("SignalR1M5",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR1M5",BarSymbol,45,"Tahoma Narrow",R1M5);
   ObjectSet("SignalR1M5",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR1M5",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col6Offset);
   ObjectSet("SignalR1M5",OBJPROP_YDISTANCE,Shift_UP_DN + 2);
   
   //----------------R2
   ObjectCreate("LabelR2",OBJ_LABEL,0,0,0);
   ObjectSetText("LabelR2",R2Label,6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("LabelR2",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("LabelR2",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col1Offset);
   ObjectSet("LabelR2",OBJPROP_YDISTANCE,Shift_UP_DN + 45);

   ObjectCreate("SignalR2D1",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR2D1",BarSymbol,45,"Tahoma Narrow",R2D1);
   ObjectSet("SignalR2D1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR2D1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col2Offset);
   ObjectSet("SignalR2D1",OBJPROP_YDISTANCE,Shift_UP_DN + 12);

   ObjectCreate("SignalR2H1",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR2H1",BarSymbol,45,"Tahoma Narrow",R2H1);
   ObjectSet("SignalR2H1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR2H1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col3Offset);
   ObjectSet("SignalR2H1",OBJPROP_YDISTANCE,Shift_UP_DN + 12);

   ObjectCreate("SignalR2M30",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR2M30",BarSymbol,45,"Tahoma Narrow",R2M30);
   ObjectSet("SignalR2M30",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR2M30",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col4Offset);
   ObjectSet("SignalR2M30",OBJPROP_YDISTANCE,Shift_UP_DN + 12);

   ObjectCreate("SignalR2M15",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR2M15",BarSymbol,45,"Tahoma Narrow",R2M15);
   ObjectSet("SignalR2M15",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR2M15",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col5Offset);
   ObjectSet("SignalR2M15",OBJPROP_YDISTANCE,Shift_UP_DN + 12);

   ObjectCreate("SignalR2M5",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR2M5",BarSymbol,45,"Tahoma Narrow",R2M5);
   ObjectSet("SignalR2M5",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR2M5",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col6Offset);
   ObjectSet("SignalR2M5",OBJPROP_YDISTANCE,Shift_UP_DN + 12);
   
   //----------------R3
   ObjectCreate("LabelR3",OBJ_LABEL,0,0,0);
   ObjectSetText("LabelR3",R3Label,6,"Tahoma Narrow",Color.Bar.Label);
   ObjectSet("LabelR3",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("LabelR3",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col1Offset);
   ObjectSet("LabelR3",OBJPROP_YDISTANCE,Shift_UP_DN + 55);

   ObjectCreate("SignalR3D1",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR3D1",BarSymbol,45,"Tahoma Narrow",R3D1);
   ObjectSet("SignalR3D1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR3D1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col2Offset);
   ObjectSet("SignalR3D1",OBJPROP_YDISTANCE,Shift_UP_DN + 22);

   ObjectCreate("SignalR3H1",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR3H1",BarSymbol,45,"Tahoma Narrow",R3H1);
   ObjectSet("SignalR3H1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR3H1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col3Offset);
   ObjectSet("SignalR3H1",OBJPROP_YDISTANCE,Shift_UP_DN + 22);

   ObjectCreate("SignalR3M30",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR3M30",BarSymbol,45,"Tahoma Narrow",R3M30);
   ObjectSet("SignalR3M30",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR3M30",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col4Offset);
   ObjectSet("SignalR3M30",OBJPROP_YDISTANCE,Shift_UP_DN + 22);

   ObjectCreate("SignalR3M15",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR3M15",BarSymbol,45,"Tahoma Narrow",R3M15);
   ObjectSet("SignalR3M15",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR3M15",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col5Offset);
   ObjectSet("SignalR3M15",OBJPROP_YDISTANCE,Shift_UP_DN + 22);

   ObjectCreate("SignalR3M5",OBJ_LABEL,0,0,0);
   ObjectSetText("SignalR3M5",BarSymbol,45,"Tahoma Narrow",R3M5);
   ObjectSet("SignalR3M5",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
   ObjectSet("SignalR3M5",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col6Offset);
   ObjectSet("SignalR3M5",OBJPROP_YDISTANCE,Shift_UP_DN + 22);
   
   //----------------R4
      ObjectCreate("LabelR4",OBJ_LABEL,0,0,0);
      ObjectSetText("LabelR4",R4Label,6,"Tahoma Narrow",Color.Bar.Label);
      ObjectSet("LabelR4",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("LabelR4",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col1Offset);
      ObjectSet("LabelR4",OBJPROP_YDISTANCE,Shift_UP_DN + 65);

      ObjectCreate("SignalR4D1",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR4D1",BarSymbol,45,"Tahoma Narrow",R4D1);
      ObjectSet("SignalR4D1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR4D1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col2Offset);
      ObjectSet("SignalR4D1",OBJPROP_YDISTANCE,Shift_UP_DN + 32);

      ObjectCreate("SignalR4H1",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR4H1",BarSymbol,45,"Tahoma Narrow",R4H1);
      ObjectSet("SignalR4H1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR4H1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col3Offset);
      ObjectSet("SignalR4H1",OBJPROP_YDISTANCE,Shift_UP_DN + 32);

      ObjectCreate("SignalR4M30",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR4M30",BarSymbol,45,"Tahoma Narrow",R4M30);
      ObjectSet("SignalR4M30",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR4M30",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col4Offset);
      ObjectSet("SignalR4M30",OBJPROP_YDISTANCE,Shift_UP_DN + 32);

      ObjectCreate("SignalR4M15",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR4M15",BarSymbol,45,"Tahoma Narrow",R4M15);
      ObjectSet("SignalR4M15",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR4M15",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col5Offset);
      ObjectSet("SignalR4M15",OBJPROP_YDISTANCE,Shift_UP_DN + 32);

      ObjectCreate("SignalR4M5",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR4M5",BarSymbol,45,"Tahoma Narrow",R4M5);
      ObjectSet("SignalR4M5",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR4M5",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col6Offset);
      ObjectSet("SignalR4M5",OBJPROP_YDISTANCE,Shift_UP_DN + 32);
   //----------------R5
      ObjectCreate("LabelR5",OBJ_LABEL,0,0,0);
      ObjectSetText("LabelR5",R5Label,6,"Tahoma Narrow",Color.Bar.Label);
      ObjectSet("LabelR5",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("LabelR5",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col1Offset);
      ObjectSet("LabelR5",OBJPROP_YDISTANCE,Shift_UP_DN + 75);

      ObjectCreate("SignalR5D1",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR5D1",BarSymbol,45,"Tahoma Narrow",R5D1);
      ObjectSet("SignalR5D1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR5D1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col2Offset);
      ObjectSet("SignalR5D1",OBJPROP_YDISTANCE,Shift_UP_DN + 42);

      ObjectCreate("SignalR5H1",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR5H1",BarSymbol,45,"Tahoma Narrow",R5H1);
      ObjectSet("SignalR5H1",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR5H1",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col3Offset);
      ObjectSet("SignalR5H1",OBJPROP_YDISTANCE,Shift_UP_DN + 42);

      ObjectCreate("SignalR5M30",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR5M30",BarSymbol,45,"Tahoma Narrow",R5M30);
      ObjectSet("SignalR5M30",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR5M30",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col4Offset);
      ObjectSet("SignalR5M30",OBJPROP_YDISTANCE,Shift_UP_DN + 42);

      ObjectCreate("SignalR5M15",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR5M15",BarSymbol,45,"Tahoma Narrow",R5M15);
      ObjectSet("SignalR5M15",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR5M15",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col5Offset);
      ObjectSet("SignalR5M15",OBJPROP_YDISTANCE,Shift_UP_DN + 42);

      ObjectCreate("SignalR5M5",OBJ_LABEL,0,0,0);
      ObjectSetText("SignalR5M5",BarSymbol,45,"Tahoma Narrow",R5M5);
      ObjectSet("SignalR5M5",OBJPROP_CORNER,Corner.Of.Chart.Right.Top);
      ObjectSet("SignalR5M5",OBJPROP_XDISTANCE,Adjust_Side_to_side + Col6Offset);
      ObjectSet("SignalR5M5",OBJPROP_YDISTANCE,Shift_UP_DN + 42);

   return(0);
  }

Recommend