Re MT-4 Ea And Custom Indicator

 
Hi all I am trying to get this EA to work with this Custom indicator. Here are the codes I want the EA to open a trade on the arrow once the arrow has indicated a trend...Thanks for all your help......

Thank You
Mike

//+------------------------------------------------------------------+
//| SilverTrend_Signal.mq4 
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property copyright "SilverTrend  rewritten by CrazyChart"
#property link      "http://viac.ru/"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

//---- input parameters
extern int RISK=3;
extern int CountBars=350;
extern int NumberofAlerts=2;
int SSP=9;
int counter=0;
//---- buffers
double val1[];
double val2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,233);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,234);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| SilverTrend_Signal                                               |
//+------------------------------------------------------------------+
int start()
  {   
   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+SSP);
   SetIndexDrawBegin(1,Bars-CountBars+SSP);
   int i,shift,counted_bars=IndicatorCounted();
   int i1,i2,K;
   double Range,AvgRange,smin,smax,SsMax,SsMin,price;
   bool uptrend,old;
//----
   
   if(Bars<=SSP+1) return(0);
//---- initial zero
   if(counted_bars<SSP+1)
   {
      for(i=1;i<=SSP;i++) val1[CountBars-i]=0.0;
      for(i=1;i<=SSP;i++) val2[CountBars-i]=0.0;
   }
//----

K=33-RISK; 
for (shift = CountBars-SSP; shift>=0; shift--) 
{ 

	Range=0;
	AvgRange=0;
	for (i1=shift; i1<=shift+SSP; i1++)
		{AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);
		}
	Range=AvgRange/(SSP+1);

SsMax=High[shift]; SsMin=Low[shift]; 
   for (i2=shift;i2<=shift+SSP-1;i2++)
        {
         price=High[i2];
         if(SsMax<price) SsMax=price;
         price=Low[i2];
         if(SsMin>=price)  SsMin=price;
        }
 
smin = SsMin+(SsMax-SsMin)*K/100; 
smax = SsMax-(SsMax-SsMin)*K/100; 
	val1[shift]=0;
	val2[shift]=0;
	if (Close[shift]<smin)
		{
		uptrend = false;
		}
	if (Close[shift]>smax)
		{
		uptrend = true;
		}
   if (uptrend!=old && uptrend==true)
   {
   val1[shift]=Low[shift]-Range*0.5;
   counter=0;
   if (shift==0 && counter<=NumberofAlerts) 
   {
   Alert("Silver Trend ",Period()," ",Symbol()," BUY");
   counter=counter+1;
   }
   }
   if (uptrend!=old && uptrend==false) 
   {
   counter=0;
   val2[shift]=High[shift]+Range*0.5;
   if (shift==0 && counter<=NumberofAlerts) 
   {
   Alert("Silver Trend ",Period()," ",Symbol()," SELL");
   counter=counter+1;
   
   }
   }
   Comment(shift);
   old=uptrend;

}
   return(0);
  }
//+------------------------------------------------------------------+





/*[[
        Name := Turbo_Robot1.1
        Author := MT
        Link := 
        Notes := M5 for all majors
        Lots := 1.00
        Stop Loss := 45
        Take Profit := 150
        Trailing Stop := 15
]]*/

extern double slippage=20,mm=1,risk=7.5,Lot=0.1,StopLoss=45,TakeProfit=150, TrailingStop=15;

int start()
  {

double bull=0,bear=0,sl=0,tp=0,cnt=0,b=0,s=0,Opentrades=0,lotsi=0,ITB=0,ITS=0,total=0;



ITB=iCustom(NULL,0,"SilverTrend_Signal",2,0,0,20,0,14,0,0,1);

ITS=iCustom(NULL,0,"SilverTrend_Signal",2,0,0,20,0,14,0,0,1);

bull = iBullsPower(NULL,0,5,PRICE_CLOSE,1);
bear = iBearsPower(NULL,0,5,PRICE_CLOSE,1);
Comment("bull+bear= ",bull + bear,"\n I Blue ",ITB,"\n I Red ",ITS);

//////////////////////////////////////////////////
///////////// Manage multiple trades ///////////// 
//////////////////////////////////////////////////

Opentrades=0;

total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{ 
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if ( OrderSymbol()==Symbol() ) Opentrades = Opentrades+1;  
}

//////////////////////////////////////////////////
///////////// Money Manager ///////////// 
//////////////////////////////////////////////////

if (mm != 0) 
        lotsi=MathCeil(AccountBalance()*risk/10000)/10;
else
        lotsi=Lot;
        



if (Opentrades == 0) 
   {
   if ((bull + bear > 0) && (ITB == 1) && (ITS == 0)) 
      {
      sl = Ask - StopLoss * Point;
      tp = Bid + TakeProfit * Point;
      OrderSend(Symbol(),OP_BUY,lotsi,Ask,slippage,sl,tp,0,0,Blue);
      }
   if ((bull + bear < 0) && (ITS == -1) && (ITB == 0))
      {
      sl = Bid + StopLoss * Point;
      tp = Ask - TakeProfit * Point;
      OrderSend(Symbol(),OP_SELL,lotsi,Bid,slippage,sl,tp,0,0,Red);
      }
   }


b = 1 * Point + iATR(NULL,0,5,1) * 1.5;
s = 1 * Point + iATR(NULL,0,5,1) * 1.5;


total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if ((OrderType()== OP_BUY) && (OrderSymbol()== Symbol())) 
         {
         if ((OrderOpenPrice() > OrderStopLoss()) && (Bid-OrderOpenPrice() > StopLoss*Point))   
            { 
            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,SlateBlue);
            return(0);
            }
         if ((Bid - OrderOpenPrice()) > b )
            { 
            if ((OrderStopLoss()) < (Bid -b))  
               {
               OrderModify(OrderTicket(),OrderOpenPrice(),Bid - b,OrderTakeProfit(),0,SlateBlue);
               return(0);
               }
            }
         }
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if ((OrderType()== OP_SELL) && (OrderSymbol()== Symbol()))          
         {
         if ((OrderOpenPrice() < OrderStopLoss()) && (OrderOpenPrice()-Ask > StopLoss*Point)) 
            {
            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
            return(0);
            }
         if ((OrderOpenPrice()-Ask ) > s )
            { 
            if ((OrderStopLoss()) > (Ask + s))
            {
            OrderModify(OrderTicket(),OrderOpenPrice(),Ask + s,OrderTakeProfit(),0,Red);
            return(0);
            }  
         }
       } 
  
    
}
}
 
Taking a quick look your calling of the silvertrend from within the iCustom has the wrong parameters
Silvertrend is looking
for
extern int RISK=3;
extern int CountBars=350;
extern int NumberofAlerts=2;


But you have this
ITB=iCustom(NULL,0,"SilverTrend_Signal",2,0,0,20,0,14,0,0,1);
ITS=iCustom(NULL,0,"SilverTrend_Signal",2,0,0,20,0,14,0,0,1);

Too Many parameters

Check it out
Thanks
EK
 
Thank you for your response i don't know alot about the coding but i am trying to learn it. What would you rcomend to make this work as far as parameters. And all


thank You
mike
 
something like this

ITB=iCustom(NULL,0,"SilverTrend_Signal",3,350,2,0,0);
ITS=iCustom(NULL,0,"SilverTrend_Signal",3,350,2,1,0);


Try That
EK
 
Thank You Much I will give it a try
 
Can you can draw these "smin" &"smax" two variables the path line?