PSY Indicator in MQ4

2013-02-13 191 words 1 min read

A few days ago, I just met Binary Option.
After studying this game, I think PSY indicator may be useful to perdict which bar will be up or down.
I noticed MetaTrader itself did not include this indicator.
It is easy to program. PSY is used to display how many bars are up in certain bars.
I think it perhaps is useful for Binary Option 60 Seconds Call or Put Trade.
So here it is.

#property copyright "Jesse Lau"
#property link      "https://jesselau.com/"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int PSYPeriod=9;
//---- buffers
double PSYBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(3);

//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,PSYBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="PSY("+PSYPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,PSYPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
{
int    i,counted_bars=IndicatorCounted();

//----
if(Bars<=PSYPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=PSYPeriod;i++) PSYBuffer[Bars-i]=0.0;
//----
i=Bars-PSYPeriod-1;
if(counted_bars>=PSYPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
int sump=0;
for(int j=0;j<PSYPeriod;j++)
{
if(Close[i+j]>Close[i+j+1]) sump++;
}
PSYBuffer[i]=100*sump/PSYPeriod;
i--;

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

author

Authored By Jesse Lau

A freelancer living in New Zealand, engaged in website development and program trading. Ever won 1st ranking twice in the Dukascopy Strategy Contest. This article is licensed under a Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now

Post Your Comments Here:

Our website uses cookies to improve your user experience. If you continue browsing, we assume that you consent to our use of cookies. More information can be found in our privacy policy Got it