here the indicator code
//+------------------------------------------------------------------+
//| Custom MACD.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//
// ?????????? ?? ???????????? ???D
// 1. ?????????? ? ????? ??/??
// 2. ???????? ?? ??????????? ???????? ????
//
// Difference from ???D of standart
// 1. color of style of AC/AO
// 2. unvisible null bar
#property copyright "Aleksandr Pak,Almaty, 2006"
#property link "ekr-ap@mail.ru"
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Silver
#property indicator_width1 2
#property indicator_width2 2
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double MacdBuffer[], MacdBufferUp[], MacdBufferDown[];
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
IndicatorBuffers(4);
SetIndexBuffer (0,MacdBufferUp);
SetIndexStyle (0,DRAW_HISTOGRAM);
SetIndexBuffer (1,MacdBufferDown);
SetIndexStyle (1,DRAW_HISTOGRAM);
SetIndexBuffer (2,SignalBuffer);
SetIndexStyle (2,DRAW_LINE);
SetIndexDrawBegin(2,SignalSMA);
SetIndexBuffer (3,MacdBuffer);
SetIndexStyle (3,DRAW_NONE);
SetIndexLabel (0,"Buffer 0");
SetIndexLabel (1,"Buffer 1");
SetIndexLabel (2,"Signal");
IndicatorDigits(Digits+3);
IndicatorShortName("MACD_color("+FastEMA+","+SlowEMA+","+SignalSMA+")");
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
int limit,i;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
for(i=0; i<limit; i++)
{
MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
}
for(i=0; i<limit; i++)
{
MacdBufferDown[i]=0.0; MacdBufferUp[i]=0.0;
if(i>=1) //??? ????? ?? ??????????? ???????? ???? //break the null bar
{
if(MacdBuffer[i]-MacdBuffer[i]>=0)MacdBufferDown[i]=MacdBuffer[i]; //??????? ???????? //condition of color
else MacdBufferUp[i]=MacdBuffer[i];}
}
for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
return(0);
}
//+------------------------------------------------------------------+
Different indicator index buffers are used -- when a value is present in one of the buffers, one draws red, one draws green.
Observe the values in each buffer using the DataWindow, then use iCustom() to determine when red is active and when it is active.
The color itself is not an accesible value.
i dont understand how do i get to the datawindow... and also i dont know how to programm mql4 or programming period this is why im asking someone to help me and fix the code for me... i would be greatly helpful and im willing to share my settings with anyone whos able to help me with this programm code...
thanks
hustlerscreed
This is one way you could do it
//+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double macd1=iCustom(Symbol(),0,"macd3",120,80,1,0,1); double macd2=iCustom(Symbol(),0,"macd3",120,80,1,0,2); double macd3=iCustom(Symbol(),0,"macd3",120,80,1,1,1); double macd4=iCustom(Symbol(),0,"macd3",120,80,1,1,2); static int trade_bar; if(macd1>0 && macd2==0 && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,NULL,0,0,Green);trade_bar=Bars;} if(macd3>0 && macd4==0 && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,NULL,0,0,Red);trade_bar=Bars;} //----
Different indicator index buffers are used -- when a value is present in one of the buffers, one draws red, one draws green.
Observe the values in each buffer using the DataWindow, then use iCustom() to determine when red is active and when it is active.
The color itself is not an accesible value.
i think what your saying is the way to go but i dont know how to do it
Menu -- View -- DataWindow
That window shows various values for the bar that you manually point at with the mouse.
Values for the indicator indexes for the indicators in use are also shown.
From that window you can determine which indicator buffer is used to draw the green bars, and which is used to draw the red bars.
That information is helpful for programming the iCustom() command in the EA to collect that information.
You are not a programmer? I am not a teacher.
---
fxcourt (above) took a different tack, instead of reading the MACD indicator, he calculates the MACD values directly.
perfect i understand the values changes, Thanks much Phy
now can someone he me programm them in to the ea using icustom()
much thanks,
hustlerscreed
ok found the function i need to use
below is the function
heres the deal i need to
buy when buffer 0 is greater than -0.00000 && buffer 1 is absolute 0.00000
sell when buffer 0 is absolute 0.00000 && buffer 1 is greater then -0.00000
bool SetIndexBuffer( | int index, double array[]) |
index | - | Line index. Must lie between 0 and 7. |
array[] | - | Array that stores calculated indicator values. |
double ExtBufferSilver[]; int init() { SetIndexBuffer(0, ExtBufferSilver); // first line buffer // ... }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
the following is the ea code. what i need to do know or do is how do i get my ea to trade from the change of the color on the macd histogram only.
also above is a picture of the indicator as you can see there is no signal line i took it out
can someone help me fix this ea please
thanks.
hustlerscreed
/+------------------------------------------------------------------+