10Min_2ind_v1
Download scriptThis script is designed as a technical analysis tool for the MetaTrader platform, specifically tailored to identify potential trading opportunities by monitoring price trends and momentum. It functions by scanning historical and real-time data to detect specific "crossovers" between different types of moving averages, while simultaneously filtering these signals through secondary momentum indicators.
Core Logic and Mechanics
The logic operates on three primary layers of analysis:
1. Trend Identification (Moving Averages) The foundation of the script is based on the relationship between two different types of Moving Averages (MA):
- Linear Weighted Moving Average (LWMA): This reacts more quickly to recent price changes.
- Simple Moving Average (SMA): This provides a smoother, slower view of the overall trend.
The tool looks for "crosses"—moments where these two lines intersect. When the faster LWMA crosses above the slower SMA, it suggests upward momentum. Conversely, when the LWMA crosses below the SMA, it suggests downward momentum.
2. Momentum Filtering (RSI and Stochastic) To increase accuracy and reduce "false signals," the script doesn't just rely on the moving average crossover. It checks two additional indicators to confirm the strength of the move:
- Relative Strength Index (RSI): Used to determine if the price is gaining enough strength to sustain a trend.
- Stochastic Oscillator: Used to measure the speed and change of price movements.
3. Visual Signaling Once the script identifies a crossover and confirms it with the secondary indicators, it plots specific visual markers directly on your trading chart:
- Arrows: Indicate the primary direction of a trend (Up or Down) based on the moving average crossover.
- Squares/Dots: These serve as additional confirmation layers. They appear only when specific conditions are met—such as the RSI being above or below certain thresholds (e.g., 52 for bullish strength or 48 for bearish weakness) alongside the moving average cross.
Summary of Execution
The script processes the price history bar-by-bar. For every new candle, it calculates the current values of all four indicators and compares them to the previous candle's values. If a crossover occurs, it evaluates the RSI and Stochastic levels to decide which specific visual signal (Arrow, Square, or Dot) to display on the screen, providing the trader with a multi-layered confirmation of market sentiment in real-time.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 10 Minute trader |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link "http://www.lightpatch.com"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 White // arrow up for moving average
#property indicator_color2 White // arrow down for moving average
#property indicator_color3 Aqua // box for stoch
#property indicator_color4 Red // box for rsi
#property indicator_color5 White // box for macd
#property indicator_color6 White // dot for early stoch cross
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
// User Input
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
// 233 up arrow
// 234 down arrow
// 159 big dot
// 168 open square
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexArrow(0,233); //up
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexArrow(1,234); //down
SetIndexStyle(2,DRAW_ARROW);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexArrow(2,168); //open square
SetIndexStyle(3,DRAW_ARROW);
SetIndexBuffer(3, ExtMapBuffer4);
SetIndexArrow(3,168); //open square
SetIndexStyle(4,DRAW_ARROW);
SetIndexBuffer(4, ExtMapBuffer5);
SetIndexArrow(4,168); //open square
SetIndexStyle(5,DRAW_ARROW);
SetIndexBuffer(5, ExtMapBuffer6);
SetIndexArrow(5,159); //dot
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
int i;
for( i=0; i<Bars; i++ ) ExtMapBuffer1[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer2[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer3[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer4[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer5[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer6[i]=0;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double wma=0, wma_p=0; // linear Weighted Moving Average & Previous
double sma=0, sma_p=0; // Simple Moving Average & Previous
double stochm=0, stochm_p=0; // STOCHastic Main & Previous
double stochs=0, stochs_p=0; // STOCHastic Signal
double rsi=0; // Relative Strength Indicator
double rsi1=0, rsi2=0; // 1st 2 periods of past history
double rsi3=0, rsi4=0; // 2nd 2 periods
int pos=Bars-100; // leave room for moving average periods
while(pos>=0)
{
wma_p=wma; // save previous calculations
wma=iMA(Symbol(),0,10,0,MODE_LWMA,PRICE_CLOSE,pos);
sma_p=sma; // save previous calculations
sma=iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,pos);
stochm_p=stochm;
stochm=iStochastic(Symbol(),0,10,6,6,0,1,0,pos);
stochs_p=stochs;
stochs=iStochastic(Symbol(),0,10,6,6,0,1,1,pos);
rsi=iRSI(Symbol(),0,28,PRICE_CLOSE,pos);
rsi1=iRSI(Symbol(),0,28,PRICE_CLOSE,pos+1);
rsi2=iRSI(Symbol(),0,28,PRICE_CLOSE,pos+2);
rsi3=iRSI(Symbol(),0,28,PRICE_CLOSE,pos+3);
rsi4=iRSI(Symbol(),0,28,PRICE_CLOSE,pos+4);
// RISING stochastic cross
// if (stochm_p>stochm && stochs_p<stochs && stochs>stochm)
// FALLING stochastic cross
// if (stochm_p<stochm && stochs_p>stochs && stochs<stochm)
if ( wma_p < sma_p && wma > sma )
{
ExtMapBuffer1[pos]=wma - 0.0006;
if (rsi > 52 ) //blue
{
ExtMapBuffer3[pos]=wma + 0.0003;
}
if (stochm > stochs) //red
{
ExtMapBuffer4[pos]=wma + 0.0006;
}
// if ( rsi>55 && (rsi1<45||rsi2<45||rsi3<45) && (stochm>80||stochs>80) ) //white
if ( rsi > 55 ) //white
{
ExtMapBuffer5[pos]=wma + 0.0009;
}
}
if ( wma_p > sma_p && wma < sma )
{
ExtMapBuffer2[pos]=wma + 0.0006;
if (rsi < 48 )
{
ExtMapBuffer3[pos]=wma - 0.0003;
}
if (stochm < stochs)
{
ExtMapBuffer4[pos]=wma - 0.0006;
}
// if ( rsi<45 && (rsi1>55||rsi2>55||rsi3>55) && (stochm<20||stochs<20) ) //white
if ( rsi < 45 ) //white
{
ExtMapBuffer5[pos]=wma - 0.0009;
}
}
pos--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments