Commentator_v2

Download script
Author: ������ ������
Commentator_v2

This script functions as a comprehensive market "Commentator"—a visual dashboard designed to provide traders with real-time summaries of various technical market conditions. Instead of requiring the user to interpret multiple different charts or complex graphs, it aggregates data from several popular indicators into a single, easy-to-read text summary directly on the trading screen.

The logic operates by monitoring eight specific market metrics simultaneously:

Trend and Momentum Analysis

  • DeMarker: This is used to identify price reversals. The script monitors whether the price is reaching extreme levels, alerting the user if there is a high probability of a trend turning upward or downward.
  • Momentum: This tracks the strength of price movement. It specifically looks for "crossovers" where momentum shifts from one side of a threshold to another, providing clear buy or sell signals based on the speed of price action.
  • ATR (Average True Range): This provides a measure of market volatility. It helps the trader understand how much the price is swinging, which serves as an indicator of potential trend changes.

Overbought and Oversold Monitoring

The script includes several "oscillator" metrics to help identify when a market has moved too far in one direction and might be due for a correction:

  • CCI (Commodity Channel Index): Identifies periods of over-extension, highlighting where the price may be over-bought (potential drop) or over-sold (potential rise).
  • MFI (Money Flow Index): Similar to volume-weighted momentum, it identifies potential market "peaks" or "bottoms" based on the flow of capital.
  • WPR (Williams %R): Monitors the position of the price relative to its high-low range, flagging areas where a reversal might be expected.
  • Stochastic Oscillator: Compares two moving averages of price to suggest immediate buying or selling opportunities based on their relative positions.

Advanced Position Logic (AC Indicator)

A significant portion of the script's logic is dedicated to analyzing the "AC" indicator. It performs a multi-step check to determine:

  1. Directional Bias: Whether the current price action suggests a preference for buying or selling.
  2. Position Type: By scanning historical data points, the logic determines if the current setup favors a "Short" or "Long" position.
  3. Contextual Suggestions: It combines these checks to provide specific textual feedback, such as "Possible Purchase" or "Possible Sale," depending on whether the indicator values are currently positive or negative.

User Experience

For the end-user, the logic simplifies the trading process by translating raw numerical data into human-readable phrases (e.g., "Potential Market Peak," "Possibility of Price Reversal," or "Buy Signal"). By consolidating these various technical viewpoints into one text block, it allows a trader to get a "snapshot" of the market's health at a single glance.

Indicators Used
DeMarker indicatorIndicator of the average true rangeBill Williams Accelerator/Decelerator oscillatorCommodity channel indexMoney flow indexLarry William percent range indicatorStochastic oscillatorMomentum indicator
18 Views
0 Downloads
0 Favorites
Commentator_v2
//+------------------------------------------------------------------+
//|  Àíäðåé Îïåéäà                                 Êîììåíòàòîð       |
//+------------------------------------------------------------------+
#property copyright "Îïåéäà Àíäðåé"
#property link      "itrytobenotlinked"


#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorShortName("Comentator");           
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int i = 0;
//   Demarker
      double valDem=iDeMarker(NULL, 0, 13, 0);
      string commentDem = "DeMarker:    ";
      string commentDemAdd = "   Íåò äàííûõ";
     
      if (valDem < 0.30)
         commentDemAdd =  "   Îæèäàåòñÿ ðàçâîðîò öåí Ââåðõ";
      
      if (valDem > 0.70)
         commentDemAdd =   "   Îæèäàåòñÿ ðàçâîðîò öåí Âíèç";
      commentDem = commentDem + commentDemAdd;

//ATR
      double valATR=iATR(NULL, 0, 12, 0);
      string commentATR = "ATR:           ";
        commentATR = commentATR + "   Âåðîÿòíîñòü ñìåíû òðåíäà " + valATR;
            
