Author: Copyright � 2004, MetaQuotes Software Corp.
Price_main

This script is designed as a visual trading tool for the MetaTrader platform, specifically engineered to identify and signal potential trend reversals or momentum shifts using specialized price action logic.

Core Functionality

The primary purpose of this tool is to monitor price movements and automatically place visual markers (arrows) on the chart. These markers serve as cues for traders to recognize when the market sentiment might be shifting from bullish to bearish, or vice versa.

How the Logic Works

The script functions by scanning historical and real-time price data, specifically looking at the relationship between opening prices, closing prices, highs, and lows of individual candles. Its internal logic follows these key steps:

  • Trend Detection: The tool differentiates between "up" candles (where the price closed higher than it opened) and "down" candles (where the price closed lower than it opened).
  • Signal Identification: It looks for specific instances where the price movement reaches a point of equilibrium or transition. When the script detects a qualifying price action—specifically one that indicates a potential change in direction—it places a visual arrow on the chart.
  • Visual Differentiation:
    • One set of markers (colored Yellow) is triggered during specific bullish price patterns.
    • The other set of markers (colored Magenta) is triggered during specific bearish price patterns.
  • Smart Filtering: To prevent the chart from being cluttered with constant signals, the script includes internal "memory." It tracks previous signals to ensure it only alerts the user when a significant change occurs, rather than repeating the same alert on consecutive bars.

User Notifications

Beyond the visual arrows on the chart, the script is equipped with an optional audio notification system. Depending on how the user configures the settings, the tool can play specific sound effects (such as "expert.wav" or "blip2.wav") the moment a new signal is detected. This allows traders to stay informed of market shifts even when they are not looking directly at the screen.

Summary for the Trader

In simple terms, this script acts as an automated observer. It sifts through the constant noise of price movements and "pings" you with visual arrows and sounds whenever it detects a specific pattern that suggests the market may be turning in a new direction.

Miscellaneous
Implements a curve of type %1It plays sound alerts
8 Views
0 Downloads
0 Favorites
Price_main
//+------------------------------------------------------------------+
//|                                                  Heiken Ashi.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//| For Heiken Ashi we recommend next chart settings ( press F8 or   |
//| select on menu 'Charts'->'Properties...'):                       |
//|  - On 'Color' Tab select 'Black' for 'Line Graph'                |
//|  - On 'Common' Tab disable 'Chart on Foreground' checkbox and    |
//|    select 'Line Chart' radiobutton                               |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Magenta
#property indicator_width1 3
#property indicator_width2 3

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double counthigh;
double countlow;
double alertBar;
double prev;
extern int SoundAlertMode = 0;
extern int messageAlert = 1;
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW, STYLE_SOLID);
    SetIndexArrow(0, 233);
  SetIndexBuffer(0, ExtMapBuffer1);
  SetIndexStyle(1,DRAW_ARROW, STYLE_SOLID);
       SetIndexArrow(1,234);
   SetIndexBuffer(1, ExtMapBuffer2);

      
//       SetIndexStyle(2,DRAW_HISTOGRAM);
//           SetIndexArrow(2,233);
//  SetIndexBuffer(2, ExtMapBuffer3);
//   SetIndexStyle(3,DRAW_HISTOGRAM);
//         SetIndexArrow(3,233);
//   SetIndexBuffer(3, ExtMapBuffer4);
//----
   SetIndexDrawBegin(0,5);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
//   SetIndexBuffer(2,ExtMapBuffer3);
//   SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double BarOpen, BarHigh, BarLow, BarClose;
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   while(pos>0)
     {
      BarOpen=Open[pos];
      BarClose=Close[pos];
      BarHigh=High[pos];
      BarLow=Low[pos];
      if (BarOpen<BarClose) 
        {
      if(prev != 2 && Bars>alertBar && BarOpen != BarClose && ExtMapBuffer1[pos] == ExtMapBuffer2[pos]) {ExtMapBuffer1[pos]=BarLow;prev=2;
       if(SoundAlertMode > 0 ) PlaySound("expert.wav");alertBar = Bars;}
   if(ExtMapBuffer1[pos] > ExtMapBuffer2[pos]) counthigh=counthigh + 1;
        } 
    if (BarOpen>BarClose) 
        {
      if(prev != 1 && Bars>alertBar && BarOpen != BarClose && ExtMapBuffer1[pos] == ExtMapBuffer2[pos]) {ExtMapBuffer2[pos]=BarHigh;prev = 1;
       if(SoundAlertMode > 0 ) PlaySound("blip2.wav");alertBar = Bars;}
   if(ExtMapBuffer1[pos] < ExtMapBuffer2[pos]) countlow=countlow + 1;
        } 
  	   pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments