SDX-SweetSpots_Digit_Adjust

Download script
Author: Copyright Shimodax
SDX-SweetSpots_Digit_Adjust

Overview of the SweetSpots Indicator

The SweetSpots indicator is a specialized visual tool designed to help traders identify key price levels on their trading charts. Instead of cluttering the screen with every possible price point, it automatically calculates and draws horizontal lines at specific "milestones," allowing for a cleaner analysis of potential support and resistance zones.

How the Logic Works

The core objective of this script is to break down the current market price into organized increments, making it easier to spot where significant price action might occur. Here is a breakdown of the logic:

1. Dynamic Price Scaling The script first identifies the "precision" of your trading environment (whether your broker uses standard or high-precision digits). It then takes the current live market price and rounds it down to the nearest significant milestone. This ensures that the lines drawn are consistent and mathematically aligned with the currency pair's structure.

2. Milestone Generation Once the primary milestone is identified, the script automatically generates a series of surrounding levels. It projects these lines both above and below the current price:

  • Primary Milestones: These are highlighted using a solid line style and a distinct primary color. These represent major "round numbers" or significant structural points.
  • Secondary Milestones: The script also identifies smaller intermediate steps between the primary levels. These are represented by dotted lines and a secondary color, providing a more granular view of the price movement without overwhelming the visual display.

3. Automated Chart Management To keep your trading workspace organized, the script handles all the "heavy lifting" regarding chart maintenance:

  • Real-Time Updates: The indicator monitors price movements and automatically shifts the lines as the market moves, ensuring the grid is always relevant to current conditions.
  • Automatic Cleanup: When you remove the indicator from your chart, the script is programmed to automatically delete all the lines it created. This prevents "ghost" lines from remaining on your screen and keeps your history clean.

Summary of Benefits

By automating the identification of these price levels, the SweetSpots indicator helps traders:

  • Identify Key Zones: Quickly see where major price "walls" or "floors" are located.
  • Maintain Visual Clarity: Distinguish between major structural levels (solid lines) and minor intermediate steps (dotted lines) at a glance.
  • Save Time: Eliminate the need to manually draw horizontal lines, allowing you to focus on analyzing market trends rather than technical setup.
11 Views
0 Downloads
0 Favorites
SDX-SweetSpots_Digit_Adjust
//+------------------------------------------------------------------+
//|                                                   SweetSpots.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
//Digit adjustment code added by cja
#property copyright "Copyright Shimodax"
#property link      "http://www.strategybuilderfx.com"

#property indicator_chart_window

extern bool Six_Digits = false;
extern int LinesAboveBelow= 10;
extern color LineColorMain= LightGray;
extern color LineColorSub= Gray;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   return(0);
}

int deinit()
{
   int obj_total= ObjectsTotal();
   
   for (int i= obj_total; i>=0; i--) {
      string name= ObjectName(i);
    
      if (StringSubstr(name,0,11)=="[SweetSpot]") 
         ObjectDelete(name);
   }
   
   return(0);
}
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   static datetime timelastupdate= 0;
   static datetime lasttimeframe= 0;
   
    
   // no need to update these buggers too often   
   if (CurTime()-timelastupdate < 600 && Period()==lasttimeframe)
      return (0);
      
   int i, ssp1, style, ssp;
   double ds1;
   color linecolor;
   int Fifty,Hund;
   
   if(Six_Digits==true){Fifty=500;Hund=1000; }
   else {Fifty=50;Hund=100;}
   
   ssp1= Bid / Point;
   
   ssp1= ssp1 - ssp1%Fifty;

   for (i= -LinesAboveBelow; i<LinesAboveBelow; i++) {
      ssp= ssp1+(i*Fifty); 
      
      if (ssp%Hund==0) {
         style= STYLE_SOLID;
         linecolor= LineColorMain;
      }
      else {
         style= STYLE_DOT;
         linecolor= LineColorSub;
      }
      
      ds1= ssp*Point;
      SetLevel(DoubleToStr(ds1,Digits), ds1,  linecolor, style, Time[10]);
   
   
   }

   return(0);
}


//+------------------------------------------------------------------+
//| Helper                                                           |
//+------------------------------------------------------------------+
void SetLevel(string text, double level, color col1, int linestyle, datetime startofday)
{
   int digits= Digits;
   string linename= "[SweetSpot] " + text + " Line",
          pricelabel; 

   // create or move the horizontal line   
   if (ObjectFind(linename) != 0) {
      ObjectCreate(linename, OBJ_HLINE, 0, 0, level);
      ObjectSet(linename, OBJPROP_STYLE, linestyle);
      ObjectSet(linename, OBJPROP_COLOR, col1);
   }
   else {
      ObjectMove(linename, 0, 0, level);
   }
}
      

Comments