help on new developed indicator

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
250
ffoorr 2016.05.04 20:22 #
 
kewu:

Have done it but it doesnt produce base on my condition.

here is my code

"it doesnt produce" don't mean anything.

The indicator do work on my computer.


#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 PaleGreen
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Red

#property indicator_color4 Red

extern int FastEMA = 5;
extern int SlowEMA = 6;
extern int RSIPeriod = 7;
extern bool Alerts = 0;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_down[];
int a = 0;
int old = 0;
double x = 0.0;
extern double delta = 0.0;
 datetime alertshow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_LINE,0,3 );
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_LINE,0,3);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,2);
   SetIndexArrow(2, 233);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,2);
   SetIndexArrow(3, 234);
   SetIndexBuffer(3, arrow_down);
   SetIndexEmptyValue(3, 0.0);

   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   int limit;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   if(counted_bars==0) limit = MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else                limit = Bars-counted_bars;
   for (int i = limit; i >= 0; i--) 
      {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
       if (x > delta*Point && irsi_1 > 50.0){ a = 1;  } // this is up condition a = 1
       if (x < delta*Point && irsi_1 < 50.0) { a = 2; }
      if (a == 1 && old == 2) 
         {
         arrow_1[i] = Low[i] - 5.0 * Point;// a=1 should be up_arrow 
         c= TRUE;
         price_10 = Ask;
         } 
      if (a == 2 && old == 1 ) 
           {
           arrow_down[i] = High[i] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
            }
      old = a;

   }
   if (Alerts && c) {
      PlaySound("alert.wav");
      if (old == 2)  
      
         if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol()," buy signal");
            alertshow=Time[1];
           }
      else
         if (old == 1) if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol(),"  sell signal");
            alertshow=Time[1];
           }
   }
//----
   return(prev_calculated);
  }
//+------------------------------------------------------------------+


Here modifie for this :


if(counted_bars==0) limit = MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else                limit = Bars-counted_bars;
//------------------------------------------------------------------------------

if(counted_bars==0) limit = Bars-(FastEMA+SlowEMA+1);
   else                limit = Bars-counted_bars;

The OnCalculate is useless; it can be replaced by   int start()  


avatar
9
kewu 2016.05.05 12:45 #
 
ffoorr:

"it doesnt produce" don't mean anything.

The indicator do work on my computer.



Here modifie for this :


The OnCalculate is useless; it can be replaced by   int start()  


it works but it doesnt indicate/print the arrow base on my initial settings like the one am having problem with.
avatar
9
kewu 2016.05.06 09:21 #
 
ffoorr:

"it doesnt produce" don't mean anything.

The indicator do work on my computer.



Here modifie for this :


The OnCalculate is useless; it can be replaced by   int start()  


sir , dont forget me on this matter .

what am trying to said is that the indicator doesn't work in the same way. please look at the below image sir.



Back to topics list   | 1 2  

To add comments, please log in or register