SDX-SweetSpots

Download script
Author: Copyright Shimodax
SDX-SweetSpots

This tool is designed to provide traders with a clear visual map of the price action by automatically identifying and drawing specific price "Sweet Spots" on your trading chart. Instead of requiring you to manually calculate key price levels, the script handles the mathematics for you, creating a structured grid that helps in identifying significant zones of interest.

How it Works

The logic follows a systematic approach to organize the market into organized intervals:

  • Dynamic Level Identification: The script looks at the current market price and rounds it down to the nearest increment of 50 points. This serves as the anchor for the entire grid.
  • Automated Grid Generation: From that anchor point, the script automatically projects a series of horizontal lines both above and below the current price. You can customize how many lines appear in each direction through the settings.
  • Visual Hierarchy: To make the chart easy to read at a glance, the script differentiates between different types of levels using visual styles:
    • Primary Levels: Every 100 points, the script draws a prominent solid line. These represent major milestones.
    • Secondary Levels: In the gaps between the primary levels (every 50 points), it draws dotted lines. These highlight the "Sweet Spots" between major price targets.
  • Efficiency & Performance: The script is designed to be "light." It doesn't redraw every single time the price moves; instead, it updates at set intervals to ensure your trading platform remains smooth and responsive while keeping the levels current.

Summary for Traders

Essentially, this tool acts as an automated ruler. It cleans up the visual clutter of a chart by highlighting recurring price milestones. By providing a consistent grid of solid and dotted lines, it allows you to see exactly where the market sits in relation to both major price boundaries and smaller, intermediate "sweet spots," aiding in better entry and exit planning.

14 Views
0 Downloads
0 Favorites
SDX-SweetSpots
//+------------------------------------------------------------------+
//|                                                   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, 0, level);
   }
}
      

Comments