I want to create an EA using this indicator. Taking the value from gadblSlope - buffer 6. But I keep getting “variable not defined” from the iCustom. Heres is the indicator. Basically I want to open buy order when the value is >=0.6 and sell order when <=-0.6. Open one order per chart (pair) which the EA is attached. Close those orders when the values goes back to 0.6 for opened buy order and -0.6 for opened sell order. Use a simple money managment whit extern int (SL, TP, Trailing and Lote Size). See if you can help me please.
//±-----------------------------------------------------------------+
//| 10.2 TmaSlope v.1.4.mq4 |
//±-----------------------------------------------------------------+
#property copyright “Copyright © 2012, zznbrm”
//Edited by shahrooz "[email protected]"
//Edited by Nanningbob April 2012 for 10.2
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_level1 0.4
#property indicator_level2 -0.4
#property indicator_level3 0.8
#property indicator_level4 -0.8
#property indicator_levelcolor White
#property indicator_color1 Green
#property indicator_color2 Lime
#property indicator_color3 FireBrick
#property indicator_color4 Red
#property indicator_color5 Teal
#property indicator_color6 HotPink
#property indicator_color7 DarkBlue
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 3
#property indicator_width6 3
#property indicator_width7 0
//---- input parameters
extern int eintPeriod = 20;
extern double edblHigh1 = 0.4;
extern double edblLow1 = -0.4;
extern int atrPeriod = 100;
//---- indicator buffers
double gadblUp1[];
double gadblUp2[];
double gadblDn1[];
double gadblDn2[];
double gadblMid1[];
double gadblMid2[];
double gadblSlope[];
color Font_Color_M15;
double TICK;
bool AdditionalDigit;
//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
int init()
{
//IndicatorBuffers( 8 );
IndicatorBuffers( 7 );
IndicatorDigits( 5 );
IndicatorShortName( “10.2 TmaSlope_Norm” );
AdditionalDigit = MarketInfo(Symbol(), MODE_MARGINCALCMODE) == 0 && MarketInfo(Symbol(), MODE_PROFITCALCMODE) == 0 && Digits % 2 == 1;
TICK = getTick();
SetIndexBuffer( 0, gadblUp1 ); SetIndexLabel( 0, NULL ); SetIndexStyle( 0, DRAW_HISTOGRAM );
SetIndexBuffer( 1, gadblUp2 ); SetIndexLabel( 1, NULL ); SetIndexStyle( 1, DRAW_HISTOGRAM );
SetIndexBuffer( 2, gadblDn1 ); SetIndexLabel( 2, NULL ); SetIndexStyle( 2, DRAW_HISTOGRAM );
SetIndexBuffer( 3, gadblDn2 ); SetIndexLabel( 3, NULL ); SetIndexStyle( 3, DRAW_HISTOGRAM );
SetIndexBuffer( 4, gadblMid1 ); SetIndexLabel( 4, NULL ); SetIndexStyle( 4, DRAW_HISTOGRAM );
SetIndexBuffer( 5, gadblMid2 ); SetIndexLabel( 5, NULL ); SetIndexStyle( 5, DRAW_HISTOGRAM );
SetIndexBuffer( 6, gadblSlope ); SetIndexLabel( 6, “TMA Slope” ); SetIndexStyle( 6, DRAW_NONE );
SetIndexEmptyValue( 0, 0.0 );
SetIndexEmptyValue( 1, 0.0 );
SetIndexEmptyValue( 2, 0.0 );
return( 0 );
}
//±-----------------------------------------------------------------+
//| Custom indicator deinitialization function |
//±-----------------------------------------------------------------+
int deinit()
{
return( 0 );
}
//±-----------------------------------------------------------------+
//| Custom indicator iteration function |
//±-----------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
if ( counted_bars < 0 ) return(-1);
if ( counted_bars > 0 ) counted_bars–;
int intLimit = MathMin( Bars - 1, Bars - counted_bars + eintPeriod );
double dblTma, dblPrev;
double dblTmaMTF, dblPrevMTF;
double atr ;
double atrMTF ;
for( int inx = intLimit; inx >= 0; inx-- )
{
//gadblTma[inx] = calcTma( inx );
//gadblPrev[inx] = calcTma( inx+1 );
//gadblSlope[inx] = ( gadblTma[inx] - gadblPrev[inx] ) / TICK;
atr= iATR(NULL,0,100,inx+10)*0.1;
atrMTF= iATR(NULL,0,100,inx+10)*0.1;
if (atr == 0) continue;
if (atrMTF == 0) continue;
dblTma = calcTma( inx );
dblPrev = calcTma( inx+1 );
gadblSlope[inx] = ( dblTma - dblPrev ) / atr;
gadblUp1[inx] = 0.0;
gadblDn1[inx] = 0.0;
gadblMid1[inx] = 0.0;
gadblUp2[inx] = 0.0;
gadblDn2[inx] = 0.0;
gadblMid2[inx] = 0.0;
if ( gadblSlope[inx] > edblHigh1 )
{
if(gadblSlope[inx] < gadblSlope[inx+1]) gadblUp1[inx] = gadblSlope[inx];
else gadblUp2[inx] = gadblSlope[inx];
}
else if ( gadblSlope[inx] < edblLow1 )
{
if(gadblSlope[inx] < gadblSlope[inx+1]) gadblDn2[inx] = gadblSlope[inx];
else gadblDn1[inx] = gadblSlope[inx];
}
else
{
if(gadblSlope[inx] < gadblSlope[inx+1]) gadblMid2[inx] = gadblSlope[inx];
else gadblMid1[inx] = gadblSlope[inx];
}
// if(gadblSlope[inx]>=0 && gadblSlope[inx]<gadblSlope[inx+1] && Close[inx]>Open[inx] ) arrowdown[inx]=gadblSlope[inx]+0.1gadblSlope[inx];
// if(gadblSlope[inx]<0 && gadblSlope[inx]>gadblSlope[inx+1] && Close[inx]<Open[inx]&& gadblSlope[inx+2]>=gadblSlope[inx+1]) arrowup[inx]=gadblSlope[inx]+0.1gadblSlope[inx];
string tt=DoubleToStr(gadblSlope[inx],2);
ObjectCreate("label",OBJ_LABEL,WindowFind("10.2 TmaSlope_Norm"),0,0);
ObjectSet("label",OBJPROP_XDISTANCE,1);
ObjectSet("label",OBJPROP_YDISTANCE,25);
ObjectSet("label",OBJPROP_CORNER,3);
ObjectSetText("label"," "+tt+" ",20,"Arial",White);
string sObjName="InfoBar1";
if (gadblSlope[0] >= edblHigh1)
ObjectSetText(sObjName, “Buy Only”, 20, “Verdana”, Turquoise);
else if (gadblSlope[0] <= edblLow1)
ObjectSetText(sObjName, “Sell Only”, 20, “Verdana”, Red);
else
ObjectSetText(sObjName, “Ranging”, 20, “Verdana”, DarkGreen);
string name1 = “InfoBar1”;
}
return( 0 );
}
//±-----------------------------------------------------------------+
//| getTick() |
//±-----------------------------------------------------------------+
double getTick() {
double tick = MarketInfo(Symbol(), MODE_TICKSIZE);
if (AdditionalDigit) {
tick *= 10;
}
return (tick);
}
//±-----------------------------------------------------------------+
//| calcTma() |
//±-----------------------------------------------------------------+
double calcTma( int inx )
{
double dblSum = (eintPeriod+1)*Close[inx];
double dblSumw = (eintPeriod+1);
int jnx, knx;
for ( jnx = 1, knx = eintPeriod; jnx <= eintPeriod; jnx++, knx-- )
{
dblSum += ( knx * Close[inx+jnx] );
dblSumw += knx;
if ( jnx <= inx )
{
dblSum += ( knx * Close[inx-jnx] );
dblSumw += knx;
}
}
return( dblSum / dblSumw );
}