Download MetaTrader 5

Alarm for important price variations

To add comments, please log in or register
niktokokushoku
7
niktokokushoku  

Hello ,

I have been practising my trading for 2 years now .In order to improve my gains , i have been looking for an indicator that would alert me when there are "important" price variations . This could be helpful for nights important fluctuations .

The most appropiate indicator I could find is the Detrended Price Oscillator one .

Howether , there is no alarm at all !

I tried to fix it in order to set an alarm signal when DPO is superior to an given value .

Of course , since I am very bad at programming , it doesn t work ...
Looking for some help to either fix it or to find another suitable indicator .

I think this would be a basic but nether the less ,helful indicator

thanx

dawe


*
Detrended Price Oscillator tries to capture the short-term trend changes.
Indicator's cross with zero is the best indicator of such change.
*/

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue

extern int MA_Period = 10;
extern int BarsToCount = 4000;
//beginning dawe
//extern int Interspread = 20;
//end dawe
int Shift;

//---- buffers
double DPO[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("DPO(" + MA_Period + ")");
IndicatorDigits(Digits);
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, DPO);

Shift = MA_Period / 2 + 1;

return(0);
}

//+------------------------------------------------------------------+
//| Detrended Price Oscillator |
//+------------------------------------------------------------------+
int start()
{
// Too few bars to do anything
if (Bars <= MA_Period) return(0);
// If we don't have enough bars to count as specified in the input
if (BarsToCount >= Bars) BarsToCount = Bars;

SetIndexDrawBegin(0, Bars - BarsToCount + MA_Period + 1);

int counted_bars = IndicatorCounted();

// First MA_Period bars are set to 0 if we have to few bars to display
if (counted_bars < MA_Period)
{
for(int i = 1; i <= MA_Period; i++)
DPO[BarsToCount - i]=0.0;
}
//----

for (i = BarsToCount - MA_Period - 1; i >=0; i--)
{
DPO = Close - iMA(NULL, 0, MA_Period, Shift, MODE_SMA, PRICE_CLOSE, i);

//beginning dawe

//if ( 100* fabs ( DPO ) >=Interspread )
// PlaySound("alert.wav");

//end dawe
}

return(0);
}

Files:
dpi.mq4 3 kb
Paul75
1319
Paul75  

Similar query is asked by another member you can get more info about it here: https://www.mql5.com/en/forum/194680

I hope, it may be helpful for you.

niktokokushoku
7
niktokokushoku  

Hi thanx for the reply .

I didn t use the proper mt4 function . Mathabs is the correct one .

Please find here below a working version of the indicator .

Can be improved of course but with fine tuning of the Interspread var ,alarm can be very helpful indeed !

//+------------------------------------------------------------------+

//| DPO Alert.mq4 |

//| |

//| |

//+------------------------------------------------------------------+

/*

Detrended Price Oscillator tries to capture the short-term trend changes.

Indicator's cross with zero is the best indicator of such change.

*/

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 Blue

extern int MA_Period = 14;

extern int BarsToCount = 400;

extern int Interspread = 1;

int Shift;

//---- buffers

double DPO[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

IndicatorShortName("DPO(" + MA_Period + ")");

IndicatorDigits(Digits);

SetIndexStyle(0, DRAW_LINE);

SetIndexBuffer(0, DPO);

Shift = MA_Period / 2 + 1;

return(0);

}

//+------------------------------------------------------------------+

//| Detrended Price Oscillator Alert |

//+------------------------------------------------------------------+

int start()

{

// Too few bars to do anything

if (Bars <= MA_Period) return(0);

// If we don't have enough bars to count as specified in the input

if (BarsToCount >= Bars) BarsToCount = Bars;

SetIndexDrawBegin(0, Bars - BarsToCount + MA_Period + 1);

int counted_bars = IndicatorCounted();

// First MA_Period bars are set to 0 if we have to few bars to display

if (counted_bars < MA_Period)

{

for(int i = 1; i <= MA_Period; i++)

DPO[BarsToCount - i]=0.0;

}

//----

for (i = BarsToCount - MA_Period - 1; i >=0; i--)

{

DPO = Close - iMA(NULL, 0, MA_Period, Shift, MODE_SMA, PRICE_CLOSE, i);

if ( (100 * MathAbs (DPO)) >= Interspread )
PlaySound("alert.wav");

}

return(0);
}
//+------------------------------------------------------------------+

To add comments, please log in or register