VininI_Cyber_Cycle_V2_My5[1]
Download scriptThis script is a technical analysis tool designed to identify cyclical trends and potential market turning points by analyzing price movements. Instead of simply looking at the current price, it uses a multi-step mathematical process to smooth out "noise" and normalize data into a readable format.
How the Logic Works
1. Data Smoothing (Price Averaging) The script begins by calculating a smoothed average of the market price. Rather than relying on a single data point (like the current closing price), it takes a weighted average of the current bar and several preceding bars. This helps to filter out sudden, erratic price spikes and provides a clearer picture of the underlying trend.
2. Cycle Calculation Once the prices are smoothed, the script applies a specific mathematical formula to determine the "Cycle." This step is designed to detect the momentum and rhythm of the market. It compares the current smoothed value against previous values to see how the movement is evolving over time.
3. Dynamic Normalization One of the most important features of this script is how it handles different markets. Because every asset (like Gold, EURUSD, or Bitcoin) has a different price range, the script automatically calculates the "range" of the cycle over a specific window of time (defaulting to 1,000 bars). It identifies the highest and lowest points reached in that window and shrinks the data into a standard scale. This ensures that the indicator behaves consistently regardless of whether you are trading an asset with high prices or low prices.
4. Signal Conversion (The Sigmoid Function) After normalizing the cycle, the script applies a specific mathematical curve (a sigmoid function) to transform the data. This converts the raw cyclical movement into a value bounded between -1 and 1. This makes it much easier for a trader to visualize:
- Positive values represent upward momentum.
- Negative values represent downward momentum.
5. Visual Buy/Sell Signals Finally, the script looks for specific "thresholds" within that -1 to 1 range:
- If the normalized value rises above 0.5, it marks a potential Buy area.
- If the normalized value drops below -0.5, it marks a potential Sell area.
Summary for the User
The tool essentially takes messy market data, smooths it out to find the "heartbeat" of the trend, scales it so it fits perfectly on your screen regardless of the asset type, and then highlights specific zones where momentum is strongest in either direction.
//+------------------------------------------------------------------+
//| VininI_Cyber |
//| Copyright © 2009, Victor Nicolaev |
//| e-mail: vinin@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Victor Nicolaev"
#property link "e-mail: vinin@mail.ru"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_level1 -0.5
#property indicator_level2 0
#property indicator_level3 0.5
#property indicator_minimum -1.05
#property indicator_maximum 1.05
//---- input parameters
extern double alpha=0.01;
extern double betta=1.0;
extern int price_mode=4;
extern double NormalizeTarget=7.5; // èíòåðâàë [-NormalizeTarget,+NormalizeTarget]
// íà êîòîðûé íîðìèðóåòñÿ çíà÷åíèå èíäèêàòîðà
extern int BarInWindow=1000; // øèðèíà îêíà äëÿ íîðìèðîâêè â áàðàõ
extern bool prn=false; // âêëþ÷èò ïå÷àòü â æóðíàë
//---- buffers
double Cycle[];
double Smonth[];
double iCycle[];
double Buy[];
double Sell[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
IndicatorBuffers(5);
SetIndexBuffer(0, iCycle);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(1, Buy);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(2, Sell);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(3, Smonth);
SetIndexBuffer(4, Cycle);
IndicatorShortName("VininI_Cyber_Cycle_Norm_Gom");
return(0);
}
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
//---------çàäàåòñÿ øèðèíà îêíà ïî óìîë÷àíèþ 1000
if( BarInWindow <= 0 )BarInWindow=1000;
int counted_bars = IndicatorCounted();
if (counted_bars < 0) return(-1);
if (counted_bars > 0) counted_bars--;
int limit=Bars - counted_bars;
for(int i = limit; i >= 0; i--) {
Smonth[i]=(Price(i)+2.0*Price(i+1)+2.0*Price(i+2)+Price(i+3))/6.0;
}
for(i = limit; i >= 0; i--)
{
//===!!!===Çäåñü ìîæíî âñòàâèòü âû÷èñëåíèå ëþáîãî èíäèêàòîðà, åñëè óäàëüèòü ïðåäûäóùèé öèêë
Cycle[i]=betta*((1.0-0.5*alpha)*(1.0-0.5*alpha)*(Smonth[i]-2.0*Smonth[i+1]+Smonth[i+2])+2.0*(1.0-alpha)*Cycle[i+1]-(1.0-alpha)*(1.0-alpha)*Cycle[i+2]);
//------êîíòðîëüíàÿ ïå÷àòü
if( prn && i<2 )Print("j=",i," cycle ",Cycle[i]);
}
//------- Âû÷èñë. äèàïàçîí èçìåíåíèé èíäèêàòîðà â îêíå áàð [1,BarInWindow]
int iMax = ArrayMaximum(Cycle,BarInWindow,0);double Max=Cycle[iMax];
int iMin = ArrayMinimum(Cycle,BarInWindow,0);double Min=Cycle[iMin];
//--------Âû÷èñëÿåì êîýôô ãîìîòåòèè ñ öåòðîì â 0 îòíîñèòåëüíî ìàêñèìàëüíî óäàëåííîé òî÷êè
if( MathAbs(Max) > MathAbs(Min) ) double Gomot=MathAbs(Max);else Gomot=MathAbs(Min);
double KGomot = NormalizeTarget/Gomot;
//--------Êîíòðîëüíàÿ ïå÷àòü
if( prn)Print( "Min ",Min," Max ",Max," Gomot ",Gomot," KGomot ",KGomot);
for(i = limit; i >= 0; i--) {
//-------ïðåîáðàçîâàíèå [min,0][0,max] ïî ãîìîòåòèè â òî÷êå 0 ñ êîýôô KGomot
double NCycle = KGomot*Cycle[i];
//--------êîíòðîëüíàÿ ïå÷àòü
if(prn && i< 2 ) Print("i=",i,"[Min,Max]-> [y,N] ",NCycle," ",Cycle[i]);
//---------îáð. ïðåîáð.Ôèøåðà
iCycle[i]=(MathExp(2.0*NCycle)-1.0)/(MathExp(2.0*NCycle)+1.0);
//--------êîíòðîëüíàÿ ïå÷àòü
if(prn && i< 2 ) Print("i=",i," [y,N]->Ôèøåð ",NCycle," ",iCycle[i]);
if (iCycle[i]>= 0.5) {Buy[i]=iCycle[i];Buy[i+1]=iCycle[i+1];}
if (iCycle[i]<=-0.5) {Sell[i]=iCycle[i];Sell[i+1]=iCycle[i+1];}
}
return(0);
}
//+------------------------------------------------------------------+
double Price(int pos){
switch (price_mode){
case PRICE_CLOSE: return(Close[pos]);
case PRICE_OPEN: return(Open[pos]);
case PRICE_HIGH: return(High[pos]);
case PRICE_LOW: return(Low[pos]);
case PRICE_MEDIAN: return((High[pos]+Low[pos])/2.0);
case PRICE_TYPICAL: return((High[pos]+Low[pos]+Close[pos])/3.0);
case PRICE_WEIGHTED: return((High[pos]+Low[pos]+Close[pos]+Close[pos])/4.0);
}
}
Comments