Commentator

Author: ������ ������
Commentator

The provided MetaTrader MQL script is a custom indicator designed to analyze and comment on various market conditions using technical indicators. Below, I'll explain the logic of this script in non-technical terms suitable for an audience without programming knowledge.

Purpose

The goal of this script is to generate comments about potential market movements based on several well-known technical analysis indicators. It aims to provide insights into whether certain trading actions might be advisable or not.

How It Works

  1. Technical Indicators Used:

    • DeMarker (Dem) Indicator: This measures momentum and helps identify overbought or oversold conditions in the market.
    • Commodity Channel Index (CCI): Identifies cyclical trends and potential reversals by measuring the current price level relative to an average price level.
    • Money Flow Index (MFI): Similar to the Relative Strength Index (RSI) but uses volume data to measure buying or selling pressure.
    • Williams Percent Range (W%R): A momentum indicator that shows overbought and oversold conditions in a market.
    • Stochastic Oscillator: Compares a closing price of an asset to its price range over a certain period, indicating potential bullish or bearish trends.
    • Momentum Indicator: Measures the rate of change in price to identify acceleration or deceleration.
    • Average True Range (ATR): Assesses market volatility by measuring the average range between highs and lows.
  2. Logic and Analysis:

    • The script evaluates each technical indicator's current value against predefined thresholds to determine the market condition.
    • For example, if the DeMarker is high, it might suggest an overbought condition; conversely, a low value may indicate an oversold condition.
    • Similarly, for CCI, values above 100 typically signal overbought conditions, while below -100 suggest oversold conditions.
    • Each indicator provides a specific comment based on its current reading. These comments are then compiled into one cohesive analysis.
  3. Output:

    • The script combines the insights from all indicators into a single text output that is displayed to the user as a "Comment."
    • This comment suggests potential actions like buying or selling, highlights overbought or oversold conditions, and gives an overall market sentiment based on multiple technical perspectives.
  4. Use Case:

    • Traders use this script's output to make informed decisions about entering or exiting trades. It provides a consolidated view of the market condition, reducing the complexity of interpreting multiple indicators individually.

Conclusion

This script serves as an analytical tool that distills complex market data into actionable insights for traders, using established technical analysis techniques. Its primary function is to assist in decision-making by offering a comprehensive overview of potential market conditions based on several indicators' readings.

Indicators Used
DeMarker indicatorIndicator of the average true rangeBill Williams Accelerator/Decelerator oscillatorCommodity channel indexMoney flow indexLarry William percent range indicatorStochastic oscillatorMomentum indicator
3 Views
0 Downloads
0 Favorites
Commentator
//+------------------------------------------------------------------+
//|  Àíäðåé Îïåéäà                                 Êîììåíòàòîð       |
//+------------------------------------------------------------------+
#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 = "   No data";
     
      if (valDem < 0.30)
         commentDemAdd =  "   Possible reverse to uptrend";
      
      if (valDem > 0.70)
         commentDemAdd =   "   Possible reverse to downtrend";
      commentDem = commentDem + commentDemAdd;

//ATR
      double valATR=iATR(NULL, 0, 12, 0);
      string commentATR = "ATR:           ";
        commentATR = commentATR + "   Possible trend changing " + valATR;
            
//AÑ
      string commentAC = "AC:            ";
      string commentACAdd = "No data ";
      string commentACAdd0 = "No data ";
      string commentACAdd1 = "No data ";
      string commentACAdd2 = "No data ";
      double valAC0=iAC(NULL, 0, 0);
      double valAC1=iAC(NULL, 0, 1);
      if (valAC1 < valAC0)
         commentACAdd = "Sell not advisable";
      
      if (valAC1 > valAC0)
         commentACAdd = "Buy not advisable";
      
      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 = "Short position";


      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 = "Long position";


      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 = "Short position";



      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 = "Long position";



      
      
      if (iAC(NULL, 0, 0) < 0)
      {         
         if (theeRedUpper == true)
            commentACAdd1 = "Possible buy, ";  
            
         if (theeGreenDown == true)
            commentACAdd1 = "Possible buy, ";  
                  
         if (twoRedUpper == true)
           commentACAdd2 = "Possible sell, ";         
      }
      
      if (iAC(NULL, 0, 0) > 0)
      {
         if (theeRedUpper == true)
            commentACAdd1 = "Possible sell, ";
            
         if (theeGreenDown == true)
            commentACAdd1 = "Possible sell, ";
                  
         if (twoGreenDown == true)
            commentACAdd2 = "Possible buy, ";
      }
      
            
        commentAC = commentAC 
        + "\n" + "   " +commentACAdd
        + "\n" + "   " + commentACAdd1+ commentACAdd0
        + "\n" + "   " + commentACAdd2
        ;

     
     
//CCI
      double valCCI=iCCI(NULL,0,12,PRICE_MEDIAN,0);
      string commentCCI = "CCI:            ";
      string commentCCIAdd = "   No data ";
      if (valCCI > 100)
        commentCCIAdd =  "   Overboughted condition (possibility to corrected recession) ";

      if (valCCI < -100)
        commentCCIAdd =  "   Oversolded condition (possibility to corrected raising) ";
        
      commentCCI =  commentCCI + commentCCIAdd + valCCI;



//MFI
      double valMFI=iMFI(NULL,0,14,0);
      string commentMFI = "MFI:            ";
      string commentMFIAdd = "   No data ";
      if (valMFI > 80)
        commentMFIAdd =  "    potential high ";

      if (valMFI < 20)
        commentMFIAdd =  "    potential low ";
        
        commentMFI =  commentMFI + commentMFIAdd + valMFI;
        
        
//WPR
      double valWPR=iWPR(NULL,0,14,0);
      string commentWPR = "R%:             ";
      string commentWPRAdd = "   No data ";
      if (valWPR < -80)
        commentWPRAdd =  "    Oversolded condition (waiting for long reversal is desirable) ";

      if (valWPR > -20)
        commentWPRAdd =  "    Overboughted condition (waiting for short reversal is desirable) ";
        
      commentWPR =  commentWPR + commentWPRAdd + valWPR;
        
        
//STOCH

      double valSTOCH=0; 
      string commentSTOCH = "Stoch:         ";
      string commentSTOCHAdd = "   No data ";
      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 =  "    Possible buy";
               
      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 =  "    Possible sell";   
        
      commentSTOCH =  commentSTOCH + commentSTOCHAdd;


//Momentum

      double valMom=0;
      string commentMom = "Momentum:  ";
      string commentMomAdd = "   No data ";
      if((iMomentum(NULL,0,14,PRICE_CLOSE,1) < 100) && (iMomentum(NULL,0,14,PRICE_CLOSE,0) > 100))
        commentMomAdd =  "    Signal to buy";
        
      if((iMomentum(NULL,0,14,PRICE_CLOSE,1) > 100) && (iMomentum(NULL,0,14,PRICE_CLOSE,0) < 100))
        commentMomAdd =  "    Signal to sell";   
        
      commentMom =  commentMom + commentMomAdd;
      
      Comment(
      commentSTOCH + "\n"
      +commentWPR + "\n"
      +commentMFI + "\n"
      +commentDem + "\n"
      +commentCCI + "\n"
      +commentATR + "\n"
      +commentMom + "\n"      
      +commentAC + "\n"
      );      
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---