//AÑ
      string commentAC = "AC:            ";
      string commentACAdd = "Íåò äàííûõ ";
      string commentACAdd0 = "Íåò äàííûõ ";
      string commentACAdd1 = "Íåò äàííûõ ";
      string commentACAdd2 = "Íåò äàííûõ ";
      double valAC0=iAC(NULL, 0, 0);
      double valAC1=iAC(NULL, 0, 1);
      if (valAC1 < valAC0)
         commentACAdd = "Íå æåëàòåëüíî ïðîäàâàòü";
      
      if (valAC1 > valAC0)
         commentACAdd = "Íå æåëàòåëüíî ïîêóïàòü";
      
      bool theeRedUpper = true;
      for(i=2; i>=0; i--)
      {
         if ( iAC(NULL, 0, i) < iAC(NULL, 0, i+1))
         {
            if ( iAC(NULL, 0, i) <= 0)
               theeRedUpper = false;
         }
         else
            theeRedUpper = false;
      }
      
      if (theeRedUpper == true)
         commentACAdd0 = "Êîðîòêàÿ ïîçèöèÿ";


      bool theeGreenDown = true;
      for(i=2; i>=0; i--)
      {
         if ( iAC(NULL, 0, i) > iAC(NULL, 0, i+1))
         {
            if ( iAC(NULL, 0, i) >= 0)         
              theeGreenDown = false;
         }
         else
            theeGreenDown = false;
      }
      
      if (theeGreenDown == true)
         commentACAdd0 = "Äëèííàÿ ïîçèöèÿ";


      bool twoRedUpper = true;
      for(i=1; i>=0; i--)
      {
         if ( iAC(NULL, 0, i) > iAC(NULL, 0, i+1))
            twoRedUpper = false;
      }
      
      if (twoRedUpper == true)
         commentACAdd2 = "Êîðîòêàÿ ïîçèöèÿ";



      bool twoGreenDown = true;
      for(i=2; i>=0; i--)
      {
         if ( iAC(NULL, 0, i) < iAC(NULL, 0, i+1))
            twoGreenDown = false;
      }
      
      if (twoGreenDown == true)
         commentACAdd2 = "Äëèííàÿ ïîçèöèÿ";



      
      
      if (iAC(NULL, 0, 0) < 0)
      {         
         if (theeRedUpper == true)
            commentACAdd1 = "Âîçìîæíà ïîêóïêà, ";  
            
         if (theeGreenDown == true)
            commentACAdd1 = "Âîçìîæíà ïîêóïêà, ";  
                  
         if (twoRedUpper == true)
           commentACAdd2 = "Âîçìîæíà ïðîäàæà, ";         
      }
      
      if (iAC(NULL, 0, 0) > 0)
      {
         if (theeRedUpper == true)
            commentACAdd1 = "Âîçìîæíà ïðîäàæà, ";
            
         if (theeGreenDown == true)
            commentACAdd1 = "Âîçìîæíà ïðîäàæà, ";
                  
         if (twoGreenDown == true)
            commentACAdd2 = "Âîçìîæíà ïîêóïêà, ";
      }
      
            
        commentAC = commentAC 
        + "\n" + "   " +commentACAdd
        + "\n" + "   " + commentACAdd1+ commentACAdd0
        + "\n" + "   " + commentACAdd2
        ;

     
     
//CCI
      double valCCI=iCCI(NULL,0,12,PRICE_MEDIAN,0);
      string commentCCI = "CCI:            ";
      string commentCCIAdd = "   Íåò äàííûõ ";
      if (valCCI > 100)
        commentCCIAdd =  "   Cîñòîÿíèå ïåðåêóïëåííîñòè (âåðîÿòíîñòü êîððåêòèðóþùåãî ñïàäà) ";

      if (valCCI < -100)
        commentCCIAdd =  "   Cîñòîÿíèå ïåðåïðîäàííîñòè (âåðîÿòíîñòü êîððåêòèðóþùåãî ïîäúåìà) ";
        
      commentCCI =  commentCCI + commentCCIAdd + valCCI;



//MFI
      double valMFI=iMFI(NULL,0,14,0);
      string commentMFI = "MFI:            ";
      string commentMFIAdd = "   Íåò äàííûõ ";
      if (valMFI > 80)
        commentMFIAdd =  "    ïîòåíöèàëüíîàÿ âåðøèíà ðûíêà ";

      if (valMFI < 20)
        commentMFIAdd =  "    ïîòåíöèàëüíîàå îñíîâàíèå ðûíêà ";
        
        commentMFI =  commentMFI + commentMFIAdd + valMFI;
        
        
//WPR
      double valWPR=iWPR(NULL,0,14,0);
      string commentWPR = "R%:             ";
      string commentWPRAdd = "   Íåò äàííûõ ";
      if (valWPR < -80)
        commentWPRAdd =  "    ñîñòîÿíèå ïåðåïðîäàííîñòè (ðàçóìíî äîæäàòüñÿ ïîâîðîòà öåí ââåðõ) ";

      if (valWPR > -20)
        commentWPRAdd =  "    ñîñòîÿíèå ïåðåêóïëåííîñòè (ðàçóìíî äîæäàòüñÿ ïîâîðîòà öåí âíèç) ";
        
      commentWPR =  commentWPR + commentWPRAdd + valWPR;
        
        
//STOCH

      double valSTOCH=0; 
      string commentSTOCH = "Stoch:         ";
      string commentSTOCHAdd = "   Íåò äàííûõ ";
      if(iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0)>iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0))
        commentSTOCHAdd =  "    Âîçìîæíà ïîêóïêà";
               
      if(iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0)<iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0))
        commentSTOCHAdd =  "    Âîçìîæíà ïðîäàæà";   
        
      commentSTOCH =  commentSTOCH + commentSTOCHAdd;


//Momentum

      double valMom=0;
      string commentMom = "Momentum:  ";
      string commentMomAdd = "   Íåò äàííûõ ";
      if((iMomentum(NULL,0,14,PRICE_CLOSE,1) < 100) && (iMomentum(NULL,0,14,PRICE_CLOSE,0) > 100))
        commentMomAdd =  "    Ñèãíàë ê ïîêóïêå";
        
      if((iMomentum(NULL,0,14,PRICE_CLOSE,1) > 100) && (iMomentum(NULL,0,14,PRICE_CLOSE,0) < 100))
        commentMomAdd =  "    Ñèãíàë ê ïðîäàæå";   
        
      commentMom =  commentMom + commentMomAdd;
      
      Comment("Èíäèêàòîðû\n"
      +commentSTOCH + "\n"
      +commentWPR + "\n"
      +commentMFI + "\n"
      +commentDem + "\n"
      +commentCCI + "\n"
      +commentATR + "\n"
      +commentMom + "\n"      
      +commentAC + "\n"
      );      
   return(0);
  }
//+------------------------------------------------------------------+

Comments