-
Notifications
You must be signed in to change notification settings - Fork 1
/
PPO.mq4
67 lines (67 loc) · 2.62 KB
/
PPO.mq4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//+------------------------------------------------------------------+
//| PPO.mq4 |
//| Copyright © 2007 Tom Balfe |
//| |
//| Percentage Price Oscillator |
//| This is a momentum indicator. |
//| Signal line is EMA of PPO. |
//| |
//| Follows formula: (FastEMA-SlowEMA)/SlowEMA |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007 Tom Balfe"
#property link "[email protected]"
//----
#property indicator_separate_window
#property indicator_buffers 2
//----
#property indicator_color1 SkyBlue
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 1
#property indicator_style2 2
//---- user changeable stuff
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalEMA=9;
//---- two buffers
double PPOBuffer[];
double SignalBuffer[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,SignalEMA);
IndicatorDigits(Digits+1);
SetIndexBuffer(0,PPOBuffer);
SetIndexBuffer(1,SignalBuffer);
//----
IndicatorShortName("PPO ("+FastEMA+","+SlowEMA+","+SignalEMA+")");
SetIndexLabel(0,"PPO");
SetIndexLabel(1,"Signal");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- (FastEMA-SlowEMA)/SlowEMA
//---- PPO counted in the 1st buffer
for(int i=0; i<limit; i++)
PPOBuffer[i]=(iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i))/
iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2nd buffer
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(PPOBuffer,Bars,SignalEMA,0,MODE_EMA,i);
return(0);
}
//+------------------------------------------------------------------+