DinapoliTargets-Kuskus

Author: mishanya
DinapoliTargets-Kuskus

This script is designed as a visual analysis tool for trading platforms, specifically aimed at identifying significant market trends and automatically calculating potential price targets based on historical price action. It functions by recognizing "swings"—the highs and lows of the market—and projecting where the price might travel next using mathematical proportions.

Core Logic and Functionality

Trend Identification (ZigZag Analysis) The script begins by scanning historical price data to identify structural shifts in the market. It looks for "swing points," which are significant peaks and valleys that stand out from the surrounding price action. By tracking these movements, the tool creates a chronological map of the market's trajectory, helping to distinguish between minor fluctuations and major trend changes.

Real-Time Monitoring and Alerts The tool continuously compares the most recent price movement against the established history of swing points. If it detects a significant change in direction—such as a shift from an upward trend to a downward trend (or vice versa)—it can trigger a notification alert. This allows users to stay informed about major structural changes without having to constantly monitor every tick of the market.

Automated Target Calculation One of the primary features of this script is its ability to project future price levels. It uses the geometry of the most recent completed trend moves to calculate several specific "Targets." These targets are derived using mathematical constants (specifically related to Fibonacci proportions), which are often used by traders to identify areas of potential price reversal or exhaustion.

The script identifies three distinct target zones:

  • Target 1: A primary projection based on a specific mathematical ratio of the previous move.
  • Target 2: A calculation representing a direct extension of the current price momentum.
  • Target 3: A further projection intended to capture larger, long-term trend movements.

Visual Mapping and Support/Resistance Levels To make this data actionable for the user, the script draws physical lines on the trading chart. When enabled, it automatically plots:

  • Start and Stop Lines: These provide a visual "safety zone" or entry context based on the current market volatility (the spread).
  • Target Lines: These appear as distinct colored horizontal lines, showing exactly where the script expects the price to reach its next significant milestone.

Summary of User Experience

For a non-programmer, this tool acts as an automated "analyst." It does the heavy lifting of calculating complex trend proportions and historical math in the background, then translates that data into simple visual cues on the screen. It tells you where the market has been, alerts you when the direction changes, and marks the specific price levels where you might consider taking action.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
DinapoliTargets-Kuskus
//+------------------------------------------------------------------+
//|                                              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 PowderBlue
#property indicator_width1 5
//---- input parameters
extern int       barn=300;
extern int       Length=30;// was 19
double prev;
double last;
double alertBar;
extern int SoundAlertMode = 1;
extern int Soundonly = 1;
extern bool targets = false;
//---- 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("DIN");
   
//----
   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("Dinap Kuskus ZigZag going Down on ",Symbol()," Period ",Period());alertBar = Bars;}
      if(prev < Uzel[i][2] && ExtMapBuffer1[mv]!=Uzel[i][2] && SoundAlertMode > 0 && Bars>alertBar) {Alert("Dinap Kuskus ZigZag going Up on ",Symbol()," Period ",Period());alertBar = Bars;}

//      if(prev > Uzel[i][2] && ExtMapBuffer1[mv]!=Uzel[i][2] && Bars>alertBar) {PlaySound("mailworf.wav");alertBar = Bars;}
//      if(prev < Uzel[i][2] && ExtMapBuffer1[mv]!=Uzel[i][2] && Bars>alertBar) {PlaySound("subspace.wav");alertBar = Bars;}
      ExtMapBuffer1[mv]=Uzel[i][2];
      prev=Uzel[i][2];
   } 

PointA = Uzel[uzl-2][2];
PointB = Uzel[uzl-1][2];
PointC = Uzel[uzl][2];

Target1=NormalizeDouble((PointB-PointA)*0.618+PointC,4);
Target2=PointB-PointA+PointC;
Target3=NormalizeDouble((PointB-PointA)*1.618+PointC,4);
Fantnsy=NormalizeDouble((PointB-PointA)*2.618+PointC,4);
CrazyDream=NormalizeDouble((PointB-PointA)*4.618+PointC,4);
if (PointB<PointC)
{
Start= NormalizeDouble((PointB-PointA)*0.318+PointC,4)-(Ask-Bid);
Stop=PointC+2*(Ask-Bid);
}
if (PointB>PointC)
{
Start= NormalizeDouble((PointB-PointA)*0.318+PointC,4)+(Ask-Bid);
Stop=PointC-2*(Ask-Bid);
}


   if (ObjectFind("Start Line") != 0 && targets == true) 
     {
      ObjectCreate("Start line",OBJ_HLINE,0,Time[0],Start);
      ObjectSet("Start line",OBJPROP_COLOR,Bisque);
      ObjectSet("Start line",OBJPROP_WIDTH,3);
      ObjectSet("Start line",OBJPROP_STYLE,STYLE_DOT);
     }
     else
     {
     ObjectMove("Start line", 0,Time[0],Start);
     }

   if (ObjectFind("Stop Line") != 0 && targets == true) 
     {
      ObjectCreate("Stop line",OBJ_HLINE,0,Time[0],Stop);
      ObjectSet("Stop line",OBJPROP_COLOR,Red);
      ObjectSet("Stop line",OBJPROP_WIDTH,3);
      ObjectSet("Stop line",OBJPROP_STYLE,STYLE_DOT);
     }
     else
     {
     ObjectMove("Stop line", 0,Time[0],Stop);
     }
    
    if (ObjectFind("Target1 Line") != 0 && targets == true) 
     {
      ObjectCreate("Target1 line",OBJ_HLINE,0,Time[0],Target1);
      ObjectSet("Target1 line",OBJPROP_COLOR,Yellow);
      ObjectSet("Target1 line",OBJPROP_WIDTH,3);
      ObjectSet("Target1 line",OBJPROP_STYLE,STYLE_DOT);
     }
     else
     {
     ObjectMove("Target1 line", 0,Time[0],Target1);
     }

    if (ObjectFind("Target2 Line") != 0 && targets == true) 
     {
      ObjectCreate("Target2 line",OBJ_HLINE,0,Time[0],Target2);
      ObjectSet("Target2 line",OBJPROP_COLOR,PaleTurquoise);
      ObjectSet("Target2 line",OBJPROP_WIDTH,3);
      ObjectSet("Target2 line",OBJPROP_STYLE,STYLE_DOT);
     }
     else
     {
     ObjectMove("Target2 line", 0,Time[0],Target2);
     }
    
    if (ObjectFind("Target3 Line") != 0 && targets == true) 
     {
      ObjectCreate("Target3 line",OBJ_HLINE,0,Time[0],Target3);
      ObjectSet("Target3 line",OBJPROP_COLOR,LightSkyBlue);
      ObjectSet("Target3 line",OBJPROP_WIDTH,3);
      ObjectSet("Target3 line",OBJPROP_STYLE,STYLE_DOT);
     }
     else
     {
     ObjectMove("Target3 line", 0,Time[0],Target3);
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments