Sweet Spot Finder v3.4

Sweet Spot Finder v3.4

This script is a multi-layered technical analysis tool designed to identify potential "Sweet Spots" in market price action. It works by identifying specific structural peaks and valleys (known as fractals) across four different time horizons simultaneously.

Core Logic Overview

The primary purpose of this script is to monitor the market for reversals or significant price shifts. Instead of looking at just one speed of price movement, it scans the charts using four distinct "Ranges":

  1. Extra Short-Range: Captures very rapid, immediate price fluctuations.
  2. Short-Range: Identifies more immediate trends.
  3. Medium-Range: Tracks established intermediate movements.
  4. Long-Range: Observes the broader, overarching market structure.

How the Detection Works

The script uses a "Fractal" detection logic to determine where these signals appear:

  • Peak Identification (Sell Signals): The tool looks for high points in price. If a specific candle's high is higher than its neighbors within a defined period, it marks a potential "Sell" or "Exit Buy" point.
  • Valley Identification (Buy Signals): Conversely, it looks for low points. If a candle's low is lower than the surrounding candles within a specific range, it marks a potential "Buy" or "Exit Sell" point.
  • Displacement & Sensitivity: The script includes a "Displacement" factor which adjusts the visual placement of the signal based on the current spread (the difference between the Bid and Ask prices), ensuring the signals are positioned accurately relative to real-time trading costs.

Visual and Notification System

The script provides immediate feedback to the user through several layers of alerts:

  • On-Chart Visuals: It draws different colored arrows on your chart to distinguish between the four ranges. Each range has its own dedicated color (e.g., Red, Green, Yellow, and Blue), allowing you to see at a glance whether a signal is happening on a micro, medium, or macro scale.
  • Pop-up Alerts: When a signal is detected, the script triggers an on-screen alert window providing a clear text description of the signal type (e.g., "Medium-Range Signal: SELL").
  • Email Notifications: If enabled, the script can send these alerts directly to your email, ensuring you are notified of market changes even if you aren't looking at the screen.
  • Dynamic Comments: It updates a text comment on the chart area, summarizing the most recent signals detected across all active ranges.

Summary for the User

In essence, this tool acts as a comprehensive "scout." It scans the market at various speeds to tell you when price action is hitting a structural limit. By showing you both the immediate "noise" of the market and the broader "flow," it helps traders identify potential entry or exit points based on different trading styles—from scalping (short-range) to swing trading (long-range).

Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt sends emails
9 Views
0 Downloads
0 Favorites
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);
}

Comments