Download MetaTrader 5

Posting Indicators

To add comments, please log in or register
AndPra
22
AndPra  

Hi,

I am learning mql4. I made an indicator to get in a certain way the candle strength and create a bull-bear curve. Please let me have your comments and any suggestions for improvement. I have added a detailed description,



as comments inside the indicator file.

Thanks for testing

AndPra

===========================

//+------------------------------------------------------------------------+
//| CAS_v1.mq4 |
//|Copyright © Andrew Prap. |
//|Candle Strength (CAS) Indicator with Moving Averages |
//+------------------------------------------------------------------------+
//|HELP: 1) About the Indicator 2) How to trade
//|============================================
//|1) About the Indicator:
//| All Technical Indicators are based on instrument values of a) OPEN, b) HIGH,
//|c) LOW, and d) CLOSE, while some are also using e) the VOLUME. In MetaTrader, Volume
//|is the Tick Volume, a surrogate for trade volume. The higher the volume during
//|a price move the more significant the move. To get a more concrete information
//|about Candlesticks and a measure their strength, all 5 values provided from MetaTrader
//|are used here (see calculation method below (*)). The indication provided is
//|called CAS the CAndlestick Strength. This is shown with a Histogram Gold
//|color bars. This Histogram shows also if the market is trending or ranging.
//| Depending on the instrument and time frame you can calibrate its scaling in
//|the Input Parameters. Thereafter,two Exponential Moving Averages are used, one
//|Fast and one Slow. Their difference when greater than zero should indicate entering
//|in BULL area and the inverse in BEAR area. This is seen by a dashed aqua color line.
//| In addition,with a thick Lime color line, is shown a smoothed CAS, with a
//|period to select e.g. 4 to 6,which is the Fast CAS EMA.
//|
//|2) How to trade:
//| The dashed aqua color line being the Difference of the 2 Moving Averages (moving
//|above or below zero),gives in certain circumstances a faster response for entry (buy)
//|above zero and exit (sell)below zero, while the Fast CAS EMA, called BULL_BEAR may give a
//|more conservative indication (less noise)for entry and exit.
//|Alternatively, you may enter with a small amount according the above dashed aqua
//|line and increase the entry amount after a confirmation given by the lime color
//|BULL_BEAR line. moving above zero for buy and below for sell.
//| A suggestion is to use the CAS indicator together with Alligator in main window
//|and +DMI -DMIof the ADX indicator in a separate window.
//| DISCLAIMER: Use this Indicator at your own risk.
//+------------------------------------------------------------------+
#property copyright "A. Prap (Open CAS_v1.mq4 in MetaEditor and read HELP)"
//----
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Aqua
#property indicator_style1 4
#property indicator_width1 1
#property indicator_color2 Gold // Candle Strength Histogram
#property indicator_width2 2
#property indicator_color3 Lime // BULL BEAR Line
#property indicator_width3 2
#property indicator_level1 0.00
#property indicator_levelstyle1 0
#property indicator_levelcolor1 Yellow
//---- input parameters
input int MA_CASPeriodfast=5; // Candle Strenght Fast Period
nput int MA_CASPeriodslow=24; // Candle Strenght Fast Period
input double Candle_Scale_Histogram=0.9; // Calibrate Scale
input int Bull_Bear_Scale=2; // Calibrate Scale
input int Differ_Fast_Slow_Scale=2; // Calibrate Scale
//---- buffers
double MA_CASfast[];
double CAS[];
double MA_CASslow[];
double DMAfs[];
double CANDL_STR[];
double BULL_BEAR[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+-------------------------------------------------------------------+
int init()
{
//---- buffers
SetIndexBuffer(0, DMAfs);
SetIndexStyle(0,DRAW_LINE);
SetIndexLabel(0,"Diff_MAFastSlow");
SetIndexBuffer(1, CANDL_STR);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexLabel(1,"Candle_Strength");
SetIndexBuffer(2, BULL_BEAR);
SetIndexStyle(2,DRAW_LINE);
SetIndexLabel(2,"BULL_BEAR");
SetIndexStyle(3, DRAW_NONE);
SetIndexBuffer(3,CAS);
SetIndexLabel(3,NULL);
SetIndexStyle(4,DRAW_NONE);
SetIndexBuffer(4,MA_CASslow);
SetIndexLabel(4,NULL);
SetIndexStyle(5,DRAW_NONE);
SetIndexBuffer(5,MA_CASfast);
SetIndexLabel(5,NULL);
IndicatorShortName("CAS_V1");
IndicatorDigits(2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator function Candle Strength and Moving Averages
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
if(counted_bars==0)
limit=Bars;
if(counted_bars>0)
limit=Bars-counted_bars;
limit--;
for(i=limit; i>=0; i--)
CAS[i]=((double)Volume[i])*((3*(double)Close[i])-((double)Low[i]+(double)Open[i]+ (double)High[i]));
//----- TWO EXPON. MOVING AVERAGES ---------------------------------+
for(i = limit; i >= 0; i--)
{
MA_CASfast[i] = iMAOnArray(CAS,0,MA_CASPeriodfast,0,MODE_EMA,i);
MA_CASslow[i]= (iMAOnArray(CAS,0,MA_CASPeriodslow,0,MODE_EMA,i));
DMAfs[i]=Differ_Fast_Slow_Scale*((MA_CASfast[i])-(MA_CASslow[i]));
CANDL_STR[i]=((double)MathPow(Volume[i],Candle_Scale_Histogram))*
((3*(double)Close[i])-((double)Low[i]+(double)Open[i]+ (double)High[i])); //(**)
}
for(i = limit; i >= 0; i--)
BULL_BEAR[i]=Bull_Bear_Scale*(MA_CASfast[i]);
//+------------------------------------------------------------------+
return(0); }
//+------------------------------------------------------------------+
//NOTES:
//======
//(*)CAS=(Volume)*((3*Close)-(Low+Open+High))
//The relation of ((3*Close)-(Low+Open+High)) gives a good indication
// of the candlestick conditions. 

//(**) MathPow is a workaround to reduce the size of the CAS Histogram bars
Alain Verleyen
Moderator
32012
Alain Verleyen  
AndPra:

Hi.

I am new here. Where can I post an indicator (MQL4) to discuss with others.

Thanks

AndPra

Here or in Codebase.
whroeder1
15321
whroeder1  

Play video
Please edit your post.
For large amounts of code, attach it.
AndPra
22
AndPra  
AndPra:

Hi.

I am new here. Where can I post an indicator (MQL4) to discuss with others.

Thanks

AndPra

Hi,

I cannot post. I received a warning:

"Unfortunately, your message cannot be added due to any of the following reasons:
1) the entry has already existed
2) there have been limits for non-approved users
3) the message interval has not reached 30 sec."

What can I do?

Thanks

AndPra

whroeder1
15321
whroeder1  
AndPra: I cannot post.
Then how did you post your "I cannot post" post? Edit your post and post!
AndPra
22
AndPra  
angevoyageur:
Here or in Codebase.


OK. I edited my above post with the code. Please have a look.

Thanks

AndPra

Alberto Cioccarelli
2572
Alberto Cioccarelli  
all ok thanks 
To add comments, please log in or register