need help in coding buy sell condiation for EA

 

1 He i was using this below indicator (no.1) but i am unable to put buy and sell condiation in EA

buy when bar is blue and sell when bar is red

how to put condiation that in ea



2 also want to know how to change the display style off indicator in shown in picture. want to display like indicator 2



=====================================


#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int maPeriod=1;
extern int maMethod=MODE_SMMA;
extern int maPrice=PRICE_CLOSE;
extern int rsiPeriod=80;
extern int rsiLevel=50;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom 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;
//---- main loop
for(int i=0; i<limit; i++)
{
double ma = iMA(NULL,0,maPeriod, 0, maMethod, maPrice, i);
double rsi= iRSI(NULL, 0, rsiPeriod, maPrice, i);
if (rsi >= rsiLevel)
ExtMapBuffer1[i] = ma;
else
ExtMapBuffer2[i] = ma;
}
return(0);



}

//+------------------------------------------------------------------+

Files:
bt_trend.mq4  2 kb
 
if (iRSI(NULL, 0, 80, 1, i) >= 50) //(i dependent if it's repainting)
   {
   OrderSend(.... ,OP_BUY,.......);
   }
else
   OrderSend(.... ,OP_SELL,.......);

i don't understand the logic behind whatever

 
qjol:

i don't understand the logic behind whatever

he its working in EA

THANKS for reply qjol:


also want to know how to change the display style off indicator in shown in picture. want to display like indicator 2 ( above 0.00 and below 0.00 )

 

i'm not sure if this is what u want

& please for the next time

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       maPeriod=1;
extern int       maMethod=MODE_SMMA;
extern int       maPrice=PRICE_CLOSE;
extern int       rsiPeriod=80;
extern int       rsiLevel=50;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int bars_count=WindowBarsPerChart();
   double _Low = Low[iLowest(NULL,0,MODE_LOW,bars_count,0)];

   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;
//---- main loop
   for(int i=0; i<limit; i++)
     {
         double ma = iMA(NULL,0,maPeriod, 0, maMethod, maPrice, i);
         double rsi= iRSI(NULL, 0, rsiPeriod, maPrice, i);
         if (rsi >= rsiLevel)
            ExtMapBuffer1[i] = ma - _Low;
         else
            ExtMapBuffer2[i] = -ma + _Low;
     }
   return(0);
   
  }
//+------------------------------------------------------------------+
 

or maybe

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       maPeriod=1;
extern int       maMethod=MODE_SMMA;
extern int       maPrice=PRICE_CLOSE;
extern int       rsiPeriod=80;
extern int       rsiLevel=50;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int bars_count=WindowBarsPerChart();
   double _Low = Low[iLowest(NULL,0,MODE_LOW,bars_count,0)];
   double _High = High[iHighest(NULL,0,MODE_HIGH,bars_count,0)];
   
   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;
//---- main loop
   for(int i=0; i<limit; i++)
     {
         double ma = iMA(NULL,0,maPeriod, 0, maMethod, maPrice, i);
         double rsi= iRSI(NULL, 0, rsiPeriod, maPrice, i);
         if (rsi >= rsiLevel)
            ExtMapBuffer1[i] = ma - _Low;
         else
            ExtMapBuffer2[i] = -  _High + ma;
     }
   return(0);
   
  }
//+------------------------------------------------------------------+
 
qjol:

or maybe


ya got it

thnks for reply qjol: :)