Login

User Name:  
Password::  
Forgot Password?
Sign up with

Join now (it's free)

User Name:
First Name:
Last Name:
Email:
Password::

Building Strategy Conditions with Oscillators

The other type of indicator is an oscillator. Oscillators are drawn in a separate window and they oscillate between high and low price extremes. They are centered around a neutral axis (generally 0), or they are bound by an upper or lower extreme (such as 0 and 100). Examples of oscillators include momentum, stochastics and RSI. 

Oscillators indicate overbought and oversold levels. While they can be used as an indicator of trends, they are generally used to locate areas of pending reversal. These are used to produce counter-trend signals. 

Below is a number of occillators: 


MACD(1)
Note //Buy: MACD rises above the signal line
//Sell: MACD falls below the signal line
Extern int fastmacd=12; //Averaging period for calculation of a quick MA
extern int slowmacd=26; //Averaging period for calculation of a slow MA
extern int signalmacd=9; //Averaging period for calculation of a signal line
Indicator
Calling
macdmaincurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,0);
macdmainprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,1);
macdsigcurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_SIGNAL,0);
macdsigprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_SIGNAL,1);
BuyCond if (macdmainprev < macdsignalprev && macdmaincurr >= macdsignalcurr)
SellCond if (macdmainprev > macdsignalprev && macdmaincurr <=macdsignalcurr)


MACD(2)
Note //Buy: crossing 0 upwards
//Sell: crossing 0 downwards
Extern int fastmacd=12; //Averaging period for calculation of a quick MA
extern int slowmacd=26; //Averaging period for calculation of a slow MA
extern int signalmacd=9; //Averaging period for calculation of a signal line
Indicator
Calling
macdmaincurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,0);
macdmainprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_MAIN,1);
macdsigcurr=iMACD(NULL,0,fastmacd,slowmacd,signalmacd,0,MODE_SIGNAL,0);
macdsigprev=iMACD(NULL,0,fastmacd,slowmacd,signalmacd0,MODE_SIGNAL,1);
BuyCond if (macdmainprev < 0 && macdmaincurr >= 0)
SellCond if (macdmainprev > 0 && macdmaincurr <= 0)


RSI
Note //Buy: crossing 30 upwards
//Sell: crossing 70 downwards
Extern rsiu = 14; // averaging period
lowerband = 30;
upperband = 70;
Indicator
Calling
rsicurrent=iRSI(NULL,0,rsiu,PRICE_CLOSE,0);
rsiprevious=iRSI(NULL,0,rsiu,PRICE_CLOSE,1);
BuyCond if (rsiprevious<lowerband&&rsicurrent>=lowerband)
SellCond if (rsiprevious>upperband&&rsicurrent<=upperband)


Stochastics Occilator(1)
Note //Buy: main line rises above 20 after it fell below this point
//Sell: main line falls lower than 80 after it rose above this point
Extern stok = 5; // Period(amount of bars) for the calculation of %K line
stod = 3; //Averaging period for the calculation of %D line
stslow =3; // Value of slowdown
mamode = 1; 
lowerband = 20;
upperband = 80;
Indicator
Calling
stocurrent=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,0);
stoprevious=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,1);
BuyCond if (stoprevious<lowerband&&stocurrent>=lowerband)
SellCond if (stoprevious>upperband&&stocurrent<=upperband)


Stochastics Occilator(2)
Note //Buy: main line goes above the signal line 
//Sell: signal line goes above the main line
Extern stok = 5; // Period(amount of bars) for the calculation of %K line
stod = 3; //Averaging period for the calculation of %D line
stslow =3; // Value of slowdown
mamode = 1; 
lowerband = 20;
upperband = 80;
Indicator
Calling
stomaincurr=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,0);
stomainprev=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_MAIN,1);
stosignalcurr=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_SIGNAL,0);
stosignalprev=iStochastic(NULL,0,stok,stod,stslow,mamode,0,MODE_SIGNAL,1);
BuyCond if (stomainprev<stosignalprev&&stomaincurr>=stosignalcurr)
SellCond if (stomainprev>stosignalprev&&stomaincurr<=stosignalcurr)


Williams % Range
Note //Buy: crossing -80 upwards
//Sell: crossing -20 downwards
Extern willperiod = 14; // averaging period
lowerband = -20;
upperband = -80;
Indicator
Calling
willcurrent=iWPR(NULL,0,willperiod,0);
willprevious=iWPR(NULL,0,willperiod,1);
BuyCond if (willprevious<upperband>willcurrent>= upperband)
SellCond if (willprevious>lowerband&&willcurrent<=lowerband)


Force Index
Note /Flag 14 is 1, when FI recommends to buy (i.e. FI<0)
//Flag 14 is -1, when FI recommends to sell (i.e. FI>0)
Extern forceu = 2; // averaging period
Indicator
Calling
forcecurrent=iForce(NULL,0,forceu,MODE_SMA,PRICE_CLOSE,0); 
BuyCond if (forcecurrent<0)
SellCond if (forcecurrent>0)

Top
An e-mail with your verification code has been sent to your e-mail address. Please access your in-box and use the verification button or verification code to complete your registration.
You already have an account linked with this E-mail (it maybe standard or social login). Please, sign in with it.
Please, provide us your e-mail so we can verify your account.
Email: