#property  copyright "Copyright © 2007, FXImpact"
#property  link "http://www.fximpact.com"

#property  indicator_separate_window
#property  indicator_buffers 8
#property  indicator_color1  Black
#property  indicator_color2  Lime
#property  indicator_color3  Lime
#property  indicator_color4  Yellow
#property  indicator_color5  Red
#property  indicator_color6  Red
#property  indicator_color7  Black
#property  indicator_color8  Black

//extern   string   pswd = "-- Please Input Password --";
//extern   string   Password = "";
extern   string   optns = "-- Options --";
extern   int      boxValue = 5;
extern   int      Multiply = 3;
extern   bool     ShowGrid = true;
extern   string   clrs = "-- Color Options --";
extern   color    ColorUp = Green;
extern   color    ColorDown = Red;
extern   color    PriceLevel = Red;
extern   color    GridColor = Gray;
bool     var_136 = false;
bool     var_140 = false;
bool     var_144 = true;
bool     var_148 = false;
bool     var_152 = false;
double   var_156 = 0;
double   var_164 = 0;
int      var_172 = 0;
int      var_176 = 0;
int      var_180 = 0;
double   arr_184[];
double   var_188 = 0;
bool     var_196 = true;
int      var_200 = 0;
int      var_204;
int      var_208;
int      var_212 = -1;
string   var_216;
int      FH;
int      var_228 = 0;
int      var_232 = 0;
double   arr_236[];
double   arr_240[];
double   var_244;
double   var_252;
double   arr_260[];
double   arr_264[];
double   arr_268[];
double   arr_272[];
double   arr_276[];
double   arr_280[];
int      var_284 = -1;
int      var_288;
bool     var_292 = false;
double gdXecn = 1;

//+------------------------------------------------------------------+



void drawPatterns(int i, int j)
{
double var_drawPatterns_8;
double var_drawPatterns_16;

if ((arr_236[i + 4] == arr_236[i + 2]) && (arr_236[i + 4] > arr_236[i + 3]) && (arr_236[i + 1] < arr_236[i + 2]))
   {
   if (isBufferEmpty(0,6,i))
      {
      arr_260[j + 5] = arr_236[i + 4];
      arr_260[j + 4] = arr_236[i + 4];
      arr_260[j + 3] = arr_236[i + 4];
      arr_260[j + 2] = arr_236[i + 4];
      arr_260[j + 1] = arr_236[i + 4];
      arr_260[j] = arr_236[i + 4];
      if (i == 0) doAlert("Triple Top","Look for a breakout above the resistance line",1,1);
      }
         else
      {
      if (var_232 == 0)
         {
         }
      }
   }

if ((arr_240[i + 4] == arr_240[i + 2]) && (arr_240[i + 4] < arr_240[i + 3]) && (arr_240[i + 1] > arr_240[i + 2]))
   {
   if (isBufferEmpty(1,6,i))
      {
      arr_272[j + 5] = arr_240[i + 4];
      arr_272[j + 4] = arr_240[i + 4];
      arr_272[j + 3] = arr_240[i + 4];
      arr_272[j + 2] = arr_240[i + 4];
      arr_272[j + 1] = arr_240[i + 4];
      arr_272[j] = arr_240[i + 4];
      if (i == 0) doAlert("Triple Bottom","Look for a breakout below the support line",2,0);
      }
         else
      {
      if (var_228 == 0)
         {
         }
      }
   }

if ((arr_236[i + 6] == arr_236[i + 4]) && (arr_236[i + 6] > arr_236[i + 5]) && (arr_236[i + 1] < arr_236[i + 5]) && (arr_236[i + 2] < arr_236[i + 4]))
   {
   if (isBufferEmpty(2,9,i))
      {
      arr_264[j + 7] = arr_236[i + 4];
      arr_264[j + 6] = arr_236[i + 4];
      arr_264[j + 5] = arr_236[i + 4];
      arr_264[j + 4] = arr_236[i + 4];
      arr_264[j + 3] = arr_236[i + 4];
      arr_264[j + 2] = arr_236[i + 4];
      arr_264[j + 1] = arr_236[i + 4];
      arr_264[j] = arr_236[i + 4];
      if (i == 0) doAlert("Spread Triple Top","Look for a breakout above the resistance line",3,1);
      }
         else
      {
      if (var_232 == 0)
         {
         }
      }
   }

if ((arr_240[i + 6] == arr_240[i + 4]) && (arr_240[i + 6] < arr_240[i + 5]) && (arr_240[i + 1] > arr_240[i + 5]) && (arr_240[i + 2] > arr_240[i + 4]))
   {
   if (isBufferEmpty(3,9,i))
      {
      arr_276[j + 7] = arr_240[i + 4];
      arr_276[j + 6] = arr_240[i + 4];
      arr_276[j + 5] = arr_240[i + 4];
      arr_276[j + 4] = arr_240[i + 4];
      arr_276[j + 3] = arr_240[i + 4];
      arr_276[j + 2] = arr_240[i + 4];
      arr_276[j + 1] = arr_240[i + 4];
      arr_276[j] = arr_240[i + 4];
      if (i == 0) doAlert("Spread Triple Bottom","Look for a breakout below the support line",4,0);
      }
         else
      {
      if (var_228 == 0)
         {
         }
      }
   }

if ((arr_236[i + 6] < arr_236[i + 4]) && (arr_236[i + 6] > arr_236[i + 5]) && (arr_236[i + 5] < arr_236[i + 4]) && (arr_236[i + 4] < arr_236[i + 2]) && (arr_236[i + 4] > arr_236[i + 3]) && (arr_236[i + 3] < arr_236[i + 2]) && (arr_236[i + 1] < arr_236[i + 2]) && ((arr_236[i + 4] - arr_236[i + 6]) / ((gdXecn*boxValue) * Point) <= 5))
   {
   var_drawPatterns_8 = (arr_236[i + 4] - arr_236[i + 6]) * 0.5;
   var_drawPatterns_16 = (arr_236[i + 2] - arr_236[i + 4]) * 0.5;
   if (var_drawPatterns_8 == var_drawPatterns_16)
      {
      if (isBufferEmpty(2,8,i))
         {
         arr_264[j + 7] = arr_236[i + 6];
         arr_264[j + 6] = arr_264[i + 7] + var_drawPatterns_8;
         arr_264[j + 5] = arr_264[i + 6] + var_drawPatterns_8;
         arr_264[j + 4] = arr_264[i + 5] + var_drawPatterns_8;
         arr_264[j + 3] = arr_264[i + 4] + var_drawPatterns_8;
         arr_264[j + 2] = arr_264[i + 3] + var_drawPatterns_8;
         arr_264[j + 1] = arr_264[i + 2] + var_drawPatterns_8;
         arr_264[j] = arr_264[i + 1] + var_drawPatterns_8;
         if (i == 0) doAlert("Bullish Resistance","Look for a breakout above the resistance line",5,1);
         }
            else
         {
         if (var_232 == 0)
            {
            }
         }
      }
   }

if ((arr_240[i + 6] > arr_240[i + 4]) && (arr_240[i + 6] < arr_240[i + 5]) && (arr_240[i + 5] > arr_240[i + 4]) && (arr_240[i + 4] > arr_240[i + 2]) && (arr_240[i + 4] < arr_240[i + 3]) && (arr_240[i + 3] > arr_240[i + 2]) && (arr_240[i + 1] > arr_240[i + 2]) && ((arr_240[i + 6] - arr_240[i + 4]) / ((gdXecn*boxValue) * Point) <= 5))
   {
   var_drawPatterns_8 = (arr_240[i + 6] - arr_240[i + 4]) * 0.5;
   var_drawPatterns_16 = (arr_240[i + 4] - arr_240[i + 2]) * 0.5;
   if (var_drawPatterns_8 == var_drawPatterns_16)
      {
      if (isBufferEmpty(3,8,i))
         {
         arr_276[j + 7] = arr_240[i + 6];
         arr_276[j + 6] = arr_276[i + 7] - var_drawPatterns_8;
         arr_276[j + 5] = arr_276[i + 6] - var_drawPatterns_8;
         arr_276[j + 4] = arr_276[i + 5] - var_drawPatterns_8;
         arr_276[j + 3] = arr_276[i + 4] - var_drawPatterns_8;
         arr_276[j + 2] = arr_276[i + 3] - var_drawPatterns_8;
         arr_276[j + 1] = arr_276[i + 2] - var_drawPatterns_8;
         arr_276[j] = arr_276[i + 1] - var_drawPatterns_8;
         if (i == 0) doAlert("Bearish Support","Look for a breakout below the support line",6,0);
         }
            else
         {
         if (var_228 == 0)
            {
            }
         }
      }
   }

if ((arr_236[i + 6] == arr_236[i + 5] + (gdXecn*boxValue) * Point) && (arr_236[i + 5] == arr_236[i + 4] + (gdXecn*boxValue) * Point) && (arr_236[i + 4] == arr_236[i + 3] + (gdXecn*boxValue) * Point) && (arr_236[i + 3] == arr_236[i + 2] + (gdXecn*boxValue) * Point) && (arr_236[i + 2] == arr_236[i + 1] + (gdXecn*boxValue) * Point))
   {
   if (isBufferEmpty(2,7,i))
      {
      arr_264[j + 6] = arr_236[i + 6];
      arr_264[j + 5] = arr_236[i + 5];
      arr_264[j + 4] = arr_236[i + 4];
      arr_264[j + 3] = arr_236[i + 3];
      arr_264[j + 2] = arr_236[i + 2];
      arr_264[j + 1] = arr_236[i + 1];
      arr_264[j] = arr_236[i + 1] - (gdXecn*boxValue) * Point;
      if (i == 0) doAlert("Stairstep Bullish Resistance","Look for a breakout above the resistance line",7,1);
      }
         else
      {
      if (var_232 == 0)
         {
         }
      }
   }

if ((arr_240[i + 6] + (gdXecn*boxValue) * Point == arr_240[i + 5]) && (arr_240[i + 5] + (gdXecn*boxValue) * Point == arr_240[i + 4]) && (arr_240[i + 4] + (gdXecn*boxValue) * Point == arr_240[i + 3]) && (arr_240[i + 3] + (gdXecn*boxValue) * Point == arr_240[i + 2]) && (arr_240[i + 2] + (gdXecn*boxValue) * Point == arr_240[i + 1]))
   {
   if (isBufferEmpty(3,7,i))
      {
      arr_276[j + 6] = arr_240[i + 6];
      arr_276[j + 5] = arr_276[i + 6] + (gdXecn*boxValue) * Point;
      arr_276[j + 4] = arr_276[i + 5] + (gdXecn*boxValue) * Point;
      arr_276[j + 3] = arr_276[i + 4] + (gdXecn*boxValue) * Point;
      arr_276[j + 2] = arr_276[i + 3] + (gdXecn*boxValue) * Point;
      arr_276[j + 1] = arr_276[i + 2] + (gdXecn*boxValue) * Point;
      arr_276[j] = arr_276[i + 1] + (gdXecn*boxValue) * Point;
      if (i == 0) doAlert("Stairstep Bullish Support","Look for a breakout below the support line",8,0);
      }
         else
      {
      if (var_228 == 0)
         {
         }
      }
   }

if ((arr_236[i + 2] - arr_240[i + 2] / ((gdXecn*boxValue) * Point) <= 7) && (arr_236[i + 6] == arr_236[i + 4]) && (arr_236[i + 6] > arr_236[i + 5]) && (arr_236[i + 5] < arr_236[i + 4]) && (arr_236[i + 4] > arr_236[i + 3]) && (arr_236[i + 4] < arr_236[i + 2]) && (arr_236[i + 3] < arr_236[i + 2]) && (arr_236[i + 2] > arr_236[i + 1]) && (arr_240[i + 2] < arr_240[i + 1]))
   {
   if (isBufferEmpty(0,4,i))
      {
      arr_260[i + 3] = arr_236[i + 2];
      arr_260[i + 2] = arr_236[i + 2];
      arr_260[i + 1] = arr_236[i + 2];
      arr_260[i] = arr_236[i + 2];
      if (i == 0) doAlert("Bullish Catapault","Look for a breakout above the resistance line",9,1);
      }
         else
      {
      if (var_232 == 0)
         {
         }
      }
   }

if ((arr_236[i + 2] - arr_240[i + 2] / ((gdXecn*boxValue) * Point) <= 7) && (arr_240[i + 6] == arr_240[i + 4]) && (arr_240[i + 6] > arr_240[i + 5]) && (arr_240[i + 5] < arr_240[i + 4]) && (arr_240[i + 4] > arr_240[i + 3]) && (arr_240[i + 4] < arr_240[i + 2]) && (arr_240[i + 3] < arr_240[i + 2]) && (arr_236[i + 2] > arr_236[i + 1]) && (arr_240[i + 2] < arr_240[i + 1]))
   {
   if (isBufferEmpty(1,4,i))
      {
      arr_272[i + 3] = arr_240[i + 2];
      arr_272[i + 2] = arr_240[i + 2];
      arr_272[i + 1] = arr_240[i + 2];
      arr_272[i] = arr_240[i + 2];
      if (i == 0) doAlert("Bearish Catapault","Look for a breakout below the support line",10,0);
      }
         else
      {
      if (var_228 == 0)
         {
         }
      }
   }

if ((arr_236[i + 4] > arr_236[i + 3]) && (arr_236[i + 3] > arr_236[i + 2]) && (arr_236[i + 2] > arr_236[i + 1]) && (arr_240[i + 4] < arr_240[i + 3]) && (arr_240[i + 3] < arr_240[i + 2]) && (arr_240[i + 2] < arr_240[i + 1]))
   {
   if (isBufferEmpty(2,5,i) && isBufferEmpty(3,5,i))
      {
      }
   }

if ((arr_236[i + 6] > arr_236[i + 5]) && (arr_236[i + 5] < arr_236[i + 4]) && (arr_236[i + 6] == arr_236[i + 4]) && (arr_236[i + 4] == arr_236[i + 2]) && (arr_236[i + 5] == arr_236[i + 3]) && (arr_236[i + 3] == arr_236[i + 1]) && (arr_240[i + 6] < arr_240[i + 5]) && (arr_240[i + 5] < arr_240[i + 4]) && (arr_240[i + 4] < arr_240[i + 3]) && (arr_240[i + 3] < arr_240[i + 2]) && (arr_240[i + 2] < arr_240[i + 1]) && (arr_240[i + 1] < arr_240[i]))
   {
   if ((arr_260[i + 8] == EMPTY_VALUE) && (arr_276[i + 7] == EMPTY_VALUE))
      {
      arr_260[i + 7] = arr_236[i + 6];
      arr_260[i + 6] = arr_236[i + 6];
      arr_260[i + 5] = arr_236[i + 6];
      arr_260[i + 4] = arr_236[i + 6];
      arr_260[i + 3] = arr_236[i + 6];
      arr_260[i + 2] = arr_236[i + 6];
      arr_260[i + 1] = arr_236[i + 6];
      arr_260[i] = arr_236[i + 6];
      arr_276[i + 6] = arr_240[i + 6];
      arr_276[i + 5] = arr_240[i + 5];
      arr_276[i + 4] = arr_240[i + 4];
      arr_276[i + 3] = arr_240[i + 3];
      arr_276[i + 2] = arr_240[i + 2];
      arr_276[i + 1] = arr_240[i + 1];
      arr_276[i] = arr_240[i];
      if (i == 0) doAlert("Ascending Triangle","Look for a breakout above the resistance line",12,1);
      }
         else
      {
      if (var_232 == 0)
         {
         }
      }
   }

if ((arr_240[i + 6] < arr_240[i + 5]) && (arr_240[i + 6] == arr_240[i + 4]) && (arr_240[i + 4] == arr_240[i + 2]) && (arr_240[i + 5] == arr_240[i + 3]) && (arr_240[i + 3] == arr_240[i + 1]) && (arr_236[i + 6] > arr_236[i + 5]) && (arr_236[i + 5] > arr_236[i + 4]) && (arr_236[i + 4] > arr_236[i + 3]) && (arr_236[i + 3] > arr_236[i + 2]) && (arr_236[i + 2] > arr_236[i + 1]) && (arr_236[i + 1] > arr_236[i]))
   {
   var_drawPatterns_8 = (arr_236[i + 5] - arr_236[i + 3]) * 0.5;
   var_drawPatterns_16 = (arr_236[i + 3] - arr_236[i + 1]) * 0.5;
   if ((arr_264[i + 7] == EMPTY_VALUE) && (arr_272[i + 8] == EMPTY_VALUE) && (var_drawPatterns_8 == var_drawPatterns_16))
      {
      arr_264[i + 5] = arr_236[i + 6];
      arr_264[i + 4] = arr_260[i + 5] - var_drawPatterns_8;
      arr_264[i + 3] = arr_260[i + 4] - var_drawPatterns_8;
      arr_264[i + 2] = arr_260[i + 3] - var_drawPatterns_8;
      arr_264[i + 1] = arr_260[i + 2] - var_drawPatterns_8;
      arr_264[i] = arr_260[i + 1] - var_drawPatterns_8;
      arr_272[i + 6] = arr_240[i + 6];
      arr_272[i + 5] = arr_240[i + 6];
      arr_272[i + 4] = arr_240[i + 6];
      arr_272[i + 3] = arr_240[i + 6];
      arr_272[i + 2] = arr_240[i + 6];
      arr_272[i + 1] = arr_240[i + 6];
      arr_272[i] = arr_240[i];
      if (i == 0) doAlert("Decending Triangle","Look for a breakout below the support line",13,0);
      }
         else
      {
      if (var_228 == 0)
         {
         }
      }
   }

if ((arr_236[i + 4] < arr_236[i + 2]) && (arr_236[i + 4] > arr_236[i + 3]) && (arr_236[i + 4] == arr_236[i + 1]) && (arr_236[i + 1] < arr_236[i + 2]))
   {
   if (isBufferEmpty(0,4,i))
      {
      arr_260[i + 3] = arr_236[i + 2];
      arr_260[i + 2] = arr_236[i + 2];
      arr_260[i + 1] = arr_236[i + 2];
      arr_260[i] = arr_236[i + 2];
      if (i == 0) doAlert("Ascending Triple Top","Look for a breakout above the resistance line",14,1);
      }
         else
      {
      if (var_232 == 0)
         {
         }
      }
   }

if ((arr_240[i + 4] > arr_236[i + 2]) && (arr_240[i + 4] < arr_236[i + 3]) && (arr_240[i + 4] == arr_240[i + 1]) && (arr_240[i + 1] > arr_240[i + 2]))
   {
   if (isBufferEmpty(1,6,i))
      {
      arr_272[i + 3] = arr_240[i + 2];
      arr_272[i + 2] = arr_240[i + 2];
      arr_272[i + 1] = arr_240[i + 2];
      arr_272[i] = arr_240[i + 2];
      if (i == 0) doAlert("Decending Triple Bottom","Look for a breakout below the support line",15,0);
      }
         else
      {
      if (var_228 == 0)
         {
         }
      }
   }
}

