SweetSpots GOLD
Download scriptThe SweetSpots indicator is designed to provide visual structure to your trading charts by automatically mapping out significant price levels. Rather than cluttering the screen with every possible price point, it identifies "sweet spots"—specific intervals that help traders visualize key zones of interest.
Core Functionality
The tool scans the current market price and projects a series of horizontal lines across your chart. These lines act as visual anchors, representing consistent pip increments. By identifying these levels automatically, the indicator helps traders maintain a sense of scale and perspective on price movement.
How the Logic Works
The script operates based on three primary layers of hierarchy:
- Primary Levels (Main Sweet Spots): The indicator identifies major milestones based on a primary interval (defaulting to 100 pips). These are treated as significant anchors on the chart.
- Sub-Levels: To provide more granularity, the script populates the space between the main levels with secondary markers (defaulting to every 50 pips). This allows you to see the "path" between major milestones without overwhelming the display.
- Dynamic Visual Emphasis: Not all lines are treated equally. The logic automatically adjusts the visual thickness of the lines based on their importance:
- Standard Sub-Levels: Thin, dotted lines for frequent price increments.
- Major Sweet Spots: Solid lines that stand out more clearly.
- Significant Milestones: As the price reaches even larger intervals (multiples of 10x and 100x the base level), the script increases the line thickness to highlight these as high-priority zones.
Performance and Behavior
To ensure your trading platform remains responsive, the script is programmed with an optimization cycle. It does not redraw every single time the price moves; instead, it updates at scheduled intervals (every 10 minutes) or when necessary. Additionally, it includes a cleanup routine that ensures old markers are removed and replaced cleanly by new ones, keeping your chart organized and free of "ghost" lines from previous price action.
Summary for the Trader
In short, this tool acts as a sophisticated visual grid. It automatically distinguishes between minor price movements and major structural levels by varying the color, style, and thickness of horizontal lines. This allows you to see at a glance where you are in relation to both immediate "sub-spots" and larger, more significant "sweet spots" in the market.
//+------------------------------------------------------------------+
//| SweetSpots.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright Shimodax"
#property link "http://www.strategybuilderfx.com"
#property indicator_chart_window
/* Introduction:
This indicator shows lines at sweet spots (50 and 100
pips levels). It is recommended to turn off the grid.
Enjoy!
Markus
*/
extern int NumLinesAboveBelow= 100;
extern int SweetSpotMainLevels= 100;
extern color LineColorMain= Blue;
extern int LineStyleMain= STYLE_SOLID;
extern bool ShowSubLevels= true;
extern int sublevels= 50;
extern color LineColorSub= Blue;
extern int LineStyleSub= STYLE_DOT;
//+------------------------------------------------------------------+
//| 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);
deinit(); // delete all previous lines
int i, ssp1, style, ssp, thickness; //sublevels= 50;
double ds1;
color linecolor;
if (!ShowSubLevels)
sublevels*= 2;
ssp1= Bid / Point;
ssp1= ssp1 - ssp1%sublevels;
for (i= -NumLinesAboveBelow; i<NumLinesAboveBelow; i++) {
ssp= ssp1+(i*sublevels);
if (ssp%SweetSpotMainLevels==0) {
style= LineStyleMain;
linecolor= LineColorMain;
}
else {
style= LineStyleSub;
linecolor= LineColorSub;
}
thickness= 1;
if (ssp%(SweetSpotMainLevels*10)==0) {
thickness= 2;
}
if (ssp%(SweetSpotMainLevels*100)==0) {
thickness= 3;
}
ds1= ssp*Point;
SetLevel(DoubleToStr(ds1,Digits), ds1, linecolor, style, thickness, Time[10]);
}
return(0);
}
//+------------------------------------------------------------------+
//| Helper |
//+------------------------------------------------------------------+
void SetLevel(string text, double level, color col1, int linestyle, int thickness, 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);
ObjectSet(linename, OBJPROP_WIDTH, thickness);
ObjectSet(linename, OBJPROP_BACK, True);
}
else {
ObjectMove(linename, 0, Time[0], level);
}
}
Comments