YangTraderMain

Download script
Author: ��������2011��6��25��
YangTraderMain

This tool is designed as a technical analysis indicator for the MetaTrader platform, intended to help traders visualize market momentum and identify potential entry or exit points based on price action trends.

Core Methodology

The script operates by analyzing price movements through a multi-layered mathematical smoothing process. Instead of looking at raw price data alone, which can be noisy and erratic, it processes the information in three distinct stages:

  1. Momentum Calculation: The logic first calculates the difference between two moving averages of different lengths. By comparing a shorter timeframe to a longer one, the script identifies the "velocity" of the current market trend.
  2. Smoothing Layer: To ensure that the resulting data doesn't react too violently to minor price fluctuations (which can lead to false signals), the script applies a secondary mathematical filter over the momentum values. This creates a smoother line that represents the underlying strength of the trend.
  3. Visual Mapping: The primary output is a continuous line displayed on your chart, providing a visual representation of these smoothed trends.

Signal Generation

Beyond just showing a trend line, the script includes an automated signaling system to highlight specific market conditions:

  • Buy Signals: The logic monitors for specific "oversold" or upward momentum shifts. When the calculated values cross a defined lower threshold (indicating a potential reversal from a low point), the tool places a visual arrow below the price candle.
  • Sell Signals: Conversely, the script monitors for "overbought" levels or downward momentum shifts. When the values cross a higher threshold (indicating the market may be reaching a peak), it places a visual arrow above the price candle.

User Configuration

The behavior of the tool can be adjusted through several key parameters:

  • Period: Determines how much historical data is considered for the trend calculations.
  • Time Window & Sensitivity: These settings allow you to fine-tune how quickly or slowly the indicator reacts to new price changes, helping you balance between capturing early moves and avoiding "市場雜訊" (market noise).

In summary, this script acts as a filter that strips away market noise to reveal the prevailing trend, providing visual alerts when price action suggests the trend may be reaching an exhaustion point or beginning a new move.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
YangTraderMain
//--  Original Author : yangshu --//
//--  copyright YangShu 2011    --//
//--  Email:yangshu@yangshu.net --//
//--  Web: http://yangshu.net   --//
#property copyright "ÑîÊ÷´´ÓÚ2011Äê6ÔÂ25ÈÕ" 
#property link      "http://yangshu.net" 

#property indicator_chart_window 
#property indicator_buffers 3 
#property indicator_color1 Teal
#property indicator_style1 2
#property indicator_color2 DodgerBlue
#property indicator_color3 Red  
//---- input parameters 
extern int period=34; 
extern int TimeWindow=34;
extern int Sensitive=8;
int        method=3;                         // MODE_SMA 
int        price=0;                          // PRICE_CLOSE 
double ExtMapBuffer[]; 
double buf1[];
double buf2[];

int init() 
{ 
    IndicatorBuffers(3);  
    SetIndexBuffer(0,ExtMapBuffer); 
    ArraySetAsSeries(ExtMapBuffer, true); 
    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
    IndicatorShortName("YangTraderMain"); 
   
   int  draw;
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,233);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,234);
   SetIndexEmptyValue(1,0.0);
   SetIndexDrawBegin(1,draw);
   SetIndexDrawBegin(2,draw);
   SetIndexBuffer(1,buf1);
   SetIndexBuffer(2,buf2);
  
  return(0); 
} 

double WMA(int x, int p) 
{ 
    return(iMA(NULL, 0, p, 0, method, price, x));    
} 

int start() 
{ 
    int counted_bars = IndicatorCounted(); 
    if(counted_bars < 0) return(-1); 
    int x = 0; 
    int p = MathSqrt(period);              
    int e = Bars - counted_bars + period + 1; 
    double vect[]; 
    if(e > Bars) e = Bars;    
    ArrayResize(vect, e); 
    ArraySetAsSeries(vect, true);
    for(x = 0; x < e; x++) 
        vect[x] = 2*WMA(x, period/2) - WMA(x, period);        
    for(x = 0; x < e-period; x++)
        ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);        

   //Begin draw Buy or Sell arrow
   int vv=Bars-IndicatorCounted();
   for(int i=0; i<vv; i++)
   {
    double sg1 = iCustom(NULL,0,"YangTrader",TimeWindow,Sensitive,0,i);
    double sg2 = iCustom(NULL,0,"YangTrader",TimeWindow,Sensitive,0,i+1);
     if (sg1>15 && sg2<15)
      buf1[i] = Low[i+1]-15*Point;
     
     if (sg1<80 && sg2>=80)
      buf2[i] = High[i+1]+15*Point;
   }  

  return(0); 
} 

Comments