Download MetaTrader 5
To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
Rock-Trader.com
197
Rohit Sharma 2014.08.06 18:02 

Dear all traders,

I have created an indicator on the base of BB, malty time frame method, but its not working properly, I don't find any errors when I compile,

when I use it in Live market signal comes and goes, it works in 1 minut time frame, but I get the signals in 5m also, when changing the time frame the signal goes automatically,

can any one help me out ?

//+------------------------------------------------------------------+
//|                                                        RT-23.mq4 |
//|                                 Copyright 2014, Rock-Trader LLP. |
//|                                         http://www.Rocktrader.in |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Rock-Trader LLP."
#property link      "http://www.Rocktrader.in"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 5       // Number of buffers


//--- input parameters
int i, Counted_bars,limit;
double clos,UpFractal,DownFractal,BLGBuffer,bid;
input int BB=20;
extern int MACDLeval=0;
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
input int STDV=20;
input double STDVL= 0.0002;

bool Buy = false;
bool Sell = false;
//-------------//
double BuyBuffer[];
double SellBuffer[];
double BuyStopLoss[];
double SellStopLoss[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(8);
   
   //---- name for DataWindow and indicator subwindow label
   IndicatorShortName("RT_Rocking_Trend");
   SetIndexLabel(0,"RT_Rocking_Trend");
   ObjectCreate("myatrheading", OBJ_LABEL, 0, 0, 0);
   ObjectCreate("myurl", OBJ_LABEL, 0, 0, 0);
   ObjectCreate("mytext", OBJ_LABEL, 0, 0, 0);

   SetIndexBuffer(0, BuyBuffer);
   SetIndexStyle(0,DRAW_ARROW,2,2,clrBlue);
   SetIndexArrow(0,217);
   SetIndexLabel(0,"Rock Trader Buy");
  
   SetIndexBuffer(1, SellBuffer);
   SetIndexStyle(1,DRAW_ARROW,2,2,clrRed);
   SetIndexArrow(1,218);
   SetIndexLabel(1,"Rock Trader Sell");
   
   SetIndexBuffer(2, BuyStopLoss);
   SetIndexStyle(2,DRAW_ARROW,2,2,clrBlue);
   SetIndexArrow(2,217);
   SetIndexLabel(2,"RT Buy Stoploss");
   
   SetIndexBuffer(3, SellStopLoss);
   SetIndexStyle(3,DRAW_ARROW,2,2,clrRed);
   SetIndexArrow(3,218);
   SetIndexLabel(3,"RT Sell Stoploss");
  
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration 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();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit=Bars-counted_bars;
//----
   for (i = Bars; i >= 0; i--) {
      
      
      if(iOBV(Symbol(),1,PRICE_CLOSE,i) > iOBV(Symbol(),1,PRICE_CLOSE,i+1)&& Buy == false &&
       iOBV(Symbol(),5,PRICE_CLOSE,i) > iOBV(Symbol(),5,PRICE_CLOSE,i+1)&&
       iStdDev(Symbol(),1,STDV,0,MODE_SMMA,PRICE_CLOSE,i) > iStdDev(Symbol(),1,STDV,0,MODE_SMMA,PRICE_CLOSE,i+1) &&
       iStdDev(Symbol(),5,STDV,0,MODE_SMMA,PRICE_CLOSE,i) > iStdDev(Symbol(),5,STDV,0,MODE_SMMA,PRICE_CLOSE,i+1) &&
       iStdDev(Symbol(),15,STDV,0,MODE_SMMA,PRICE_CLOSE,i) > iStdDev(Symbol(),5,STDV,0,MODE_SMMA,PRICE_CLOSE,i+1) &&
       Close[i] > iBands(Symbol(),1,20,2,0,PRICE_CLOSE,MODE_UPPER,i+1)&& 
       High [i+1]> iBands(Symbol(),5,20,1,0,PRICE_CLOSE,MODE_UPPER,i+2)&& 
       High[i+1] > iBands(Symbol(),15,20,1,0,PRICE_CLOSE,MODE_UPPER,i+2
       ))
       
      
      {
         BuyBuffer[i]=Low[i];
         BuyStopLoss[i]=Low[i];
         Buy = true;
         Sell = false;
         if (Time[i] == Time[1] && clos != Close[1])
         {
            Alert ("RT-Break-Out: ",Symbol()+" : Buy StopLoss @ "+DoubleToStr(Low[i]));
            Alert ("RT-Break-Out: ",Symbol()+" : Buy @ "+DoubleToStr(Open[0]));
            clos = Close[1];
         }         
      }
      
      if(iOBV(Symbol(),1,PRICE_CLOSE,i) < iOBV(Symbol(),1,PRICE_CLOSE,i+1)&& Sell == false &&
       iOBV(Symbol(),5,PRICE_CLOSE,i) < iOBV(Symbol(),5,PRICE_CLOSE,i+1)&&
       iStdDev(Symbol(),1,STDV,0,MODE_SMMA,PRICE_CLOSE,i) > iStdDev(Symbol(),1,STDV,0,MODE_SMMA,PRICE_CLOSE,i+1) &&
       iStdDev(Symbol(),5,STDV,0,MODE_SMMA,PRICE_CLOSE,i) > iStdDev(Symbol(),5,STDV,0,MODE_SMMA,PRICE_CLOSE,i+1) &&
       iStdDev(Symbol(),15,STDV,0,MODE_SMMA,PRICE_CLOSE,i) > iStdDev(Symbol(),5,STDV,0,MODE_SMMA,PRICE_CLOSE,i+1) &&
       Close[i] < iBands(Symbol(),1,20,2,0,PRICE_CLOSE,MODE_LOWER,i)&& 
       Low[i] < iBands(Symbol(),5,20,1,0,PRICE_CLOSE,MODE_LOWER,i)&&
       Low[i] < iBands(Symbol(),15,20,1,0,PRICE_CLOSE,MODE_LOWER,i))
       
       
      
      
      
      {
         SellBuffer[i]=High[i];
         SellStopLoss[i]=High[i];
         Buy = false;
         Sell = true;
         if (Time[i] == Time[1] && clos != Close[1])
         {
            Alert ("RT-Break-Out: ",Symbol()+" : Sell StopLoss @ "+DoubleToStr(High[i]));
            Alert ("RT-Break-Out: ",Symbol()+" : Sell @ "+DoubleToStr(Open[0]));
            clos = Close[1];
         }
       }
       
        
      WindowRedraw();
     }
   ObjectSetText("mytext", "Rock-Trader", 10, "Arial Black", Lime);
   ObjectSet("mytext", OBJPROP_XDISTANCE, 6);
   ObjectSet("mytext", OBJPROP_YDISTANCE, 11);
   ObjectSet("mytext", OBJPROP_CORNER, 4);
   ObjectSetText("myatrheading", "by Rocktrader Researchers", 10, "Arial", Orange);
   ObjectSet("myatrheading", OBJPROP_XDISTANCE, 110);
   ObjectSet("myatrheading", OBJPROP_YDISTANCE, 12);
   ObjectSet("myatrheading", OBJPROP_CORNER, 4);
   ObjectSetText("myurl", " info@rocktrader.in | www.rocktrader.in", 9, "Arial", White);
   ObjectSet("myurl", OBJPROP_XDISTANCE, 5);
   ObjectSet("myurl", OBJPROP_YDISTANCE, 27);
   ObjectSet("myurl", OBJPROP_CORNER, 4);

//--- return value of prev_calculated for next call

   return(rates_total);
  }
//+------------------------------------------------------------------+
ffoorr
985
ffoorr 2014.08.07 11:59  
 for (i = limit; i >= 0; i--) 


Number 2 is for Histogram, 0 = draw_solid

SetIndexStyle(0,DRAW_ARROW,2,2,clrBlue);


I think you should move the timeframe, in fonction of the actuel TF,

if (period() == 5 )  { TF_2 = 5*3(15); TF_3 = 5*6 (30); }
/
To add comments, please log in or register