km-trend_movers_v1

Author: KM

This script is designed to help traders identify potential buying or selling opportunities in the market. It achieves this by analyzing several popular technical indicators and displaying their values directly on the chart, along with buy/sell signals based on a specific strategy.

Here's a breakdown of what the script does:

  1. Indicator Display: The script calculates the values of several commonly used indicators - RSI (Relative Strength Index), ATR (Average True Range), Stochastic Oscillator, MACD (Moving Average Convergence Divergence), and CCI (Commodity Channel Index). It then displays these values as text labels on the chart for easy reference. Think of these indicators as different lenses focusing on market behavior, each highlighting something unique about the price movement.

  2. Moving Average Analysis: The script focuses on two Moving Averages (MAs), one "fast" and one "slow." Moving averages smooth out price fluctuations to show the general direction of the trend. The "fast" MA reacts more quickly to price changes than the "slow" MA.

  3. Buy/Sell Signal Generation: The core logic of the script is to generate buy/sell signals based on the relationship between the current price and the two moving averages.

    • Strong Buy: If the most recent closing price is above both the fast and slow moving averages, the script signals a "Strong Buy".
    • Weak Buy: If the most recent closing price is above the fast moving average but below the slow moving average, the script signals a "Weak Buy, Wait or Buy!".
    • Strong Sell: If the most recent closing price is below both the fast and slow moving averages, the script signals a "Strong Sell".
    • Weak Sell: If the most recent closing price is below the fast moving average but above the slow moving average, the script signals a "Weak Sell, Wait or Sell!".
    • Neutral: If none of the above conditions are met, the script displays "PLEASE WAIT FOR RIGHT DECISION".
  4. Alerts: If enabled, the script can generate alerts (pop-up messages), send emails, and/or push notifications to your mobile device when a buy or sell signal is triggered. It will only trigger these alerts once per bar and is based on when these buy/sell conditions change.

In essence, this script is like a dashboard that provides a quick overview of several technical indicators and generates potential trading signals based on a moving average crossover strategy. It's important to remember that these are just signals, and traders should use their own judgment and risk management strategies before making any trading decisions.

Price Data Components
Series array that contains close prices for each bar
Indicators Used
Relative strength indexIndicator of the average true rangeStochastic oscillatorMACD HistogramCommodity channel indexMoving average indicator
Miscellaneous
It issuies visual alerts to the screenIt sends emails
3 Views
0 Downloads
0 Favorites
km-trend_movers_v1
//+------------------------------------------------------------------+
//|                                              KM-TREND MOVERS.mq4 |
//|                                                  Khurram Mustafa |
//|                             https://www.mql5.com/en/users/kc1981 |
//+------------------------------------------------------------------+
#property copyright "KM"
#property link      "https://www.mql5.com/en/users/kc1981/seller"
#property version   "1.0"
#property description "TREND MOVERS"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

input color Colour = Black;
input string Setting1 = "Moving Average";
input int MA_fast = 6; 
input int MA_slow = 25;
input int MA_shift_fast = 0;
input int MA_shift_slow = 0;

input string Setting2 = "RSI";
input int Period2 = 14;

input string Setting3 = "ATR";
input int Period3 = 14;

input string Setting4 = "STOCHISTIC";
input int Period4K = 9;
input int Period4D = 3;
input int Period4S = 3;

input string Setting5 = "MACD";
input int EFast = 12;
input int ESlow = 26;
input int EPeriod = 9;

input string Setting6 = "CCI";
input int Period5 = 14;

input bool Alert_Allow = False;
input bool Email_Allow = False;
input bool Notification_Allow = False;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll();

   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double rsilevel=iRSI(Symbol(),0,Period2,0,0);

   ObjectCreate("textrsi",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("textrsi",OBJPROP_CORNER,1);
   ObjectSet("textrsi",OBJPROP_XDISTANCE,50);
   ObjectSet("textrsi",OBJPROP_YDISTANCE,80);
   ObjectSetText("textrsi","RSI LEVEL "+IntegerToString(Period2,0)+" : "+DoubleToStr(rsilevel,2),10,"Times New Roman",Colour);

   double atrlevel=iATR(Symbol(),0,Period3,0);

   ObjectCreate("textatr",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("textatr",OBJPROP_CORNER,1);
   ObjectSet("textatr",OBJPROP_XDISTANCE,50);
   ObjectSet("textatr",OBJPROP_YDISTANCE,100);
   ObjectSetText("textatr","ATR LEVEL "+IntegerToString(Period3,0)+" : "+DoubleToString(atrlevel,5),10,"Times New Roman",Colour);

   double stolevel=iStochastic(Symbol(),0,Period4K,Period4D,Period4S,0,0,MODE_EMA,0);

   ObjectCreate("textsto",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("textsto",OBJPROP_CORNER,1);
   ObjectSet("textsto",OBJPROP_XDISTANCE,50);
   ObjectSet("textsto",OBJPROP_YDISTANCE,120);
   ObjectSetText("textsto","STOCHISTIC LEVEL "+IntegerToString(Period4K,0)+" : "+DoubleToString(stolevel,2),10,"Times New Roman",Colour);

   double macdlevel=iMACD(Symbol(),0,EFast,ESlow,EPeriod,0,MODE_EMA,0);

   ObjectCreate("textmacd",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("textmacd",OBJPROP_CORNER,1);
   ObjectSet("textmacd",OBJPROP_XDISTANCE,50);
   ObjectSet("textmacd",OBJPROP_YDISTANCE,140);
   ObjectSetText("textmacd","MACD LEVEL "+IntegerToString(EPeriod,0)+" : "+DoubleToString(macdlevel,5),10,"Times New Roman",Colour);

   double ccilevel=iCCI(Symbol(),0,Period5,0,0);

   ObjectCreate("textcci",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("textcci",OBJPROP_CORNER,1);
   ObjectSet("textcci",OBJPROP_XDISTANCE,50);
   ObjectSet("textcci",OBJPROP_YDISTANCE,160);
   ObjectSetText("textcci","CCI LEVEL "+IntegerToString(Period5,0)+" : "+DoubleToStr(ccilevel,2),10,"Times New Roman",Colour);

   double h15 =iMA( Symbol(),0,MA_fast, MA_shift_fast,MODE_EMA,PRICE_CLOSE,0);
   double h120=iMA( Symbol(),0,MA_slow, MA_shift_slow,MODE_SMA,PRICE_CLOSE,0);
   static datetime tmp;

   ObjectCreate("texti",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("texti",OBJPROP_CORNER,1);
   ObjectSet("texti",OBJPROP_XDISTANCE,50);
   ObjectSet("texti",OBJPROP_YDISTANCE,60);
   ObjectSetText("texti","TEST",10,"Times New Roman",Colour);

   if(iClose(Symbol(),0,1)>h15 && iClose(Symbol(),0,1)>h120)
     {
      ObjectSetText("texti","STRONG BUY",10,"Times New Roman",DarkGreen);
      if(tmp<Time[0])
        {
         tmp=Time[0];

         if(Alert_Allow)
           {
            string AlertMsgSB="TREND MOVERS (ALERT)"+"\n"+AccountName()+"\n"+"STRONG BUY FOR PAIR - "+Symbol();
            Alert(AlertMsgSB);
           }
         if(Email_Allow)
           {
            SendMail(AccountName()+Symbol()+" - "+AccountCompany(),
                     //"New Bar :  " + "Alert  \n" +
                     "STRONG BUY FOR PAIR"+"\n"+
                     "--------------------"+"\n"+
                     "Symbol : "+" "+Symbol()+" \n"+
                     "Period : "+" "+"Trend Movers"+" \n"+
                     "Time and Date : "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+" \n"+
                     "Broker : "+" "+AccountCompany()+"\n"+
                     "Account # : "+" "+IntegerToString(AccountNumber(),0,0));
           }

         if(Notification_Allow)
           {
            SendNotification(Symbol()+" "+"Trend Movers"+"\n"+
                             "New Signal: STRONG BUY FOR PAIR "+Symbol()+"  "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+"  "+AccountCompany());
           }
        }
     }
   else if(iClose(Symbol(),0,1)>h15 && iClose(Symbol(),0,1)<h120)
     {
      ObjectSetText("texti","WEAK BUY SIGNAL,WAIT OR BUY!",10,"Times New Roman",Green);
      if(tmp<Time[0])
        {
         tmp=Time[0];

         if(Alert_Allow)
           {
            string AlertMsgSB="TREND MOVERS (ALERT)"+"\n"+AccountName()+"\n"+"WEAK BUY SIGNAL FOR PAIR,WAIT OR BUY! - "+Symbol();
            Alert(AlertMsgSB);
           }
         if(Email_Allow)
           {
            SendMail(AccountName()+Symbol()+" - "+AccountCompany(),
                     //"New Bar :  " + "Alert  \n" +
                     "WEAK BUY SIGNAL FOR PAIR,WAIT OR BUY!"+"\n"+
                     "--------------------"+"\n"+
                     "Symbol : "+" "+Symbol()+" \n"+
                     "Period : "+" "+"Trend Movers"+" \n"+
                     "Time and Date : "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+" \n"+
                     "Broker : "+" "+AccountCompany()+"\n"+
                     "Account # : "+" "+IntegerToString(AccountNumber(),0,0));
           }

         if(Notification_Allow)
           {
            SendNotification(Symbol()+" "+"Trend Movers"+"\n"+
                             "New Signal: WEAK BUY SIGNAL FOR PAIR,WAIT OR BUY! "+Symbol()+"  "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+"  "+AccountCompany());
           }
        }
     }
   else if(iClose(Symbol(),0,0)<h15 && iClose(Symbol(),0,0)<h120)
     {
      ObjectSetText("texti","STRONG SELL",10,"Times New Roman",Red);
      if(tmp<Time[0])
        {
         tmp=Time[0];

         if(Alert_Allow)
           {
            string AlertMsgSB="TREND MOVERS (ALERT)"+"\n"+AccountName()+"\n"+"STRONG SELL FOR PAIR - "+Symbol();
            Alert(AlertMsgSB);
           }
         if(Email_Allow)
           {
            SendMail(AccountName()+Symbol()+" - "+AccountCompany(),
                     //"New Bar :  " + "Alert  \n" +
                     "STRONG SELL FOR PAIR"+"\n"+
                     "--------------------"+"\n"+
                     "Symbol : "+" "+Symbol()+" \n"+
                     "Period : "+" "+"Trend Movers"+" \n"+
                     "Time and Date : "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+" \n"+
                     "Broker : "+" "+AccountCompany()+"\n"+
                     "Account # : "+" "+IntegerToString(AccountNumber(),0,0));
           }

         if(Notification_Allow)
           {
            SendNotification(Symbol()+" "+"Trend Movers"+"\n"+
                             "New Signal: STRONG SELL FOR PAIR "+Symbol()+"  "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+"  "+AccountCompany());
           }
        }
     }
   else if(iClose(Symbol(),0,0)<h15 && iClose(Symbol(),0,0)>h120)
     {
      ObjectSetText("texti","WEAK SELL SIGNAL FOR PAIR,WAIT OR SELL!",10,"Times New Roman",Red);
      if(tmp<Time[0])
        {
         tmp=Time[0];

         if(Alert_Allow)
           {
            string AlertMsgSB="TREND MOVERS (ALERT)"+"\n"+AccountName()+"\n"+"WEAK SELL SIGNAL FOR PAIR,WAIT OR SELL! - "+Symbol();
            Alert(AlertMsgSB);
           }
         if(Email_Allow)
           {
            SendMail(AccountName()+Symbol()+" - "+AccountCompany(),
                     //"New Bar :  " + "Alert  \n" +
                     "WEAK SELL SIGNAL FOR PAIR,WAIT OR SELL!"+"\n"+
                     "--------------------"+"\n"+
                     "Symbol : "+" "+Symbol()+" \n"+
                     "Period : "+" "+"Trend Movers"+" \n"+
                     "Time and Date : "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+" \n"+
                     "Broker : "+" "+AccountCompany()+"\n"+
                     "Account # : "+" "+IntegerToString(AccountNumber(),0,0));
           }

         if(Notification_Allow)
           {
            SendNotification(Symbol()+" "+"Trend Movers"+"\n"+
                             "New Signal: WEAK SELL SIGNAL FOR PAIR,WAIT OR SELL! "+Symbol()+"  "+TimeToStr(TimeCurrent(),TIME_SECONDS)+"  "+TimeToStr(TimeCurrent(),TIME_DATE)+"  "+AccountCompany());
           }
        }
     }
   else
     {
      ObjectSetText("texti","PLEASE WAIT FOR RIGHT DECISION",10,"Times New Roman",Black);
     }
   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 ---