//+------------------------------------------------------------------+

bool isBufferEmpty(int code, int max, int j)
{
int i;

switch (code)
   {
   case 0:
      for (i = 0; i <= max; i++)
         {
         if (arr_260[j + i] != EMPTY_VALUE) return(false);
         }
      return(true);
      break;
   case 1:
      for (i = 0; i <= max; i++)
         {
         if (arr_272[j + i] != EMPTY_VALUE) return(false);
         }
      return(true);
      break;
   case 2:
      for (i = 0; i <= max; i++)
         {
         if (arr_264[j + i] != EMPTY_VALUE) return(false);
         }
      return(true);
      break;
   case 3:
      for (i = 0; i <= max; i++)
         {
         if (arr_276[j + i] != EMPTY_VALUE) return(false);
         }
      return(true);
      break;
   case 4:
      for (i = 0; i <= max; i++)
         {
         if (arr_268[j + i] != EMPTY_VALUE) return(false);
         }
      return(true);
      break;
   case 5:
      for (i = 0; i <= max; i++)
         {
         if (arr_280[j + i] != EMPTY_VALUE) return(false);
         }
      return(true);
   }
}

//+------------------------------------------------------------------+

void createHighLow(int code)
{
if (code != 0)
   {
   for (int i = var_208 - 5; i >= 0; i--)
      {
      if (arr_184[i + 1] < arr_184[i])
         {
         arr_236[i] = arr_184[i];
         arr_240[i] = arr_184[i + 1];
         }
      if (arr_184[i + 1] > arr_184[i])
         {
         arr_236[i] = arr_184[i + 1] - (gdXecn*boxValue) * Point;
         arr_240[i] = arr_184[i] - (gdXecn*boxValue) * Point;
         }
      }
   for (int j = var_208; j >= 0; j--)
      {
      drawPatterns(j,j);
      }
   }
      else
   {
   if (arr_184[code + 1] < arr_184[code])
      {
      arr_236[code] = arr_184[code];
      arr_240[code] = arr_184[code + 1];
      }
   if (arr_184[code + 1] > arr_184[code])
      {
      arr_236[code] = arr_184[code + 1] - (gdXecn*boxValue) * Point;
      arr_240[code] = arr_184[code] - (gdXecn*boxValue) * Point;
      }
   drawPatterns(0,0);
   }
}

//+------------------------------------------------------------------+

void doAlert(string name, string descr, int inp_doAlert_16, int code)
{
if (code == 0) var_228 = inp_doAlert_16;
if (code == 1) var_232 = inp_doAlert_16;
Alert(Symbol() + " -- " + name + " Detected -- " + descr);
}

//+------------------------------------------------------------------+

void doArrows(string descr, double price)
{
string type;

var_284++;
if (price == Bid)
   {
   type = "SELL";
   ObjectCreate("ArrowShort_" + var_212 + "_" + var_284,OBJ_ARROW,var_212,Time[0],arr_236[0] + (gdXecn*boxValue) * Point * 2);
   ObjectSet("ArrowShort_" + var_212 + "_" + var_284,OBJPROP_ARROWCODE,234);
   ObjectSet("ArrowShort_" + var_212 + "_" + var_284,OBJPROP_COLOR,Red);
   ObjectSet("ArrowShort_" + var_212 + "_" + var_284,OBJPROP_WIDTH,2);
   var_228 = 0;
   }

if (price == Ask)
   {
   type = "BUY";
   ObjectCreate("ArrowLong_" + var_212 + "_" + var_284,OBJ_ARROW,var_212,Time[0],arr_240[0] - (gdXecn*boxValue) * Point * 2);
   ObjectSet("ArrowLong_" + var_212 + "_" + var_284,OBJPROP_ARROWCODE,233);
   ObjectSet("ArrowLong_" + var_212 + "_" + var_284,OBJPROP_COLOR,Green);
   ObjectSet("ArrowLong_" + var_212 + "_" + var_284,OBJPROP_WIDTH,2);
   var_232 = 0;
   }
Alert(Symbol() + " -- " + descr + " Confirmed -- " + type + " at " + price);
}

//+------------------------------------------------------------------+

int init()
{
var_288 = Bars;
SetIndexStyle(0,DRAW_NONE);
SetIndexDrawBegin(0,0);
SetIndexBuffer(0,arr_184);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
SetIndexDrawBegin(1,0);
SetIndexBuffer(1,arr_260);
SetIndexLabel(1,"Resistance 1");
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,3);
SetIndexDrawBegin(2,0);
SetIndexBuffer(2,arr_264);
SetIndexLabel(2,"Resistance 2");
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,3);
SetIndexDrawBegin(3,0);
SetIndexBuffer(3,arr_268);
SetIndexLabel(3,"Resistance 3");
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,3);
SetIndexDrawBegin(4,0);
SetIndexBuffer(4,arr_272);
SetIndexLabel(4,"Support 1");
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,3);
SetIndexDrawBegin(5,0);
SetIndexBuffer(5,arr_276);
SetIndexLabel(5,"Support 2");
SetIndexStyle(6,DRAW_NONE);
SetIndexDrawBegin(6,0);
SetIndexBuffer(6,arr_240);
SetIndexLabel(6,"Low");
SetIndexStyle(7,DRAW_NONE);
SetIndexDrawBegin(7,0);
SetIndexBuffer(7,arr_236);
SetIndexLabel(7,"High");
IndicatorShortName("Point and Figure (" + boxValue + "," + Multiply + ") | ForexImpact.com");

   if(Digits==3||Digits==5){
      gdXecn=10;
   } 

/*FH = FileOpen("pf.csv",FILE_CSV|FILE_READ);
if (FH < 1)
   {
   var_140 = chkPass(Password);
   if (var_140 == true)
      {
      Alert("Incorrect Password");
      }
         else
      {
      FH = FileOpen("pf.csv",FILE_WRITE,8);
      if (FH < 1)
         {
         Print("Cannot open password cache!");
         return(0);
         }
      FileWrite(FH,Password);
      FileClose(FH);
      return(0);
      }
   }
      else
   {
   string psw = FileReadString(FH);
   FileClose(FH);
   var_140 = chkPass(psw);
   if (var_140 == true)
      {
      var_140 = chkPass(Password);
      if (var_140 == true)
         {
         Alert("Password has expired, please input new password");
         FileDelete("pf.csv");
         }
      }
   }*/
}

//+------------------------------------------------------------------+

int deinit()
{
ObjectsDeleteAll(var_212);
return(0);
}

//+------------------------------------------------------------------+

void moveToFront(int limit)
{
int    var_moveToFront_4;
int    time1;
int    time2;
int    shift1;
int    shift2;
int    var_moveToFront_24;
int    i;
int    j;
int    k;

var_moveToFront_4 = var_200;
for (i = 0; i <= var_180; i++)
   {
   time1 = ObjectGet("BodyX" + var_212 + "_" + i,OBJPROP_TIME1);
   time2 = ObjectGet("BodyX" + var_212 + "_" + i,OBJPROP_TIME2);
   shift1 = iBarShift(NULL,0,time1);
   shift2 = iBarShift(NULL,0,time2);
   ObjectSet("BodyX" + var_212 + "_" + i,OBJPROP_TIME1,iTime(NULL,0,shift1 - var_moveToFront_4));
   ObjectSet("BodyX" + var_212 + "_" + i,OBJPROP_TIME2,iTime(NULL,0,shift2 - var_moveToFront_4));
   ObjectSet("BodyXO" + var_212 + "_" + i,OBJPROP_TIME1,iTime(NULL,0,shift1 - var_moveToFront_4));
   ObjectSet("BodyXO" + var_212 + "_" + i,OBJPROP_TIME2,iTime(NULL,0,shift2 - var_moveToFront_4));
   if ((iTime(NULL,0,shift1 - var_moveToFront_4) == 0) || (iTime(NULL,0,shift2 - var_moveToFront_4) == 0)) var_292 = true;
   }

for (j = var_284; j >= 0; j--)
   {
   time1 = ObjectGet("ArrowShort_" + var_212 + "_" + j,OBJPROP_TIME1);
   time2 = ObjectGet("ArrowLong_" + var_212 + "_" + j,OBJPROP_TIME1);
   shift1 = iBarShift(NULL,0,time1);
   shift2 = iBarShift(NULL,0,time2);
   ObjectSet("ArrowShort_" + var_212 + "_" + j,OBJPROP_TIME1,iTime(NULL,0,shift1 - 1));
   ObjectSet("ArrowLong_" + var_212 + "_" + j,OBJPROP_TIME1,iTime(NULL,0,shift2 - 1));
   if ((iTime(NULL,0,shift1 - 1) == 0) || (iTime(NULL,0,shift2 - 1) == 0)) var_292 = true;
   Print("Current Coord Long : ",time1);
   Print("Current Coord Short : ",time2);
   }

var_moveToFront_24 = 0;
if (var_196)
   {
   var_196 = false;
   var_208 = limit - var_176;
   for (k = var_176; k <= limit; k++)
      {
      arr_184[var_moveToFront_24] = arr_184[k];
      var_moveToFront_24++;
      }
   }
}

//+------------------------------------------------------------------+

void moveAllBack()
{
int var_moveAllBack_0;
int time1;
int time2;
int shift1;
int shift2;
int var_moveAllBack_20;
int i;
int j;

var_moveAllBack_0 = var_200;
for (i = var_180; i >= 0; i--)
   {
   time1 = ObjectGet("BodyX" + var_212 + "_" + i,OBJPROP_TIME1);
   time2 = ObjectGet("BodyX" + var_212 + "_" + i,OBJPROP_TIME2);
   shift1 = iBarShift(NULL,0,time1);
   shift2 = iBarShift(NULL,0,time2);
   ObjectSet("BodyX" + var_212 + "_" + i,OBJPROP_TIME1,iTime(NULL,0,shift1 + 1));
   ObjectSet("BodyX" + var_212 + "_" + i,OBJPROP_TIME2,iTime(NULL,0,shift2 + 1));
   ObjectSet("BodyXO" + var_212 + "_" + i,OBJPROP_TIME1,iTime(NULL,0,shift1 + 1));
   ObjectSet("BodyXO" + var_212 + "_" + i,OBJPROP_TIME2,iTime(NULL,0,shift2 + 1));
   if ((iTime(NULL,0,shift1 + 1) == 0) || (iTime(NULL,0,shift2 + 1) == 0)) var_292 = true;
   }

for (j = var_208; j >= 0; j--)
   {
   arr_184[j + 1] = arr_184[j];
   arr_260[j + 1] = arr_260[j];
   arr_264[j + 1] = arr_264[j];
   arr_272[j + 1] = arr_272[j];
   arr_276[j + 1] = arr_276[j];
   arr_236[j + 1] = arr_236[j];
   arr_240[j + 1] = arr_240[j];
   }

arr_260[0] = EMPTY_VALUE;
arr_264[0] = EMPTY_VALUE;
arr_268[0] = EMPTY_VALUE;
arr_272[0] = EMPTY_VALUE;
arr_276[0] = EMPTY_VALUE;
}

//+------------------------------------------------------------------+

int drawNewX(double price, int shift)
{
if (var_176 < 0) var_176 = 0;

ObjectCreate("BodyXO" + var_212 + "_" + var_180,OBJ_RECTANGLE,var_212,Time[var_176],price,Time[var_176 + 1],price + (gdXecn*boxValue) * Point);
ObjectSet("BodyXO" + var_212 + "_" + var_180,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("BodyXO" + var_212 + "_" + var_180,OBJPROP_BACK,1);
ObjectSet("BodyXO" + var_212 + "_" + var_180,OBJPROP_COLOR,ColorUp);
ObjectCreate("BodyX" + var_212 + "_" + var_180,OBJ_RECTANGLE,var_212,Time[var_176],price,Time[var_176 + 1],price + (gdXecn*boxValue) * Point);
ObjectSet("BodyX" + var_212 + "_" + var_180,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("BodyX" + var_212 + "_" + var_180,OBJPROP_BACK,0);
ObjectSet("BodyX" + var_212 + "_" + var_180,OBJPROP_COLOR,Blue);
var_180++;
}

//+------------------------------------------------------------------+

int drawNewO(double price, int shift)
{
if (var_176 < 0) var_176 = 0;

ObjectCreate("BodyXO" + var_212 + "_" + var_180,OBJ_RECTANGLE,var_212,Time[var_176],price,Time[var_176 + 1],price - (gdXecn*boxValue) * Point);
ObjectSet("BodyXO" + var_212 + "_" + var_180,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("BodyXO" + var_212 + "_" + var_180,OBJPROP_BACK,1);
ObjectSet("BodyXO" + var_212 + "_" + var_180,OBJPROP_COLOR,ColorDown);
ObjectCreate("BodyX" + var_212 + "_" + var_180,OBJ_RECTANGLE,var_212,Time[var_176],price,Time[var_176 + 1],price - (gdXecn*boxValue) * Point);
ObjectSet("BodyX" + var_212 + "_" + var_180,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("BodyX" + var_212 + "_" + var_180,OBJPROP_BACK,0);
ObjectSet("BodyX" + var_212 + "_" + var_180,OBJPROP_COLOR,Blue);
var_180++;
}

//+------------------------------------------------------------------+

int doReversal(int code, int shift)
{
double price;

if (var_176 < 0) var_176 = 0;

if (code == 0)
   {
   if (shift == 0) price = Bid; else price = High[shift];
   while (price > var_156 + (gdXecn*boxValue) * Point)
      {
      drawNewX(var_156,shift);
      var_156 = var_156 + (gdXecn*boxValue) * Point;
      arr_184[var_176] = var_156;
      }
   }

if (code == 1)
   {
   if (shift == 0) price = Bid; else price = Low[shift];
   while (price < var_156 - (gdXecn*boxValue) * Point)
      {
      var_156 = var_156 - (gdXecn*boxValue) * Point;
      drawNewO(var_156,shift);
      arr_184[var_176] = var_156;
      }
   }
}

//+------------------------------------------------------------------+

int start()
{
int    counted_bars;
double var_start_4;
int    var_start_12;
int    var_start_16;
int    var_start_20;
int    var_start_24;
int    var_start_28;
int    limit;
int    i;
int    j;
double var_start_44;
double var_start_52;
double var_start_60;
int    k;

//if (var_140) return(0);

counted_bars = IndicatorCounted();
var_start_4 = (gdXecn*boxValue) * Point;
var_start_28 = 0;

limit = Bars - counted_bars;
if (limit > 0) limit--;
if (limit < 0) limit = 0;

var_212 = WindowFind("Point and Figure (" + boxValue + "," + Multiply + ") | ForexImpact.com");
if (var_212 == -1)
   {
   Alert("Can not select window with name \"Point and Figure (\"" + boxValue + "," + Multiply + ")\"! ");
   var_140 = true;
   return(0);
   }

if (var_196)
   {
   ObjectsDeleteAll(var_212);
   ObjectCreate("priceLine_" + var_212,OBJ_HLINE,var_212,0,Time[0],0,0);
   ObjectSet("priceLine_" + var_212,OBJPROP_PRICE1,Bid);
   ObjectSet("priceLine_" + var_212,OBJPROP_COLOR,PriceLevel);
   }

if (!var_196)
   {
   var_176 = 0;
   ObjectSet("priceLine_" + var_212,OBJPROP_PRICE1,Bid);
   if (var_292)
      {
      var_292 = false;
      var_288 = Bars - 5;
      }
   if ((MathAbs(var_288 - Bars) >= 2) && (var_204 > 0))
      {
      var_288 = Bars;
      Print("More than one bar fed to indicator -- ",Symbol());
      Print("Reloading indicator -- ",Symbol());
      ObjectsDeleteAll(var_212);
      ArrayInitialize(arr_260,EMPTY_VALUE);
      ArrayInitialize(arr_264,EMPTY_VALUE);
      ArrayInitialize(arr_268,EMPTY_VALUE);
      ArrayInitialize(arr_272,EMPTY_VALUE);
      ArrayInitialize(arr_276,EMPTY_VALUE);
      ArrayInitialize(arr_280,EMPTY_VALUE);
      ArrayInitialize(arr_236,EMPTY_VALUE);
      ArrayInitialize(arr_240,EMPTY_VALUE);
      limit = Bars - 1;
      ObjectCreate("priceLine_" + var_212,OBJ_HLINE,var_212,0,Time[0],0,0);
      ObjectSet("priceLine_" + var_212,OBJPROP_PRICE1,Bid);
      ObjectSet("priceLine_" + var_212,OBJPROP_COLOR,PriceLevel);
      var_172 = 0;
      var_144 = true;
      var_188 = 0;
      var_196 = true;
      }
         else
      {
      if (var_204 != Bars)
         {
         for (i = 1; i <= var_208; i++)
            {
            arr_184[i - 1] = arr_184[i];
            arr_260[i - 1] = arr_260[i];
            arr_264[i - 1] = arr_264[i];
            arr_272[i - 1] = arr_272[i];
            arr_276[i - 1] = arr_276[i];
            arr_236[i - 1] = arr_236[i];
            arr_240[i - 1] = arr_240[i];
            }
         var_204 = Bars;
         var_200 = 1;
         moveToFront(limit);
         }
      }
   }

var_288 = Bars;

for (j = limit; j >= 0; j--)
   {
   if (var_144)
      {
      if (Open[j] > Close[j])
         {
         var_156 = High[j];
         var_148 = false;
         var_152 = true;
         var_176 = iBarShift(Symbol(),0,Time[j]);
         }
      if (Open[j] < Close[j])
         {
         var_156 = Low[j];
         var_148 = true;
         var_152 = false;
         var_176 = iBarShift(Symbol(),0,Time[j]);
         }
      if (Open[j] == Close[j]) continue;
      var_144 = false;
      }
   if (Time[j] > var_172)
      {
      var_164 = var_156;
      var_172 = Time[j];
      }
   if (var_148)
      {
      if (j == 0) var_244 = Bid; else var_244 = High[j];
      while (var_244 >= var_156 + var_start_4)
         {
         drawNewX(var_156,j);
         var_156 = var_156 + var_start_4;
         arr_184[var_176] = var_156;
         }
      if (j == 0)
         {
         var_252 = var_156;
         var_244 = Bid;
         }
            else
         {
         var_252 = var_164;
         var_244 = Low[j];
         }
      if (var_252 - var_start_4 * Multiply >= var_244)
         {
         if (var_176 != 0) var_176--;
         if (!var_196)
            {
            var_208++;
            moveAllBack();
            }
         doReversal(1,j);
         var_148 = false;
         var_152 = true;
         continue;
         }
      }
   if (var_152)
      {
      if (j == 0) var_244 = Bid; else var_244 = Low[j];
      while (var_244 <= var_156 - var_start_4)
         {
         var_156 = var_156 - var_start_4;
         drawNewO(var_156,j);
         arr_184[var_176] = var_156;
         }
      if (j == 0)
         {
         var_252 = var_156;
         var_244 = Bid;
         }
            else
         {
         var_252 = var_164;
         var_244 = High[j];
         }
      if (var_252 + var_start_4 * Multiply <= var_244)
         {
         if (var_176 != 0) var_176--;
         if (!var_196)
            {
            var_208++;
            moveAllBack();
            }
         doReversal(0,j);
         var_148 = true;
         var_152 = false;
         }
      }
   }

if (var_196)
   {
   var_200 = var_176;
   var_204 = Bars;
   moveToFront(limit);
   if (ShowGrid)
      {
      var_start_44 = High[iHighest(NULL,0,MODE_HIGH,0,0)];
      var_start_52 = Low[iLowest(NULL,0,MODE_LOW,0,0)];
      var_start_60 = var_start_52 - (gdXecn*boxValue) * 4 * Point * 3.0;
      for (k = (var_start_44 - var_start_52) / Point / ((gdXecn*boxValue) * 4) + 6.0; k >= 0; k--)
         {
         ObjectCreate("GridLine_" + k + "_" + var_212,OBJ_HLINE,var_212,0,0,0,0);
         ObjectSet("GridLine_" + k + "_" + var_212,OBJPROP_PRICE1,var_start_60);
         ObjectSet("GridLine_" + k + "_" + var_212,OBJPROP_STYLE,STYLE_DOT);
         ObjectSet("GridLine_" + k + "_" + var_212,OBJPROP_COLOR,GridColor);
         var_start_60 = var_start_60 + (gdXecn*boxValue) * 4 * Point;
         }
      }
   createHighLow(1);
   }
      else
   {
   createHighLow(0);
   if (var_232 != 0)
      {
      switch (var_232)
         {
         case 1:
            if (arr_260[0] != EMPTY_VALUE)
               {
               if (arr_184[0] > arr_260[0]) doArrows("Triple Top",Ask);
               }
                  else
               {
               var_232 = 0;
               }
            break;
         case 3:
            if (arr_264[0] != EMPTY_VALUE)
               {
               if (arr_184[0] > arr_264[0]) doArrows("Spread Triple Top",Ask);
               }
                  else
               {
               var_232 = 0;
               }
            break;
         case 5:
            if (arr_264[0] != EMPTY_VALUE)
               {
               if (arr_184[0] > arr_264[0]) doArrows("Bullish Resistance",Ask);
               }
                  else
               {
               var_232 = 0;
               }
            break;
         case 7:
            if (arr_264[0] != EMPTY_VALUE)
               {
               if (arr_184[0] > arr_264[0]) doArrows("Bullish Resistance",Ask);
               }
                  else
               {
               var_232 = 0;
               }
            break;
         case 9:
            if (arr_260[0] != EMPTY_VALUE)
               {
               if (arr_184[0] > arr_260[0]) doArrows("Bullish Catapault",Ask);
               }
                  else
               {
               var_232 = 0;
               }
            break;
         case 12:
            if (arr_260[0] != EMPTY_VALUE)
               {
               if (arr_184[0] > arr_260[0]) doArrows("Ascending Triangle",Ask);
               }
                  else
               {
               var_232 = 0;
               }
            break;
         case 14:
            if (arr_260[0] != EMPTY_VALUE)
               {
               if (arr_184[0] > arr_260[0]) doArrows("Ascending Triple Top",Ask);
               }
                  else
               {
               var_232 = 0;
               }
         }
      }
   if (var_228 != 0)
      {
      switch (var_228)
         {
         case 2:
            if (arr_272[0] != EMPTY_VALUE)
               {
               if (arr_184[0] <= arr_272[0]) doArrows("Triple Bottom",Bid);
               }
                  else
               {
               var_228 = 0;
               }
            break;
         case 4:
            if (arr_276[0] != EMPTY_VALUE)
               {
               if (arr_184[0] <= arr_276[0]) doArrows("Spread Triple Bottom",Bid);
               }
                  else
               {
               var_228 = 0;
               }
            break;
         case 6:
            if (arr_276[0] != EMPTY_VALUE)
               {
               if (arr_184[0] <= arr_276[0]) doArrows("Bearish Support",Bid);
               }
                  else
               {
               var_228 = 0;
               }
            break;
         case 8:
            if (arr_276[0] != EMPTY_VALUE)
               {
               if (arr_184[0] <= arr_276[0]) doArrows("Bullish Support",Bid);
               }
                  else
               {
               var_228 = 0;
               }
            break;
         case 10:
            if (arr_272[0] != EMPTY_VALUE)
               {
               if (arr_184[0] <= arr_272[0]) doArrows("Bearish Catapault",Bid);
               }
                  else
               {
               var_228 = 0;
               }
            break;
         case 13:
            if (arr_272[0] != EMPTY_VALUE)
               {
               if (arr_184[0] <= arr_272[0]) doArrows("Decending Triangle",Bid);
               }
                  else
               {
               var_228 = 0;
               }
            break;
         case 15:
            if (arr_272[0] != EMPTY_VALUE)
               {
               if (arr_184[0] <= arr_272[0]) doArrows("Decending Triple Bottom",Bid);
               }
                  else
               {
               var_228 = 0;
               }
         }
      }
   }
}

//+------------------------------------------------------------------+

/*string dcrypt(int index)
{
string array[20] = {"ywjsi","qfl","rfwpjyk}","xnlsfqx","hyunux","ktrh","nskqfynts","hfww~","wj{jwxfq","nsyjwjxy","rtsj~","ymjhfgqj","~jsk}","ltfqx","xmfwuy","stskfwr","wnxpqt|","wjyfnqx",""};
int    length = StringLen(array[index]);
int    i;
int    char;

for (i = 0; i < length; i++)
   {
   char = StringGetChar(array[index],i);
   char -= 5;
   array[index] = StringSetChar(array[index],i,char);
   }
return(array[index]);
}*/

//+------------------------------------------------------------------+
/*
bool chkPass(string code)
{
int    var_chkPass_8 = D'2007.12.31';
int    var_chkPass_12 = D'2008.03.31';
int    var_chkPass_16 = D'2008.06.30';
int    var_chkPass_20 = D'2008.09.30';
int    var_chkPass_24 = D'2008.12.31';
int    var_chkPass_28 = D'2009.03.31';
int    var_chkPass_32 = D'2009.06.30';
int    var_chkPass_36 = D'2009.09.30';
int    var_chkPass_40 = D'2009.12.31';
int    var_chkPass_44 = D'2010.03.31';
int    var_chkPass_48 = D'2010.06.30';
int    var_chkPass_52 = D'2010.09.30';
int    var_chkPass_56 = D'2010.12.31';
int    var_chkPass_60 = D'2011.03.31';
int    var_chkPass_64 = D'2011.06.30';
int    var_chkPass_68 = D'2011.09.30';
int    var_chkPass_72 = D'2011.12.31';
int    var_chkPass_76 = D'2012.03.31';
string var_chkPass_80;

if (TimeCurrent() <= var_chkPass_8)
   {
   var_chkPass_80 = dcrypt(0);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_12)
   {
   var_chkPass_80 = dcrypt(1);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_16)
   {
   var_chkPass_80 = dcrypt(2);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_20)
   {
   var_chkPass_80 = dcrypt(3);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_24)
   {
   var_chkPass_80 = dcrypt(4);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_28)
   {
   var_chkPass_80 = dcrypt(5);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_32)
   {
   var_chkPass_80 = dcrypt(6);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_36)
   {
   var_chkPass_80 = dcrypt(7);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_40)
   {
   var_chkPass_80 = dcrypt(8);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_44)
   {
   var_chkPass_80 = dcrypt(9);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_48)
   {
   var_chkPass_80 = dcrypt(10);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_52)
   {
   var_chkPass_80 = dcrypt(11);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_56)
   {
   var_chkPass_80 = dcrypt(12);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_60)
   {
   var_chkPass_80 = dcrypt(13);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_64)
   {
   var_chkPass_80 = dcrypt(14);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_68)
   {
   var_chkPass_80 = dcrypt(15);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_72)
   {
   var_chkPass_80 = dcrypt(16);
   if (code == var_chkPass_80) return(false);
   return(true);
   }

if (TimeCurrent() <= var_chkPass_76)
   {
   var_chkPass_80 = dcrypt(17);
   if (code == var_chkPass_80) return(false);
   return(true);
   }
return(true);
}*/