Disliked{quote} Correct - that is because it has automatic histo width code so the code will automatically resize for every time you zoom in and out on a chart.Ignored
Can you upload mq4 file please? I'd like to change some default settings.
Multi-colored lines MT4 Fib Tool 21 replies
Renko + TMA slope + MACD Colored 124 replies
Colored MACD - MT4 indicator modification request 2 replies
Disliked{quote} Correct - that is because it has automatic histo width code so the code will automatically resize for every time you zoom in and out on a chart.Ignored
DislikedAlerts added and areas of the code updated to prevent array out of range issues. {file}Ignored
//+------------------------------------------------------------------+
//| Indicator: MACD_AJ.mq4 |
//| Created with EABuilder.com |
//| http://eabuilder.com |
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link "http://eabuilder.com"
#property version "1.00"
#property description ""
#include <stdlib.mqh>
#include <stderror.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_type1 DRAW_LINE
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_color1 0x4F4F4F
#property indicator_label1 "Signal"
#property indicator_type2 DRAW_LINE
#property indicator_style2 STYLE_SOLID
#property indicator_width2 2
#property indicator_color2 0xFFAA00
#property indicator_label2 "MACD"
#property indicator_type3 DRAW_HISTOGRAM
#property indicator_style3 STYLE_SOLID
#property indicator_width3 2
#property indicator_color3 0xFFAA00
#property indicator_label3 "Bullish Above 0"
#property indicator_type4 DRAW_HISTOGRAM
#property indicator_style4 STYLE_SOLID
#property indicator_width4 2
#property indicator_color4 0x0000FF
#property indicator_label4 "Bearish Below 0"
#property indicator_type5 DRAW_HISTOGRAM
#property indicator_style5 STYLE_SOLID
#property indicator_width5 2
#property indicator_color5 0xFFAA00
#property indicator_label5 "Bearish Above 0"
#property indicator_type6 DRAW_HISTOGRAM
#property indicator_style6 STYLE_SOLID
#property indicator_width6 2
#property indicator_color6 0x0000FF
#property indicator_label6 "Bullish Below 0"
//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
extern int Fast_EMA = 12;
extern int Slow_EMA = 26;
extern int MACD_SMA = 9;
extern double threshold = 0;
extern double multiplier = 2.5;
double myPoint; //initialized in OnInit
//--- Custom functions -----------------------------------------------
void OnChartEvent(const int id, // Event ID
const long& lparam, // Parameter of type long event
const double& dparam, // Parameter of type double event
const string& sparam) { // Parameter of type string events
IndicatorSetInteger(INDICATOR_HEIGHT, 100);
}
//--- End of custom functions ----------------------------------------
void myAlert(string type, string message)
{
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | MACD_AJ @ "+Symbol()+","+Period()+" | "+message);
}
else if(type == "order")
{
}
else if(type == "modify")
{
}
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorBuffers(6);
SetIndexBuffer(0, Buffer1);
SetIndexEmptyValue(0, 0);
SetIndexBuffer(1, Buffer2);
SetIndexEmptyValue(1, 0);
SetIndexBuffer(2, Buffer3);
SetIndexEmptyValue(2, 0);
SetIndexBuffer(3, Buffer4);
SetIndexEmptyValue(3, 0);
SetIndexBuffer(4, Buffer5);
SetIndexEmptyValue(4, 0);
SetIndexBuffer(5, Buffer6);
SetIndexEmptyValue(5, 0);
//initialize myPoint
myPoint = Point();
if(Digits() == 5 || Digits() == 3)
{
myPoint *= 10;
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime& time[],
const double& open[],
const double& high[],
const double& low[],
const double& close[],
const long& tick_volume[],
const long& volume[],
const int& spread[])
{
int limit = rates_total - prev_calculated;
//--- counting from 0 to rates_total
ArraySetAsSeries(Buffer1, true);
ArraySetAsSeries(Buffer2, true);
ArraySetAsSeries(Buffer3, true);
ArraySetAsSeries(Buffer4, true);
ArraySetAsSeries(Buffer5, true);
ArraySetAsSeries(Buffer6, true);
//--- initial zero
if(prev_calculated < 1)
{
ArrayInitialize(Buffer1, 0);
ArrayInitialize(Buffer2, 0);
ArrayInitialize(Buffer3, 0);
ArrayInitialize(Buffer4, 0);
ArrayInitialize(Buffer5, 0);
ArrayInitialize(Buffer6, 0);
}
else
limit++;
//--- main loop
for(int i = limit-1; i >= 0; i--)
{
if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation
//Indicator Buffer 1
if(true //no conditions!
)
{
Buffer1[i] = iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_SIGNAL, i); //Set indicator value at MACD
}
else
{
Buffer1[i] = 0;
}
//Indicator Buffer 2
if(true //no conditions!
)
{
Buffer2[i] = iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_MAIN, i); //Set indicator value at MACD
}
else
{
Buffer2[i] = 0;
}
//Indicator Buffer 3
if(iOsMA(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, i) > threshold //Moving Average of Oscillator > fixed value
&& iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_MAIN, i) > iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_SIGNAL, i) //MACD > MACD
)
{
Buffer3[i] = iOsMA(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, i); //Set indicator value at Moving Average of Oscillator
}
else
{
Buffer3[i] = 0;
}
//Indicator Buffer 4
if(iOsMA(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, i) < threshold //Moving Average of Oscillator < fixed value
&& iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_MAIN, i) < iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_SIGNAL, i) //MACD < MACD
)
{
Buffer4[i] = iOsMA(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, i); //Set indicator value at Moving Average of Oscillator
}
else
{
Buffer4[i] = 0;
}
//Indicator Buffer 5
if(iOsMA(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, i) > threshold //Moving Average of Oscillator > fixed value
&& iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_SIGNAL, i) > iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_MAIN, i) //MACD > MACD
)
{
Buffer5[i] = iOsMA(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, i); //Set indicator value at Moving Average of Oscillator
}
else
{
Buffer5[i] = 0;
}
//Indicator Buffer 6
if(iOsMA(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, i) < threshold //Moving Average of Oscillator < fixed value
&& iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_SIGNAL, i) < iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, MODE_MAIN, i) //MACD < MACD
)
{
Buffer6[i] = iOsMA(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE, i); //Set indicator value at Moving Average of Oscillator
}
else
{
Buffer6[i] = 0;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
//| Indicator: CCI_AJ_.mq4 |
//| Created with EABuilder.com |
//| http://eabuilder.com |
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link "http://eabuilder.com"
#property version "1.00"
#property description "CCI indicator with different colors at levels 0, 100 and -100."
#include <stdlib.mqh>
#include <stderror.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_type1 DRAW_HISTOGRAM
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
#property indicator_color1 0x99A524
#property indicator_label1 "> 100"
#property indicator_type2 DRAW_HISTOGRAM
#property indicator_style2 STYLE_SOLID
#property indicator_width2 2
#property indicator_color2 0xDADEB1
#property indicator_label2 "[0, 100]"
#property indicator_type3 DRAW_HISTOGRAM
#property indicator_style3 STYLE_SOLID
#property indicator_width3 2
#property indicator_color3 0xD1CCFE
#property indicator_label3 "[0, -100]"
#property indicator_type4 DRAW_HISTOGRAM
#property indicator_style4 STYLE_SOLID
#property indicator_width4 2
#property indicator_color4 0x4F52EE
#property indicator_label4 "< -100"
//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
extern int period = 14;
extern int level0 = 0;
extern int level100 = 100;
extern int levelN100 = -100;
double myPoint; //initialized in OnInit
int index;
//--- Custom functions -----------------------------------------------
int TLR_Hist_Width()
{
switch((int)ChartGetInteger(0, CHART_SCALE)){
case 5: return 12;
case 4: return 6;
case 3: return 4;
case 2: return 2;
}
return 1;
}
//--- End of custom functions ----------------------------------------
void myAlert(string type, string message)
{
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | CCI_AJ_ @ "+Symbol()+","+Period()+" | "+message);
}
else if(type == "order")
{
}
else if(type == "modify")
{
}
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorBuffers(4);
SetIndexBuffer(0, Buffer1);
SetIndexEmptyValue(0, 0);
SetIndexBuffer(1, Buffer2);
SetIndexEmptyValue(1, 0);
SetIndexBuffer(2, Buffer3);
SetIndexEmptyValue(2, 0);
SetIndexBuffer(3, Buffer4);
SetIndexEmptyValue(3, 0);
//initialize myPoint
myPoint = Point();
if(Digits() == 5 || Digits() == 3)
{
myPoint *= 10;
}
//--- indicator buffers mapping
SetIndexStyle(index,EMPTY,EMPTY,TLR_Hist_Width());
//---
return(INIT_SUCCEEDED);
}
void OnChartEvent(const int id, // Event ID
const long& lparam, // Parameter of type long event
const double& dparam, // Parameter of type double event
const string& sparam) { // Parameter of type string events
IndicatorSetInteger(INDICATOR_HEIGHT, 100);
if(id==CHARTEVENT_CHART_CHANGE)
SetIndexStyle(index,EMPTY,EMPTY,TLR_Hist_Width());
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime& time[],
const double& open[],
const double& high[],
const double& low[],
const double& close[],
const long& tick_volume[],
const long& volume[],
const int& spread[])
{
int limit = rates_total - prev_calculated;
//--- counting from 0 to rates_total
ArraySetAsSeries(Buffer1, true);
ArraySetAsSeries(Buffer2, true);
ArraySetAsSeries(Buffer3, true);
ArraySetAsSeries(Buffer4, true);
//--- initial zero
if(prev_calculated < 1)
{
ArrayInitialize(Buffer1, 0);
ArrayInitialize(Buffer2, 0);
ArrayInitialize(Buffer3, 0);
ArrayInitialize(Buffer4, 0);
}
else
limit++;
//--- main loop
for(int i = limit-1; i >= 0; i--)
{
if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation
//Indicator Buffer 1
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) > level100 //Commodity Channel Index > fixed value
)
{
Buffer1[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer1[i] = 0;
}
//Indicator Buffer 2
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) < level100 //Commodity Channel Index < fixed value
&& iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) > level0 //Commodity Channel Index > fixed value
)
{
Buffer2[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer2[i] = 0;
}
//Indicator Buffer 3
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) > levelN100 //Commodity Channel Index > fixed value
&& iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) < level0 //Commodity Channel Index < fixed value
)
{
Buffer3[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer3[i] = 0;
}
//Indicator Buffer 4
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) < levelN100 //Commodity Channel Index < fixed value
)
{
Buffer4[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer4[i] = 0;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
//| Indicator: CCI_AJ.mq4 |
//| Created with EABuilder.com |
//| http://eabuilder.com |
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link "http://eabuilder.com"
#property version "1.00"
#property description "CCI indicator with different colors at levels 0, 100 and -100."
#include <stdlib.mqh>
#include <stderror.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_type1 DRAW_HISTOGRAM
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
#property indicator_color1 0x99A524
#property indicator_label1 "> 100"
#property indicator_type2 DRAW_HISTOGRAM
#property indicator_style2 STYLE_SOLID
#property indicator_width2 2
#property indicator_color2 0xDADEB1
#property indicator_label2 "[0, 100]"
#property indicator_type3 DRAW_HISTOGRAM
#property indicator_style3 STYLE_SOLID
#property indicator_width3 2
#property indicator_color3 0xD1CCFE
#property indicator_label3 "[0, -100]"
#property indicator_type4 DRAW_HISTOGRAM
#property indicator_style4 STYLE_SOLID
#property indicator_width4 2
#property indicator_color4 0x4F52EE
#property indicator_label4 "< -100"
//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
extern int period = 14;
extern int level0 = 0;
extern int level100 = 100;
extern int levelN100 = -100;
double myPoint; //initialized in OnInit
int index;
//--- Custom functions -----------------------------------------------
int TLR_Hist_Width()
{
switch((int)ChartGetInteger(0, CHART_SCALE)){
case 5: return 13;
case 4: return 6;
case 3: return 3;
case 2: return 2;
}
return 1;
}
//--- End of custom functions ----------------------------------------
void myAlert(string type, string message)
{
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | CCI_AJ @ "+Symbol()+","+Period()+" | "+message);
}
else if(type == "order")
{
}
else if(type == "modify")
{
}
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorBuffers(4);
SetIndexBuffer(0, Buffer1);
SetIndexEmptyValue(0, 0);
SetIndexBuffer(1, Buffer2);
SetIndexEmptyValue(1, 0);
SetIndexBuffer(2, Buffer3);
SetIndexEmptyValue(2, 0);
SetIndexBuffer(3, Buffer4);
SetIndexEmptyValue(3, 0);
//initialize myPoint
myPoint = Point();
if(Digits() == 5 || Digits() == 3)
{
myPoint *= 10;
}
//--- indicator buffers mapping
SetIndexStyle(index,EMPTY,EMPTY,TLR_Hist_Width());
return(INIT_SUCCEEDED);
}
void OnChartEvent(const int id, // Event ID
const long& lparam, // Parameter of type long event
const double& dparam, // Parameter of type double event
const string& sparam) { // Parameter of type string events
IndicatorSetInteger(INDICATOR_HEIGHT, 100);
if(id==CHARTEVENT_CHART_CHANGE)
SetIndexStyle(0,EMPTY,EMPTY,TLR_Hist_Width());
SetIndexStyle(1,EMPTY,EMPTY,TLR_Hist_Width());
SetIndexStyle(2,EMPTY,EMPTY,TLR_Hist_Width());
SetIndexStyle(3,EMPTY,EMPTY,TLR_Hist_Width());
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime& time[],
const double& open[],
const double& high[],
const double& low[],
const double& close[],
const long& tick_volume[],
const long& volume[],
const int& spread[])
{
int limit = rates_total - prev_calculated;
//--- counting from 0 to rates_total
ArraySetAsSeries(Buffer1, true);
ArraySetAsSeries(Buffer2, true);
ArraySetAsSeries(Buffer3, true);
ArraySetAsSeries(Buffer4, true);
//--- initial zero
if(prev_calculated < 1)
{
ArrayInitialize(Buffer1, 0);
ArrayInitialize(Buffer2, 0);
ArrayInitialize(Buffer3, 0);
ArrayInitialize(Buffer4, 0);
}
else
limit++;
//--- main loop
for(int i = limit-1; i >= 0; i--)
{
if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation
//Indicator Buffer 1
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) > level100 //Commodity Channel Index > fixed value
)
{
Buffer1[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer1[i] = 0;
}
//Indicator Buffer 2
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) < level100 //Commodity Channel Index < fixed value
&& iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) > level0 //Commodity Channel Index > fixed value
)
{
Buffer2[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer2[i] = 0;
}
//Indicator Buffer 3
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) > levelN100 //Commodity Channel Index > fixed value
&& iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) < level0 //Commodity Channel Index < fixed value
)
{
Buffer3[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer3[i] = 0;
}
//Indicator Buffer 4
if(iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i) < levelN100 //Commodity Channel Index < fixed value
)
{
Buffer4[i] = iCCI(NULL, PERIOD_CURRENT, period, PRICE_TYPICAL, i); //Set indicator value at Commodity Channel Index
}
else
{
Buffer4[i] = 0;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+ Disliked{quote} Hi cja, can you add alert when macd cross 0 line and there is an arrow appear on the main chart?Ignored
DislikedHi cja, Thanks for sharing that wonderful MACD indicator. I have a problem though and would love if you could please help me deal with it. I sometimes go back through the chart for quite a number of candles and found out that the indicator does not show the signal line, and the histogram anymore. Only MACD line appears on the indicator window. I attach the screen shot of my MT4 for GBPUSD. Many thanks in advance for your kind response. Best, yohanes {image}Ignored
Disliked@CJA, Hey there - just saw this 11yr old thread is still active. Nnice. I am wondering if you have been exposed to Tarantula on these forums? He does EliteCurrensea. I am currently considering purchasing his (Nenad's) ECS.MACD indicator, however on his website it mentions that essentially its just a OSMA which uses a 2 line MACD to plot the trigger line. If I understand what you made correctly, is your indicator essentially this? Very interested in your reply, -AlIgnored