VininI_Cyber_Cycle
Download scriptThis tool is designed as a specialized technical indicator for trading platforms, specifically engineered to identify cyclical trends and momentum shifts in financial markets. Rather than simply looking at raw price action, the script processes data through several layers of mathematical smoothing and oscillation logic to help traders distinguish between "noise" and actual market cycles.
Data Processing & Smoothing
The logic begins by establishing a foundational baseline for the price. Instead of relying on a single data point (like just the current price), it calculates a weighted average based on a specific window of previous prices. By giving more importance to the immediate past, the tool creates a "smoothed" version of the market movement. This helps neutralize minor, erratic fluctuations and provides a clearer picture of the underlying direction.
Cycle Analysis
Once the price is smoothed, the script applies a complex cyclical calculation. This stage is designed to measure the momentum of the price movement relative to its own history. It analyzes the acceleration and deceleration of the trends to determine where the market is in its current cycle.
To ensure this data remains readable and actionable for a human trader, the results are converted into an oscillating value. This transforms the raw calculations into a standardized range that moves between positive and negative values, making it much easier to visualize the strength of a trend at any given moment.
Trading Signals
The final stage of the logic translates these mathematical cycles into visual cues for the user:
- Buy Signals: When the calculated cycle momentum rises above a specific positive threshold, the tool identifies a potential upward trend.
- Sell Signals: When the cycle momentum falls below a specific negative threshold, the tool identifies a potential downward trend.
Customization
The script is built with flexibility in mind, allowing users to choose which price data point (such as Close, Open, High, Low, or various averages) serves as the foundation for all subsequent calculations. This ensures that the indicator can be tailored to suit different trading styles or specific types of assets.
//+------------------------------------------------------------------+
//| 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 int price_mode=4;
//---- 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);
return(0);
}
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
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]=(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];
iCycle[i]=(MathExp(2.0*Cycle[i])-1.0)/(MathExp(2.0*Cycle[i])+1.0);
if (iCycle[i]>= 0.5) Buy[i]=iCycle[i];
if (iCycle[i]<=-0.5) Sell[i]=iCycle[i];
}
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