Dinapoli_Red
Download scriptThis tool is designed to analyze price movements on a trading chart to identify specific structural turning points. Instead of looking at every minor fluctuation, the logic focuses on significant "swings"—the peaks and valleys that define the overall direction of the market.
How the Logic Works
1. Identifying Significant Swings The script scans past price data to determine the highest highs and lowest lows over a specific set period. It looks for "breakout" moments: when the price moves beyond the previous established range, it signals a change in market structure. These points are captured as significant anchors (swings) rather than random noise.
2. Tracking Market Structure The system keeps a history of these identified swings. By tracking where these highs and lows occur, it creates a map of the market's "memory." It distinguishes between different types of movements, specifically focusing on:
- Upward movements: Identifying the highest points reached during a bullish trend.
- Downward movements: Identifying the lowest points reached during a bearish trend.
3. Dynamic Monitoring and Alerts Once these key structural levels are mapped, the script continuously monitors the current price in relation to these historical levels. The logic is designed to detect when the market crosses or interacts with these specific structural "Red Lines."
If a significant shift occurs—such as a trend reversing or moving into a new structural zone—the script can trigger an automated alert. This provides a visual and audible signal that the market's structure has changed, helping traders stay aware of momentum shifts without having to manually watch every price tick.
Summary for the User
Essentially, this tool acts as a structural filter. It ignores the "chatter" of the market to find the major turning points (the "swings"). By mapping these out, it provides a clearer picture of the underlying market trend and notifies you when the price interacts with these critical structural boundaries.
//+------------------------------------------------------------------+
//| DinapoliTargets.mq4 |
//| mishanya_fx@yahoo.com |
//| |
//+------------------------------------------------------------------+
#property copyright "mishanya"
#property link "mishanya_fx@yahoo.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 5
//---- input parameters
extern int barn=300;
extern int Length=15;// was 19
double prev;
double last;
double alertBar;
extern int SoundAlertMode = 0;
//---- buffers
double ExtMapBuffer1[];
//double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexEmptyValue(0,0.0);
SetIndexDrawBegin(0, barn);
SetIndexStyle(0,DRAW_SECTION);
SetIndexBuffer(0,ExtMapBuffer1);
IndicatorShortName("Dinapoli_Red Line");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("Start line");
ObjectDelete("Stop line");
ObjectDelete("Target1 line");
ObjectDelete("Target2 line");
ObjectDelete("Target3 line");
ObjectDelete("info0");
ObjectDelete("info1");
ObjectDelete("info2");
ObjectDelete("info3");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int shift,Swing,Swing_n,uzl,i,zu,zd,mv;
double PointA,PointB,PointC,Target1,Target2,Target3,Fantnsy,CrazyDream,Start,Stop;
double LL,HH,BH,BL,NH,NL;
double Uzel[10000][3];
string text;
// loop from first bar to current bar (with shift=0)
Swing_n=0;Swing=0;uzl=0;
BH =High[barn];BL=Low[barn];zu=barn;zd=barn;
for (shift=barn;shift>=0;shift--) {
LL=10000000;HH=-100000000;
for (i=shift+Length;i>=shift+1;i--) {
if (Low[i]< LL) {LL=Low[i];}
if (High[i]>HH) {HH=High[i];}
}
if (Low[shift]<LL && High[shift]>HH){
Swing=2;
if (Swing_n==1) {zu=shift+1;}
if (Swing_n==-1) {zd=shift+1;}
} else {
if (Low[shift]<LL) {Swing=-1;}
if (High[shift]>HH) {Swing=1;}
}
if (Swing!=Swing_n && Swing_n!=0) {
if (Swing==2) {
Swing=-Swing_n;BH = High[shift];BL = Low[shift];
}
uzl=uzl+1;
if (Swing==1) {
Uzel[uzl][1]=zd;
Uzel[uzl][2]=BL;
}
if (Swing==-1) {
Uzel[uzl][1]=zu;
Uzel[uzl][2]=BH;
}
BH = High[shift];
BL = Low[shift];
}
if (Swing==1) {
if (High[shift]>=BH) {BH=High[shift];zu=shift;}}
if (Swing==-1) {
if (Low[shift]<=BL) {BL=Low[shift]; zd=shift;}}
Swing_n=Swing;
}
for (i=1;i<=uzl;i++) {
//text=DoubleToStr(Uzel[i][1],0);
//text=;
mv=StrToInteger(DoubleToStr(Uzel[i][1],0));
if(prev > Uzel[i][2] && ExtMapBuffer1[mv]!=Uzel[i][2] && SoundAlertMode > 0 && Bars>alertBar) {Alert("Dinapoli Red Line going Down on ",Symbol()," Period ",Period());alertBar = Bars;}
if(prev < Uzel[i][2] && ExtMapBuffer1[mv]!=Uzel[i][2] && SoundAlertMode > 0 && Bars>alertBar) {Alert("Dinapoli Red Line going Up on ",Symbol()," Period ",Period());alertBar = Bars;}
ExtMapBuffer1[mv]=Uzel[i][2];
prev=Uzel[i][2];
}
return(0);
}
//+------------------------------------------------------------------+
Comments