Gann SQ9 Price Levels_version-3





//+------------------------------------------------------------------+
//|                                                  SQ9 (Price).mq4 |
//|                                  Copyright © 2006, Matt Trigwell |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Matt Trigwell"
#property link      "m.trigwell@gmail.com" //  then hacked around by deanz.

#property indicator_chart_window


int       line_spacing_multiplier=0;

extern int        levels__to=360;
extern int        lines_every=90;
extern double     factorNumber=0.5;

extern color     line_Color=Yellow;
extern int       line_Style_choose_from_0_to_4=0;
extern int       font_size=9;


bool      is_this_the_HIGH_price=true;


int init()
{
   return(0);
}

int deinit()
{
   double AngleIndex=0;
   string AngleName="";


   for(AngleIndex=0;AngleIndex<=levels__to;AngleIndex=AngleIndex+lines_every)
   {
      AngleName = "Angle_" + AngleIndex;
      ObjectDelete(AngleName + " Label");
      ObjectDelete(AngleName + " Line");
   }

   
   return(0);
}

int start()
{
double    the_High_or_Low_Price=0;   
   double AngleIndex=0;
   string AngleName="";
   double FactorIndex=0;
   double AnglePriceLevel=0;
   int Index=0;
   string strLabel="";
   
if(ObjectFind("1")!=-1)
   {
   line_spacing_multiplier=1000000;
   the_High_or_Low_Price = ObjectGet("1", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=false;
   }
   
if(ObjectFind("2")!=-1)
   {
   line_spacing_multiplier=100000;
   the_High_or_Low_Price = ObjectGet("2", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=false;
   }
   
if(ObjectFind("3")!=-1)
   {
   line_spacing_multiplier=10000;
   the_High_or_Low_Price = ObjectGet("3", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=false;
   }
   
if(ObjectFind("4")!=-1)
   {
   line_spacing_multiplier=1000;
   the_High_or_Low_Price = ObjectGet("4", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=false;
   }
   
if(ObjectFind("5")!=-1)
   {
   line_spacing_multiplier=100;
   the_High_or_Low_Price = ObjectGet("5", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=false;
   }
   
if(ObjectFind("6")!=-1)
   {
   line_spacing_multiplier=10;
   the_High_or_Low_Price = ObjectGet("6", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=false;
   }
   
                  
 ////////////////////////////////////////////////////////////////  
   
   
   

if(ObjectFind("-1")!=-1)
   {
    line_spacing_multiplier=1000000;
    the_High_or_Low_Price = ObjectGet("-1", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=true;
   }


if(ObjectFind("-2")!=-1)
   {
    line_spacing_multiplier=100000;
    the_High_or_Low_Price = ObjectGet("-2", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=true;
   }
   
   
if(ObjectFind("-3")!=-1)
   {
    line_spacing_multiplier=10000;
    the_High_or_Low_Price = ObjectGet("-3", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=true;
   }
   
if(ObjectFind("-4")!=-1)
   {
    line_spacing_multiplier=1000;
    the_High_or_Low_Price = ObjectGet("-4", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=true;
   }
   
if(ObjectFind("-5")!=-1)
   {
    line_spacing_multiplier=100;
    the_High_or_Low_Price = ObjectGet("-5", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=true;
   }
   
 if(ObjectFind("-6")!=-1)
   {
    line_spacing_multiplier=10;
    the_High_or_Low_Price = ObjectGet("-6", OBJPROP_PRICE1); 
   is_this_the_HIGH_price=true;
   }
   
              
   for(AngleIndex=0;AngleIndex<=levels__to;AngleIndex=AngleIndex+lines_every)
   {
      AnglePriceLevel = CalculateSquare(FactorIndex,the_High_or_Low_Price);
      
      //Trim Zero's
      if(Index==1)
      {
         strLabel = DoubleToStr(AngleIndex,1);
      }
      else
      {
         strLabel = DoubleToStr(AngleIndex,0);
      }
      
      AngleName = "Angle_" + AngleIndex;
      
      

      if(ObjectFind(AngleName + " Line") != 0)
      {
         ObjectCreate(AngleName + " Line", OBJ_HLINE, 0, Time[40], AnglePriceLevel);
         ObjectSet(AngleName + " Line", OBJPROP_STYLE, line_Style_choose_from_0_to_4);
         
         if(MathMod(Index,2) == 0)
         {
            ObjectSet(AngleName + " Line", OBJPROP_COLOR, line_Color);
         }
         else
         {
             ObjectSet(AngleName + " Line", OBJPROP_COLOR, line_Color);
         }
      }
      else
      {
         ObjectMove(AngleName + " Line", 0, Time[40], AnglePriceLevel);
      }
   
      if(ObjectFind(AngleName + " Label") != 0)
      {
         ObjectCreate(AngleName + " Label", OBJ_TEXT, 0, Time[20], AnglePriceLevel);
         
         if(MathMod(Index,2) == 0)
         {
            ObjectSetText(AngleName + " Label", strLabel + "°", font_size, "Arial", line_Color);
            
         }
         else
         {
             ObjectSetText(AngleName + " Label", strLabel + "°", font_size, "Arial", line_Color);
         }  

      }
      else
      {
         ObjectMove(AngleName + " Label", 0, Time[20], AnglePriceLevel);
      }
      
      FactorIndex = FactorIndex + factorNumber;
      Index = Index + 1;
   }

   return(0);
}






double CalculateSquare(double Factor, double Price)
{
   double AnglePrice=0;



  if(Price > 0)
   {
   
      if(StringFind(Symbol(),"JPY",0) == -1)
      {
         Price = Price * line_spacing_multiplier;
      }
      else
      {
         Price = Price * line_spacing_multiplier;
         Price = Price  / 100;
      }
            
      if(is_this_the_HIGH_price==false)
      {
         AnglePrice = MathPow(MathSqrt(Price) + Factor,2);
      }
      else
      {
         AnglePrice = MathPow(MathSqrt(Price) - Factor,2);
      }
   
      if(StringFind(Symbol(),"JPY",0) == -1)
      {
         AnglePrice = AnglePrice / line_spacing_multiplier;
      }
      else
      {
         AnglePrice = AnglePrice / line_spacing_multiplier;
         AnglePrice = AnglePrice  * 100;
      }
   
   }
   
   return(AnglePrice);

 
} 



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: