fisher_org_v1_sign
Download scriptThis script is a technical trading indicator designed to identify specific momentum shifts in the financial markets. Instead of providing a constant line or trend, it functions as a signaling tool that places visual markers (arrows) on your chart to highlight potential "Buy" and "Sell" zones based on price volatility and overextended movements.
Core Operational Logic
The script operates by analyzing three primary layers of data:
1. Range and Relative Positioning The indicator looks at a specific window of recent history (defined by the "Length" setting) to determine the highest high and lowest low prices. It then calculates where the current price sits relative to that range. This helps the script understand if the price is currently "stretched" toward the top or bottom of its recent movement.
2. Smoothing and Momentum Calculation To prevent the signals from being triggered by minor, insignificant price flickers, the script applies a smoothing process. It takes the relative position calculated above and blends it with previous data points. This creates a fluid momentum value. The logic specifically focuses on the rate of change in this momentum, allowing it to distinguish between a steady trend and a sudden, aggressive surge or drop.
3. Threshold Crossing (The Trigger) This is the "decision-making" part of the script. It monitors for two specific conditions:
- Overbought/Oversold Transitions: The script looks for moments when the momentum value crosses predefined levels (the "UpLevel" and "DnLevel").
- Directional Confirmation: A signal is only generated when the momentum moves from one side of a threshold to another. For example, a "Sell" signal isn't triggered just because the price is high; it is triggered specifically when the momentum value drops below a certain intensity threshold from an elevated position.
Visual Outputs
When the logic confirms a significant shift in momentum based on the criteria above, the script performs the following actions:
- Buy Signals (Blue Arrows): When the momentum indicates a reversal from a downward stretch into upward movement, the script places a blue arrow below the price candle. The exact vertical position of this arrow is adjusted dynamically using the Average True Range (ATR)—a measure of market volatility—to ensure the arrow stays clearly visible regardless of how "fast" or "slow" the market is moving.
- Sell Signals (Deep Pink Arrows): When the momentum indicates a reversal from an upward stretch into downward movement, the script places a deep pink arrow above the price candle. Similar to the buy signal, this is adjusted by the ATR to maintain a professional distance from the price action.
Summary for the User
In simple terms, this tool acts as a "reversal scout." It monitors how hard the market is pushing in one direction and waits for the momentum to lose its strength and "snap" back. When that snap occurs, it marks the spot with an arrow, suggesting that the previous trend may be losing steam and a move in the opposite direction could be beginning.
//+------------------------------------------------------------------+
//| Fisher_org_v1_Sign.mq5 |
//| Copyright © 2006, TrendLaboratory Ltd. |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//| E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
//---- àâòîðñòâî èíäèêàòîðà
#property copyright "Copyright © 2005, TrendLaboratory Ltd."
//---- àâòîðñòâî èíäèêàòîðà
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"
//---- íîìåð âåðñèè èíäèêàòîðà
#property version "1.00"
//--- îòðèñîâêà èíäèêàòîðà â ãëàâíîì îêíå
#property indicator_chart_window
//--- äëÿ ðàñ÷åòà è îòðèñîâêè èíäèêàòîðà èñïîëüçîâàíî äâà áóôåðà
#property indicator_buffers 2
//--- èñïîëüçîâàíî âñåãî äâà ãðàôè÷åñêèõ ïîñòðîåíèÿ
#property indicator_plots 2
//+----------------------------------------------+
//| Ïàðàìåòðû îòðèñîâêè ìåäâåæüåãî èíäèêàòîðà |
//+----------------------------------------------+
//--- îòðèñîâêà èíäèêàòîðà 1 â âèäå ñèìâîëà
#property indicator_type1 DRAW_ARROW
//--- â êà÷åñòâå öâåòà ìåäâåæüåãî èíäèêàòîðà èñïîëüçîâàí DeepPink öâåò
#property indicator_color1 clrDeepPink
//--- òîëùèíà ëèíèè èíäèêàòîðà 1 ðàâíà 4
#property indicator_width1 4
//--- îòîáðàæåíèå áû÷åé ìåòêè èíäèêàòîðà
#property indicator_label1 "Fisher_org_v1 Sell"
//+----------------------------------------------+
//| Ïàðàìåòðû îòðèñîâêè áû÷üãî èíäèêàòîðà |
//+----------------------------------------------+
//--- îòðèñîâêà èíäèêàòîðà 2 â âèäå ñèìâîëà
#property indicator_type2 DRAW_ARROW
//--- â êà÷åñòâå öâåòà áû÷üåãî èíäèêàòîðà èñïîëüçîâàí Blue öâåò
#property indicator_color2 clrBlue
//--- òîëùèíà ëèíèè èíäèêàòîðà 2 ðàâíà 4
#property indicator_width2 4
//--- îòîáðàæåíèå ìåäâåæüåé ìåòêè èíäèêàòîðà
#property indicator_label2 "Fisher_org_v1 Buy"
//+----------------------------------------------+
//| Îáúÿâëåíèå êîíñòàíò |
//+----------------------------------------------+
#define RESET 0 // êîíñòàíòà äëÿ âîçâðàòà òåðìèíàëó êîìàíäû íà ïåðåñ÷åò èíäèêàòîðà
//+----------------------------------------------+
//| îáúÿâëåíèå ïåðå÷èñëåíèé |
//+----------------------------------------------+
enum ENUM_APPLIED_PRICE_ //Òèï êîíñòàíòû
{
PRICE_CLOSE_ = 1, //PRICE_CLOSE
PRICE_OPEN_, //PRICE_OPEN
PRICE_HIGH_, //PRICE_HIGH
PRICE_LOW_, //PRICE_LOW
PRICE_MEDIAN_, //PRICE_MEDIAN
PRICE_TYPICAL_, //PRICE_TYPICAL
PRICE_WEIGHTED_, //PRICE_WEIGHTED
PRICE_SIMPL_, //PRICE_SIMPL_
PRICE_QUARTER_, //PRICE_QUARTER_
PRICE_TRENDFOLLOW0_, //PRICE_TRENDFOLLOW0_
PRICE_TRENDFOLLOW1_, // TrendFollow_2 Price
PRICE_DEMARK_ // Demark Price
};
//+----------------------------------------------+
//| Âõîäíûå ïàðàìåòðû èíäèêàòîðà |
//+----------------------------------------------+
input uint ATR_Period=14;
input uint Length=7; // ãëóáèíà ñãëàæèâàíèÿ
input ENUM_APPLIED_PRICE_ IPC=PRICE_CLOSE_; // öåíîâàÿ êîíñòàíòà
input double UpLevel=+1.5; // óðîâåíü ïåðåêóïëåííîñòè
input double DnLevel=-1.5; // óðîâåíü ïåðåïðîäàííîñòè
input int Shift=0; // Ñäâèã èíäèêàòîðà ïî ãîðèçîíòàëè â áàðàõ
//+----------------------------------------------+
//--- îáúÿâëåíèå äèíàìè÷åñêèõ ìàññèâîâ, êîòîðûå â äàëüíåéøåì
//--- áóäóò èñïîëüçîâàíû â êà÷åñòâå èíäèêàòîðíûõ áóôåðîâ
double SellBuffer[];
double BuyBuffer[];
//---- îáúÿâëåíèå öåëî÷èñëåííûõ ïåðåìåííûõ íà÷àëà îòñ÷åòà äàííûõ
int min_rates_total,ATR_Handle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- ïîëó÷åíèå õåíäëà èíäèêàòîðà ATR
ATR_Handle=iATR(NULL,0,ATR_Period);
if(ATR_Handle==INVALID_HANDLE)
{
Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà ATR");
return(INIT_FAILED);
}
//---- èíèöèàëèçàöèÿ ïåðåìåííûõ íà÷àëà îòñ÷åòà äàííûõ
min_rates_total=int(MathMax(Length,ATR_Period))+1;
//--- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà â èíäèêàòîðíûé áóôåð
SetIndexBuffer(0,SellBuffer,INDICATOR_DATA);
//--- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷åòà îòðèñîâêè èíäèêàòîðà 1
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
//--- ñèìâîë äëÿ èíäèêàòîðà
PlotIndexSetInteger(0,PLOT_ARROW,226);
//--- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà â èíäèêàòîðíûé áóôåð
SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA);
//--- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷åòà îòðèñîâêè èíäèêàòîðà 2
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);
//--- ñèìâîë äëÿ èíäèêàòîðà
PlotIndexSetInteger(1,PLOT_ARROW,225);
//---- èíèöèàëèçàöèè ïåðåìåííîé äëÿ êîðîòêîãî èìåíè èíäèêàòîðà
string shortname;
StringConcatenate(shortname,"Fisher_org_v1_Sign(",Length,")");
//---- ñîçäàíèå èìåíè äëÿ îòîáðàæåíèÿ â îòäåëüíîì ïîäîêíå è âî âñïëûâàþùåé ïîäñêàçêå
IndicatorSetString(INDICATOR_SHORTNAME,shortname);
//---- îïðåäåëåíèå òî÷íîñòè îòîáðàæåíèÿ çíà÷åíèé èíäèêàòîðà
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//---- çàâåðøåíèå èíèöèàëèçàöèè
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, // êîëè÷åñòâî èñòîðèè â áàðàõ íà òåêóùåì òèêå
const int prev_calculated,// êîëè÷åñòâî èñòîðèè â áàðàõ íà ïðåäûäóùåì òèêå
const datetime &time[],
const double &open[],
const double& high[], // öåíîâîé ìàññèâ ìàêñèìóìîâ öåíû äëÿ ðàñ÷åòà èíäèêàòîðà
const double& low[], // öåíîâîé ìàññèâ ìèíèìóìîâ öåíû äëÿ ðàñ÷åòà èíäèêàòîðà
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//--- ïðîâåðêà êîëè÷åñòâà áàðîâ íà äîñòàòî÷íîñòü äëÿ ðàñ÷åòà
if(BarsCalculated(ATR_Handle)<rates_total || rates_total<min_rates_total) return(RESET);
//---- îáúÿâëåíèÿ ëîêàëüíûõ ïåðåìåííûõ
int first,bar;
double smax,smin,price,wpr,Value0,res1,res2,ATR[1],Fish0;
static double Value1,Fish1;
//---- ðàñ÷åò ñòàðòîâîãî íîìåðà first äëÿ öèêëà ïåðåñ÷åòà áàðîâ
if(prev_calculated>rates_total || prev_calculated<=0) // ïðîâåðêà íà ïåðâûé ñòàðò ðàñ÷åòà èíäèêàòîðà
{
first=min_rates_total-1; // ñòàðòîâûé íîìåð äëÿ ðàñ÷åòà âñåõ áàðîâ
Value1=0.0;
Fish1=0.0;
}
else first=prev_calculated-1; // ñòàðòîâûé íîìåð äëÿ ðàñ÷åòà íîâûõ áàðîâ
//---- îñíîâíîé öèêë ðàñ÷åòà èíäèêàòîðà
for(bar=first; bar<rates_total && !IsStopped(); bar++)
{
smax=0.0;
smin=9999999999.0;
for(int iii=0; iii<int(Length); iii++)
{
int barx=bar-iii;
smax=MathMax(smax,high[barx]);
smin=MathMin(smin,low[barx]);
}
if(smax==smin) smax+=_Point;
price=PriceSeries(IPC,bar,open,low,high,close);
wpr=(price-smin)/(smax-smin);
Value0=(wpr-0.5)+0.67*Value1;
Value0=MathMin(Value0,+999);
Value0=MathMax(Value0,-999);
res1=1.0-Value0;
if(!res1) res1=1.0;
res2=(1.0+Value0)/(1.0-Value0);
if(res2<0.0000001) res2=1.0;
Fish0=0.5*MathLog(res2)+0.5*Fish1;
//---
BuyBuffer[bar]=NULL;
SellBuffer[bar]=NULL;
//---
if(Fish0>DnLevel && Fish1<=DnLevel)
{
//--- êîïèðóåì âíîâü ïîÿâèâøèåñÿ äàííûå â ìàññèâ ATR[]
if(CopyBuffer(ATR_Handle,0,time[bar],1,ATR)<=0) return(RESET);
BuyBuffer[bar]=low[bar]-ATR[0]*3/8;
}
//---
if(Fish0<UpLevel && Fish1>=UpLevel)
{
//--- êîïèðóåì âíîâü ïîÿâèâøèåñÿ äàííûå â ìàññèâ ATR[]
if(CopyBuffer(ATR_Handle,0,time[bar],1,ATR)<=0) return(RESET);
SellBuffer[bar]=high[bar]+ATR[0]*3/8;
}
if(bar<rates_total-1)
{
Value1=Value0;
Fish1=Fish0;
}
}
//----
return(rates_total);
}
//+------------------------------------------------------------------+
//| Ïîëó÷åíèå çíà÷åíèÿ öåíîâîé òàéìñåðèè |
//+------------------------------------------------------------------+
double PriceSeries(uint applied_price,// Öåíîâàÿ êîíñòàíòà
uint bar,// Èíäåêñ ñäâèãà îòíîñèòåëüíî òåêóùåãî áàðà íà óêàçàííîå êîëè÷åñòâî ïåðèîäîâ íàçàä èëè âïåð¸ä).
const double &Open[],
const double &Low[],
const double &High[],
const double &Close[])
{
//----
switch(applied_price)
{
//---- Öåíîâûå êîíñòàíòû èç ïåðå÷èñëåíèÿ ENUM_APPLIED_PRICE
case PRICE_CLOSE: return(Close[bar]);
case PRICE_OPEN: return(Open [bar]);
case PRICE_HIGH: return(High [bar]);
case PRICE_LOW: return(Low[bar]);
case PRICE_MEDIAN: return((High[bar]+Low[bar])/2.0);
case PRICE_TYPICAL: return((Close[bar]+High[bar]+Low[bar])/3.0);
case PRICE_WEIGHTED: return((2*Close[bar]+High[bar]+Low[bar])/4.0);
//----
case 8: return((Open[bar] + Close[bar])/2.0);
case 9: return((Open[bar] + Close[bar] + High[bar] + Low[bar])/4.0);
//----
case 10:
{
if(Close[bar]>Open[bar])return(High[bar]);
else
{
if(Close[bar]<Open[bar])
return(Low[bar]);
else return(Close[bar]);
}
}
//----
case 11:
{
if(Close[bar]>Open[bar])return((High[bar]+Close[bar])/2.0);
else
{
if(Close[bar]<Open[bar])
return((Low[bar]+Close[bar])/2.0);
else return(Close[bar]);
}
break;
}
//----
case 12:
{
double res=High[bar]+Low[bar]+Close[bar];
if(Close[bar]<Open[bar]) res=(res+Low[bar])/2;
if(Close[bar]>Open[bar]) res=(res+High[bar])/2;
if(Close[bar]==Open[bar]) res=(res+Close[bar])/2;
return(((res-Low[bar])+(res-High[bar]))/2);
}
//----
default: return(Close[bar]);
}
//----
//return(0);
}
//+------------------------------------------------------------------+
Comments