How will my EA trade from indicator that uses Arrow Signal.

Back to topics list To post a new topic, please log in or register
avatar
5
gbenga 2015.09.23 18:45
 
int init()
  {
//---- indicators
    SetIndexStyle(0, DRAW_ARROW, 0, 1);
    SetIndexArrow(0, 221);
    SetIndexBuffer(0, ExtMapBuffer1);
//----
    SetIndexStyle(1, DRAW_ARROW, 0, 1);
    SetIndexArrow(1, 222);
    SetIndexBuffer(1, ExtMapBuffer2);

//----
    switch(Period())
      {
        case     1: cTime = 1;     nTime = 5;      break;    
        case     5: cTime = 5;     nTime = 15;     break; 
        case    15: cTime = 15;    nTime = 30;     break; 
        case    30: cTime = 30;    nTime = 60;     break; 
        case    60: cTime = 60;    nTime = 240;    break; 
        case   240: cTime = 240;   nTime = 1440;   break; 
        case  1440: cTime = 1440;  nTime = 10080;  break; 
        case 10080: cTime = 10080; nTime = 43200;  break; 
        case 43200: cTime = 43200; nTime = 43200;  break;               
      }
//----
    return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
    return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int limit;
    int counted_bars = IndicatorCounted();
//---- check for possible errors
    if(counted_bars < 0) 
        return(-1);
//---- last counted bar will be recounted
    if(counted_bars > 0) 
        counted_bars--;
    limit = Bars - counted_bars;
    


//----
    for(int i=0; i<limit; i++)
      {
       
        apaBlueC   = iCustom(NULL,0,"#MTF AlaskanPipAssassin",cTime,1000,7,1.6,50.6,1,i);
        apaRedC    = iCustom(NULL,0,"#MTF AlaskanPipAssassin",cTime,1000,7,1.6,50.6,0,i);
        apaBlueN   = iCustom(NULL,0,"#MTF AlaskanPipAssassin",nTime,1000,7,1.6,50.6,1,i);
        apaRedN    = iCustom(NULL,0,"#MTF AlaskanPipAssassin",nTime,1000,7,1.6,50.6,0,i);
        
        adxcBlueC  = iCustom(NULL,0,"#MTF_ADXcrosses",cTime,false,0,i);
        adxcRedC   = iCustom(NULL,0,"#MTF_ADXcrosses",cTime,false,1,i);
        adxcBlueN = iCustom(NULL,0,"#MTF_ADXcrosses",nTime,false,0,i);
        adxcRedN  = iCustom(NULL,0,"#MTF_ADXcrosses",nTime,false,1,i); 
        
        nShift       = iATR(NULL,0,100,i)*0.5;
        
        
       // if(2>1)PlaySound("goat.wav");
        
        ExtMapBuffer1[i] = 0.0; ExtMapBuffer2[i] = 0.0;
        //----
        if ((adxcBlueC < adxcRedC || adxcBlueN < adxcRedN) && (apaBlueN < apaRedN && apaBlueC < apaRedC)){
            ExtMapBuffer1[i] = Low[i] + 3*Point;}
        
        if ((adxcBlueC > adxcRedC || adxcBlueN > adxcRedN) && (apaBlueN > apaRedN && apaBlueC > apaRedC)){
            ExtMapBuffer2[i] = High[i] - 3*Point;}
}
if(ExtMapBuffer1[0]!=0.0 && Time[i]>uplast && Alerts==true) 
        {
          string message;
          message =  StringConcatenate(Symbol(),  Period()," ADXCrosses changed to Up.");
          Alert(message);
          PlaySound("goat.wav");
          uplast=Time[i];
        }
      if(ExtMapBuffer2[0]!=0.0 && Time[i]<dnlast && Alerts==true) 
        {
          string message2;
          message2 = StringConcatenate(Symbol(),  Period()," ADXCrosses changed to Down.");
          Alert(message2);
          PlaySound("goat2.wav");
          dnlast=Time[i];
        }
    return(0);
  }
//+------------------------------------------------------------------+

This is the indicator that i want to use.
I  want my Ea to open  trade once the arrow is formed on this indicator
avatar
5
gbenga 2015.09.23 19:02 #
 
if(iCustom(NULL,0,"indicator name",0,0)==iClose(Symbol(),0,0)&& CountTradesB()==0) rs= OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);
        
    if(iCustom(NULL,0,"indicator name",1,0)==iClose(Symbol(),0,0)&& CountTradesS()==0)    rs=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);

Back to topics list  

To add comments, please log in or register