Sweet Spot Finder v3.4





/*
   Generated by forexlion decompiler
*/

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 OrangeRed
#property indicator_color2 OrangeRed
#property indicator_color3 Lime
#property indicator_color4 Lime
#property indicator_color5 Yellow
#property indicator_color6 Yellow
#property indicator_color7 DodgerBlue
#property indicator_color8 DodgerBlue

extern bool XShortRange = TRUE;
extern int XShortPeriod = 10;
extern bool ShortRange = TRUE;
extern int ShortPeriod = 20;
extern bool MediumRange = TRUE;
extern int MediumPeriod = 40;
extern bool LongRange = TRUE;
extern int LongPeriod = 80;
extern double Displacement = 1.0;
extern bool AlertMode = TRUE;
extern int Compensation = 0;
extern int Sensitivity = 1;
extern bool MailAlert = FALSE;
double g_ibuf_132[];
double g_ibuf_136[];
double g_ibuf_140[];
double g_ibuf_144[];
double g_ibuf_148[];
double g_ibuf_152[];
double g_ibuf_156[];
double g_ibuf_160[];
int gi_164 = 0;
int gi_168 = 0;
int gi_172 = 0;
int gi_176 = 0;
bool gi_180 = TRUE;

int init() {
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 234);
   SetIndexBuffer(0, g_ibuf_132);
   SetIndexEmptyValue(0, 0.0);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 233);
   SetIndexBuffer(1, g_ibuf_136);
   SetIndexEmptyValue(1, 0.0);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, 234);
   SetIndexBuffer(2, g_ibuf_140);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(3, 233);
   SetIndexBuffer(3, g_ibuf_144);
   SetIndexEmptyValue(3, 0.0);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(4, 234);
   SetIndexBuffer(4, g_ibuf_148);
   SetIndexEmptyValue(4, 0.0);
   SetIndexStyle(5, DRAW_ARROW);
   SetIndexArrow(5, 233);
   SetIndexBuffer(5, g_ibuf_152);
   SetIndexEmptyValue(5, 0.0);
   SetIndexStyle(6, DRAW_ARROW);
   SetIndexArrow(6, 234);
   SetIndexBuffer(6, g_ibuf_156);
   SetIndexEmptyValue(6, 0.0);
   SetIndexStyle(7, DRAW_ARROW);
   SetIndexArrow(7, 233);
   SetIndexBuffer(7, g_ibuf_160);
   SetIndexEmptyValue(7, 0.0);
   Comment("");
   return (0);
}

int deinit() {
   return (0);
}

int Fractal(string as_0, int ai_8 = 0, int ai_12 = 0) {
   for (int li_16 = Sensitivity; li_16 <= ai_8; li_16++) {
      if (as_0 == "High") {
         if (High[ai_12 + li_16] > High[ai_12] - Compensation * Point) return (-1);
         if (High[ai_12 - li_16] > High[ai_12] - Compensation * Point) return (-1);
      }
      if (as_0 == "Low") {
         if (Low[ai_12 + li_16] < Low[ai_12] + Compensation * Point) return (-1);
         if (Low[ai_12 - li_16] < Low[ai_12] + Compensation * Point) return (-1);
      }
   }
   return (1);
}

int start() {
   string ls_unused_132;
   string ls_unused_140;
   string ls_12 = "";
   string ls_unused_20 = "";
   string ls_28 = "";
   string ls_36 = "";
   string ls_44 = "";
   string ls_52 = "";
   string ls_60 = "";
   string ls_68 = "";
   string ls_76 = "";
   string ls_84 = "";
   string ls_92 = "SIGNAL: Sweet Spot SELL / Exit BUY for " + Symbol() + " M" + Period() + ".";
   string ls_100 = "SIGNAL: Sweet Spot BUY / Exit SELL for " + Symbol() + " M" + Period() + ".";
   bool li_108 = FALSE;
   bool li_112 = FALSE;
   bool li_116 = FALSE;
   bool li_120 = FALSE;
   bool li_124 = FALSE;
   RefreshRates();
   if (!gi_180) {
      li_108 = gi_164;
      li_112 = gi_168;
      li_116 = gi_172;
      li_120 = gi_176;
   }
   int l_bars_0 = Bars;
   double ld_4 = Displacement * (Ask - Bid);
   for (int li_128 = l_bars_0; li_128 > 0; li_128--) {
      if (Fractal("High", XShortPeriod, li_128) == 1 && XShortRange) g_ibuf_132[li_128] = High[li_128] + ld_4;
      else g_ibuf_132[li_128] = 0;
      if (Fractal("Low", XShortPeriod, li_128) == 1 && XShortRange) g_ibuf_136[li_128] = Low[li_128] - ld_4;
      else g_ibuf_136[li_128] = 0;
      if (Fractal("High", XShortPeriod, li_128) == 1 && XShortRange && AlertMode) {
         gi_164 = 1;
         ls_28 = ls_92;
         ls_60 = "EXTRA SHORT-RANGE SIGNAL (Red Arrows): SELL / Exit BUY";
      }
      if (Fractal("Low", XShortPeriod, li_128) == 1 && XShortRange && AlertMode) {
         gi_164 = 2;
         ls_28 = ls_100;
         ls_60 = "EXTRA SHORT-RANGE SIGNAL (Red Arrows): BUY / Exit SELL";
      }
      if (Fractal("High", ShortPeriod, li_128) == 1 && ShortRange) g_ibuf_140[li_128] = High[li_128] + ld_4;
      else g_ibuf_140[li_128] = 0;
      if (Fractal("Low", ShortPeriod, li_128) == 1 && ShortRange) g_ibuf_144[li_128] = Low[li_128] - ld_4;
      else g_ibuf_144[li_128] = 0;
      if (Fractal("High", ShortPeriod, li_128) == 1 && ShortRange && AlertMode) {
         gi_168 = 1;
         ls_36 = ls_92;
         ls_68 = "SHORT-RANGE SIGNAL (Green Arrows): SELL / Exit BUY";
      }
      if (Fractal("Low", ShortPeriod, li_128) == 1 && ShortRange && AlertMode) {
         gi_168 = 2;
         ls_36 = ls_100;
         ls_68 = "SHORT-RANGE SIGNAL (Green Arrows): BUY / Exit SELL";
      }
      if (Fractal("High", MediumPeriod, li_128) == 1 && MediumRange) g_ibuf_148[li_128] = High[li_128] + ld_4;
      else g_ibuf_148[li_128] = 0;
      if (Fractal("Low", MediumPeriod, li_128) == 1 && MediumRange) g_ibuf_152[li_128] = Low[li_128] - ld_4;
      else g_ibuf_152[li_128] = 0;
      if (Fractal("High", MediumPeriod, li_128) == 1 && MediumRange && AlertMode) {
         gi_172 = 1;
         ls_44 = ls_92;
         ls_76 = "MEDIUM-RANGE SIGNAL (Yellow Arrows): SELL / Exit BUY";
      }
      if (Fractal("Low", MediumPeriod, li_128) == 1 && MediumRange && AlertMode) {
         gi_172 = 2;
         ls_44 = ls_100;
         ls_76 = "MEDIUM-RANGE SIGNAL (Yellow Arrows): BUY / Exit SELL";
      }
      if (Fractal("High", LongPeriod, li_128) == 1 && LongRange) g_ibuf_156[li_128] = High[li_128] + ld_4;
      else g_ibuf_156[li_128] = 0;
      if (Fractal("Low", LongPeriod, li_128) == 1 && LongRange) g_ibuf_160[li_128] = Low[li_128] - ld_4;
      else g_ibuf_160[li_128] = 0;
      if (Fractal("High", LongPeriod, li_128) == 1 && LongRange && AlertMode) {
         gi_176 = 1;
         ls_52 = ls_92;
         ls_84 = "LONG-RANGE SIGNAL (Blue Arrows): SELL / Exit BUY";
      }
      if (Fractal("Low", LongPeriod, li_128) == 1 && LongRange && AlertMode) {
         gi_176 = 2;
         ls_52 = ls_100;
         ls_84 = "LONG-RANGE SIGNAL (Blue Arrows): BUY / Exit SELL";
      }
   }
   if (gi_180 || (!gi_180 && li_108 != gi_164 || li_112 != gi_168 || li_116 != gi_172 || li_120 != gi_176)) li_124 = TRUE;
   if (li_124) {
      if (AlertMode) {
         if (ls_60 != "" && XShortRange) Alert(ls_28);
         if (MailAlert) SendMail("SSF", Symbol() + " " + ls_60);
         ls_12 = ls_60;
         if (ls_68 != "" && ShortRange) {
            Alert(ls_36);
            if (MailAlert) SendMail("SSF", Symbol() + " " + ls_68);
            if (ls_12 != "") {
               ls_12 = ls_12 
                  + "\n" 
               + ls_68;
            } else ls_12 = ls_68;
         }
         if (ls_76 != "" && MediumRange) {
            Alert(ls_44);
            if (MailAlert) SendMail("SSF", Symbol() + " " + ls_76);
            if (ls_12 != "") {
               ls_12 = ls_12 
                  + "\n" 
               + ls_76;
            } else ls_12 = ls_76;
         }
         if (ls_84 != "" && LongRange) {
            Alert(ls_52);
            if (MailAlert) SendMail("SSF", Symbol() + " " + ls_84);
            if (ls_12 != "") {
               ls_12 = ls_12 
                  + "\n" 
               + ls_84;
            } else ls_12 = ls_84;
         }
         Comment(ls_12);
      }
      gi_180 = FALSE;
   }
   return (0);
}



Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_ARROW


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features:

It issuies visual alerts to the screen
It sends emails