FractalsJPYUPv2
Download scriptThis script is designed as a specialized visual indicator for the MetaTrader 4 platform, specifically tailored to identify and highlight significant price structures across multiple currency pairs simultaneously. Rather than focusing on a single asset, it monitors six specific Japanese Yen (JPY) cross-pairs: GBP/JPY, EUR/JPY, CHF/JPY, CAD/JPY, AUD/JPY, and NZD/JPY.
Core Functionality
The primary logic of the script revolves around identifying "Fractals"—which are patterns in price action that represent local peaks or valleys. Specifically, this tool looks for upper fractals (price peaks) across all six monitored currency pairs at the exact same point in time.
Key Operational Logic:
- Multi-Pair Synchronization: The script scans all six designated currency pairs to see if they are hitting a fractal peak at the same moment. It essentially seeks out "confluence," where multiple markets react similarly at once.
- Dynamic Volatility Adjustment: To ensure the visual markers are relevant to current market conditions, the script uses an Average True Range (ATR) calculation. This means the height or significance of the detected signals is adjusted based on how much the market is currently moving, preventing the indicators from being overwhelmed during high volatility or appearing insignificant during low volatility.
- Visual Signaling: When the script detects these simultaneous price peaks, it places specific visual markers (arrows) on your chart. These markers serve as a visual cue for the trader, highlighting periods where multiple JPY-related currencies are reaching local highs at once.
- Weighted Calculation: The logic includes a system to count how many of the six pairs are hitting their peaks simultaneously. It then applies a mathematical multiplier based on that count. This means that a signal where all six pairs align will be weighted differently than a signal where only two or three pairs align, providing a clearer distinction of "strength" in the market movement.
Summary for the User
In plain terms, this tool acts as a "confluence scanner." Instead of you having to look at six different charts to see if they are all hitting price ceilings at the same time, this script does that work for you. It identifies those specific moments where there is a collective move in the JPY crosses and marks them on your main chart with visual arrows, adjusted automatically for current market volatility.
//+------------------------------------------------------------------+
//| Fractals.mq4 |
//| Copyright © 2007, by 7er |
//| sergik@hitv.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, by 7er"
#property link "sergik@hitv.ru"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 C'130,255,130'
#property indicator_color2 C'87,255,87'
#property indicator_color3 C'43,255,43'
#property indicator_color4 C'0,255,0'
#property indicator_color5 C'0,190,0'
#property indicator_color6 C'0,130,0'
//---- input parameters
extern double k=0.2,ATR=89;
//---- buffers
double FractalsUpGBPJPY[];
double FractalsUpEURJPY[];
double FractalsUpCHFJPY[];
double FractalsUpCADJPY[];
double FractalsUpAUDJPY[];
double FractalsUpNZDJPY[];
double HL;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
if(Point==1) int Dig=0;
if(Point==0.1) Dig=1;
if(Point==0.01) Dig=2;
if(Point==0.001) Dig=3;
if(Point==0.0001) Dig=4;
if(Point==0.00001) Dig=5;
//---- indicator
IndicatorDigits(Dig);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,217);
SetIndexBuffer(0,FractalsUpGBPJPY);
SetIndexEmptyValue(0,0.0);
SetIndexLabel(0,"GBPJPY");
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,217);
SetIndexBuffer(1,FractalsUpEURJPY);
SetIndexEmptyValue(1,0.0);
SetIndexLabel(1,"EURJPY");
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,217);
SetIndexBuffer(2,FractalsUpCHFJPY);
SetIndexEmptyValue(2,0.0);
SetIndexLabel(2,"CHFJPY");
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,217);
SetIndexBuffer(3,FractalsUpCADJPY);
SetIndexEmptyValue(3,0.0);
SetIndexLabel(3,"CADJPY");
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,217);
SetIndexBuffer(4,FractalsUpAUDJPY);
SetIndexEmptyValue(4,0.0);
SetIndexLabel(4,"AUDJPY");
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,217);
SetIndexBuffer(5,FractalsUpNZDJPY);
SetIndexEmptyValue(5,0.0);
SetIndexLabel(5,"NZDJPY");
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
string PAIR=Symbol();
int limit,i,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=limit; i>=0; i--)
{
int FractalsTotal=0;
HL=MathRound(iATR(PAIR,0,ATR,i)*k/Point)*Point;
double POINT=MarketInfo(PAIR,MODE_POINT);
FractalsUpGBPJPY[i]=iFractals("GBPJPY",0,MODE_UPPER,iBarShift("GBPJPY",0,iTime(PAIR,0,i),false));
if (FractalsUpGBPJPY[i]==iHigh("GBPJPY",0,iBarShift("GBPJPY",0,iTime(PAIR,0,i),false))) FractalsTotal++;
FractalsUpEURJPY[i]=iFractals("EURJPY",0,MODE_UPPER,iBarShift("EURJPY",0,iTime(PAIR,0,i),false));
if (FractalsUpEURJPY[i]==iHigh("EURJPY",0,iBarShift("EURJPY",0,iTime(PAIR,0,i),false))) FractalsTotal++;
FractalsUpCHFJPY[i]=iFractals("CHFJPY",0,MODE_UPPER,iBarShift("CHFJPY",0,iTime(PAIR,0,i),false));
if (FractalsUpCHFJPY[i]==iHigh("CHFJPY",0,iBarShift("CHFJPY",0,iTime(PAIR,0,i),false))) FractalsTotal++;
FractalsUpCADJPY[i]=iFractals("CADJPY",0,MODE_UPPER,iBarShift("CADJPY",0,iTime(PAIR,0,i),false));
if (FractalsUpCADJPY[i]==iHigh("CADJPY",0,iBarShift("CADJPY",0,iTime(PAIR,0,i),false))) FractalsTotal++;
FractalsUpAUDJPY[i]=iFractals("AUDJPY",0,MODE_UPPER,iBarShift("AUDJPY",0,iTime(PAIR,0,i),false));
if (FractalsUpAUDJPY[i]==iHigh("AUDJPY",0,iBarShift("AUDJPY",0,iTime(PAIR,0,i),false))) FractalsTotal++;
FractalsUpNZDJPY[i]=iFractals("NZDJPY",0,MODE_UPPER,iBarShift("NZDJPY",0,iTime(PAIR,0,i),false));
if (FractalsUpNZDJPY[i]==iHigh("NZDJPY",0,iBarShift("NZDJPY",0,iTime(PAIR,0,i),false))) FractalsTotal++;
if (FractalsUpGBPJPY[i]==iHigh("GBPJPY",0,iBarShift("GBPJPY",0,iTime(PAIR,0,i),false))) {FractalsUpGBPJPY[i]=iHigh(PAIR,0,i)+((HL)*FractalsTotal);FractalsTotal--;}
if (FractalsUpEURJPY[i]==iHigh("EURJPY",0,iBarShift("EURJPY",0,iTime(PAIR,0,i),false))) {FractalsUpEURJPY[i]=iHigh(PAIR,0,i)+((HL)*FractalsTotal);FractalsTotal--;}
if (FractalsUpCHFJPY[i]==iHigh("CHFJPY",0,iBarShift("CHFJPY",0,iTime(PAIR,0,i),false))) {FractalsUpCHFJPY[i]=iHigh(PAIR,0,i)+((HL)*FractalsTotal);FractalsTotal--;}
if (FractalsUpCADJPY[i]==iHigh("CADJPY",0,iBarShift("CADJPY",0,iTime(PAIR,0,i),false))) {FractalsUpCADJPY[i]=iHigh(PAIR,0,i)+((HL)*FractalsTotal);FractalsTotal--;}
if (FractalsUpAUDJPY[i]==iHigh("AUDJPY",0,iBarShift("AUDJPY",0,iTime(PAIR,0,i),false))) {FractalsUpAUDJPY[i]=iHigh(PAIR,0,i)+((HL)*FractalsTotal);FractalsTotal--;}
if (FractalsUpNZDJPY[i]==iHigh("NZDJPY",0,iBarShift("NZDJPY",0,iTime(PAIR,0,i),false))) {FractalsUpNZDJPY[i]=iHigh(PAIR,0,i)+((HL)*FractalsTotal);FractalsTotal--;}
}
return(0);
}
Comments