Relax_GoToSleep_v01_play2_sw
Download scriptThis script functions as a custom technical indicator for the MetaTrader platform, designed to provide visual signals based on specific price fluctuations and momentum shifts. Rather than using standard raw price data alone, the tool introduces a unique layer of "noise" or variance to the calculations to help identify specific trends.
How the Logic Works
1. Data Modification and Randomization The core logic begins by creating a modified version of the market's closing prices. Instead of looking directly at where the price is, the script generates a series of random values within a specific range. It applies these random variations to the actual historical closing prices. This creates a unique, "jittered" data set that serves as the foundation for all subsequent calculations.
2. Moving Average Smoothing Once the modified data set is created, the script calculates a Linear Weighted Moving Average (LWMA). By applying this calculation to the randomized data rather than the raw market data, the indicator seeks to smooth out extreme price spikes and focus on the underlying direction of the movement.
3. Percentage Change Analysis The script then analyzes the relationship between different points in time on this smoothed moving average. Specifically, it compares the current value against values from several bars back (the immediate past). It calculates the percentage difference between these points to determine the strength and velocity of the price move.
4. Signal Generation (The "Hand" Indicator) The final output of the script is a visual signal, represented as an arrow on the chart. The logic for this signal is based on the direction of the percentage change:
- If the calculated movement indicates a positive trend (an upward shift relative to the past), the script prepares one type of visual indicator.
- If the movement indicates a negative trend (a downward shift), it switches to a different visual indicator.
In summary, this tool takes market prices, adds a layer of randomized variance, smooths that data into a moving average, and then monitors the rate of change in that average to provide traders with clear directional signals on the chart.
//=======================================================================================================================
// Relax_GoToSleep.mq4
// (c) 2008 DolSergon
//
// :)
//
//=======================================================================================================================
#property copyright "(c) 2008 DolSergon"
#property link ""
//-------------------------------------------------------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width2 1
#property indicator_color3 Blue
#property indicator_width3 2
#property indicator_color4 White
#property indicator_width4 2
double BufMA[];
double BufFace[];
double BufAir[];
double BufHand[];
double BufMA1[1000];
double BufMA1Rnd[1000];
double BufMA2[];
double BufMA3[];
int Face1 = 74, Face1Pos = 0, FaceDirect = 1;
int AirPos = 0;
double AirPrice;
//=======================================================================================================================
int init() {
IndicatorBuffers(4);
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, BufMA2);
SetIndexStyle (1, DRAW_LINE);
SetIndexBuffer(1, BufMA3);
SetIndexStyle(3, DRAW_NONE);
SetIndexBuffer(3, BufMA);
SetIndexStyle(2, DRAW_ARROW);
SetIndexArrow(2, 71);
SetIndexBuffer(2, BufHand);
SetIndexEmptyValue(2, EMPTY_VALUE);
SetIndexShift(2, 4);
return(0);
}
//=======================================================================================================================
int start() {
int b;
int n;
double val1;
ArraySetAsSeries(BufMA1, true);
ArraySetAsSeries(BufMA1Rnd, true);
// MA1 ----------------------------------------------------------------------------------------
for (b=999; b>=1; b--) {
BufMA1Rnd[b] = BufMA1Rnd[b-1];
}
// Ôóíêöèÿ âîçâðàùàåò ïñåâäîñëó÷àéíîå öåëîå ÷èñëî â äèïàçîíå îò 0 äî 32767.
BufMA1Rnd[0] = (MathRand() / 1000) * Point - 15 * Point;
for (b=0; b<1000; b++) {
BufMA1[b] = Close[b] + BufMA1Rnd[b];
}
for (b=0; b<1000; b++) {
val1 = iMAOnArray(BufMA1, 1000, 7, 0, MODE_LWMA, b);
BufMA[b] = val1;
}
//
for (b=0; b<1000; b++) {
BufMA2[b] =(BufMA[b]-BufMA[b+5])/BufMA[b+5]*1000;
BufMA3[b] =(BufMA[b]-BufMA[b+6])/BufMA[b+6]*1000;
// Hand ---------------------------------------------------------------------------------------
if (BufMA2[0] > 0) {
SetIndexArrow(2, 71);
BufHand[0] = 0;
} else {
SetIndexArrow(2, 72);
BufHand[0] = 0 ;
}
BufHand[1] = EMPTY_VALUE;
}
return(0);
}
Comments