NDuet_v1
Download scriptThis tool is designed to assist traders by identifying specific market trends and potential entry points using a combination of price action patterns, moving averages, and momentum indicators. By analyzing historical data, it filters out "noise" to highlight moments where the market shows clear directional intent.
Core Analytical Components
The logic relies on several layers of information to make its determinations:
- Moving Averages: The script tracks two different types of "smoothed" price averages (Short-term and Long-term). It compares these against each other to gauge the strength of the current trend. By looking at how these averages interact, the tool can sense if the market is accelerating or losing momentum.
- Trend Measurement: It calculates the rate of change between price points over a specific period. This helps the script confirm whether the immediate price movement is positive or negative in terms of actual distance traveled.
- CCI (Commodity Channel Index): This is used as a momentum oscillator. It helps the tool understand if the market is currently overextended or moving in a way that suggests a potential reversal or continuation.
- ZigZag Integration: The script references a "ZigZag" pattern, which is a classic method for identifying major structural highs and lows in price history, helping to filter out minor fluctuations.
How the Logic Works
The script continuously monitors the market to find a specific "confluence"—a moment where multiple technical conditions align simultaneously:
- For Buy Signals: The script looks for a scenario where the short-term trend is moving upward, but specifically when the price action is contained within a certain range. It checks that the shorter moving average is positioned above the longer one, that momentum (CCI) is at a specific level, and that the overall price trend is positive. When all these factors align, it marks a potential upward move.
- For Sell Signals: Conversely, the logic seeks a scenario where the short-term trend is moving downward. It looks for the shorter moving average to be below the longer one, accompanied by negative momentum and a downward price trend.
Visual Output
Instead of just providing raw data, the script translates these complex calculations into clear visual cues on your chart:
- Trend Lines: It plots the different moving averages so you can visually see the "path" the price is following.
- Directional Arrows: When the specific mathematical conditions for a buy or sell are met, the script places an arrow (Aqua for potential upward moves and Red for potential downward moves) on the chart to alert the user to the signal.
//+------------------------------------------------------------------+
//| NDuet.mq4 |
//| Copyright © 2006, Tartan |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//----
#property indicator_separate_window
#property indicator_buffers 4
//----
extern int sper=55;
extern int fper=21;
extern int nBar=300;
extern int depth=15;
extern int deviation=5;
extern int backstep=3;
extern int per=14;
//+------------------------------------------------------------------+
//| Local variables |
//+------------------------------------------------------------------+
//double Close = 0;
//double High = 0;
//double Low = 0;
int shift=0;
double i=0;
double mas=0;
double maf=0;
double zz=0;
double zzold=0;
double mstwo=0;
double mftwo=0;
double blokb=0;
double bloks=0;
double cci=0;
double trend=0;
//---- buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE,EMPTY,EMPTY,Lime);
SetIndexStyle(1,DRAW_LINE,EMPTY,EMPTY,Red);
SetIndexBuffer(0,ExtMapBuffer);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(3,DRAW_ARROW,EMPTY,1,Aqua);
SetIndexArrow(3,241);
SetIndexBuffer(3,ExtMapBuffer3);
SetIndexLabel(3,"UpArrow");
// SetIndexEmptyValue(3,0.0);
SetIndexStyle(4,DRAW_ARROW,EMPTY,1,Red);
SetIndexArrow(4,242);
SetIndexBuffer(4,ExtMapBuffer4);
SetIndexLabel(4,"DownArrow");
// SetIndexEmptyValue(4,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
for(shift=nBar;shift>=0 ;shift--)
{
if(zz!=0 && zzold!=zz)zzold=zz;
zz=iCustom(NULL, 0, "ZigZag",depth,deviation,backstep,shift);
cci=iCCI(NULL, 0, per, PRICE_CLOSE, shift);
trend=((Close[shift+fper]-Close[shift])/Point);
mas=iMA(NULL, 0, sper, 0, MODE_EMA, PRICE_CLOSE, shift);
mstwo=iMA(NULL, 0, sper, 0, MODE_EMA, PRICE_CLOSE, shift+2);
maf=iMA(NULL, 0, fper, 0, MODE_EMA, PRICE_CLOSE, shift);
mftwo=iMA(NULL, 0, fper, 0, MODE_EMA, PRICE_CLOSE, shift+2);
//----
ExtMapBuffer[shift]=mas;
ExtMapBuffer2[shift]=maf;
//----
if(mas>maf && ((mas-maf)/Point)<10 && ((mas-maf)/Point)>0 && mstwo<mftwo && cci<0 && trend>0 && bloks==0)
{
bloks=1;blokb=0; ExtMapBuffer3[shift]=High[shift]+3*Point;
}
if(mas<maf && ((maf-mas)/Point)<10 && ((maf-mas)/Point)>0 && mstwo>mftwo && cci>0 && trend<0 && blokb==0 )
{
blokb=1;bloks=0; ExtMapBuffer4[shift]=Low[shift]-3*Point;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments