SDX-SweetSpots1_v1

Download script
Author: Copyright Shimodax
SDX-SweetSpots1_v1

This tool is designed to provide traders with a clear visual grid of significant price levels directly on their trading charts. Instead of cluttering the screen with random data, it automatically identifies and draws horizontal "Sweet Spot" lines based on fixed mathematical intervals.

How the Logic Works

Dynamic Price Grid Generation The script looks at the current live market price and calculates a base reference point. From this point, it generates a series of horizontal lines extending both above and below the current price. The spacing between these lines is consistent, creating a structured map of the market's environment.

Visual Hierarchy & Organization To help traders distinguish between different types of levels at a glance, the script uses two distinct visual styles:

  • Primary Levels: Every 100 units, the tool draws a solid, prominent line. These represent major milestones or "anchor" prices.
  • Secondary Levels: The spaces between those major milestones are filled with dotted lines (every 50 units), representing smaller sub-intervals.

Automated Maintenance The script is built to be "set and forget." It handles the heavy lifting of the following:

  • Automatic Placement: As the market moves, the tool keeps the grid relevant by ensuring the lines are positioned correctly relative to the current price.
  • Clean Workspace: When you remove the indicator from your chart, the script automatically clears all "Sweet Spot" lines it created, leaving your workspace clean.
  • Efficiency: The logic is optimized to update only when necessary, ensuring that the tool provides a smooth experience without slowing down your trading platform.

Key Takeaways for the Trader

This script serves as a structural guide for your chart. By highlighting these specific mathematical intervals, it allows you to see the "geography" of the price action more clearly, making it easier to identify where significant price movements might occur or where levels of support and resistance may cluster.

13 Views
0 Downloads
0 Favorites
SDX-SweetSpots1_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                   SweetSpots.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright Shimodax"
#property link      "http://www.strategybuilderfx.com"

#property indicator_chart_window


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;
   
   ssp1= Bid / Point;
   ssp1= ssp1 - ssp1%50;

   for (i= -LinesAboveBelow; i<LinesAboveBelow; i++) {
      ssp= ssp1+(i*50); 
      
      if (ssp%100==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, Time[0], level);
   }
}
      

Comments