iStdDev - Wrong Parameters count- I need Help Dear Traders

 

I have some problem in calling my indicator,

please correct me the exact way of calling this indicator iStdDev

Please help.

//+------------------------------------------------------------------+
//|                                               Rock-Trader-ME.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 strict
#property indicator_chart_window
#property indicator_buffers 5       // Number of buffers

//--- input parameters
input int      Magic_Value=4;
input int      Magic_Period=20;

int limit, counted_bars;
double BuyVal, SelVal;
double BuyBuffer[];
double SellBuffer[];
double NewBuyBuffer[];
double NewSellBuffer[];
bool Buy = false;
bool Sell = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, BuyBuffer);
   SetIndexStyle(0,DRAW_ARROW,2,1,clrBlue);
   SetIndexArrow(0,119);
   SetIndexLabel(0,"RT Buy SL");
  
   SetIndexBuffer(1, SellBuffer);
   SetIndexStyle(1,DRAW_ARROW,2,1,clrRed);
   SetIndexArrow(1,119);
   SetIndexLabel(1,"RT Sell SL");
   
   SetIndexBuffer(2, NewBuyBuffer);
   SetIndexStyle(2,DRAW_ARROW,2,3,clrBlue);
   SetIndexArrow(2,221);
   SetIndexLabel(2,"RT Buy Now");
   
   SetIndexBuffer(3, NewSellBuffer);
   SetIndexStyle(3,DRAW_ARROW,2,3,clrRed);
   SetIndexArrow(3,222);
   SetIndexLabel(3,"RT Sell Now");
//---
   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 i, Counted_bars;                // Number of counted bars
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   if(Counted_bars<0)return(-1);
   i=Bars-Counted_bars;           // Index of the first uncounted
   while(i>=0)                      // Loop for uncounted bars
     {
      if((iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1)) && (iStdDev(Symbol(),0,Magic_Period,i)>iStdDev(Symbol(),0,Magic_Period,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)>iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-1","9048034884",1,i) != 2147483647.0))
      {
         BuyBuffer[i]=Low[i];
         BuyVal = High[i];
         Buy = true;
      }

      if((iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1)) && (iStdDev(Symbol(),0,Magic_Period,i)>iStdDev(Symbol(),0,Magic_Period,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)<iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-1","9048034884",0,i) != 2147483647.0))
      {
         SellBuffer[i]=High[i];
         SelVal = Low[i];
         Sell = true;
      }
      if ((BuyVal !=0) && (Close[i] > BuyVal) && Buy == true &&  (iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1))&& (iStdDev(Symbol(),0,Magic_Period,i)>iStdDev(Symbol(),0,Magic_Period,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)>iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)))
      {
         NewBuyBuffer[i] = Low[i] - 10 * Point;
         Buy = false;
         if (Time[i] == Time[1])
         {
            Alert ("Rock Trader: ",Symbol()+" : Sell @ "+Open[0]);
            Alert ("Rock Trader: ",Symbol()+" : Sell StopLoss @ "+BuyVal);
         }         
      }
      if ((iClose(Symbol(),0,i)<SelVal)&& Sell == true && (iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1))&& (iStdDev(Symbol(),0,Magic_Period,i)>iStdDev(Symbol(),0,Magic_Period,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)<iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)))
      {
         NewSellBuffer[i]=High[i] + 10 * Point;
         Sell = false;
         if (Time[i] == Time[1])
         {
            Alert ("Rock Trader: ",Symbol()+" : Sell @ "+Open[0]);
            Alert ("Rock Trader: ",Symbol()+" : Sell StopLoss @ "+SelVal);
         }
      }         
      i--;                          // Calculating index of the next bar
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
void Calls()
{
double j =  iCustom(Symbol(),0,"Rock-Trader-1","9048034884",0,1);
double h = iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,1);
double i = iCustom(Symbol(),0,"Rock-Trader-3","9388301300",0,1);
double b = iCustom(Symbol(),0,"Rock-Trader-4","8590301300",0,1);
double c = iCustom(Symbol(),0,"Rock-Trader-5","9388301300",0,1);
}
 
The calling names inside iCustom are most probably the culprit. What do you know about iCustom?
 

You missed out several of the parameters required for iStdDev - https://docs.mql4.com/indicators/istddev

Yours: (4 parameters)

iStdDev(Symbol(),0,Magic_Period,i)

Correct Example: (7 parameters)

iStdDev(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,0)
 
deysmacro:
The calling names inside iCustom are most probably the culprit. What do you know about iCustom?



I only have problem with iStdDev parameters Mr.Knave helping me.


Thks

 
honest_knave:

You missed out several of the parameters required for iStdDev - https://docs.mql4.com/indicators/istddev

Yours: (4 parameters)

Correct Example: (7 parameters)



Dear Knave,

Now there is no Error message, but the indicator not working, my BUY/SELL condition is Standerd Deviation Value Must be rising .

when other parameters are equal (Present bar SteDev Value > Previous bar SteDev value)

Please Help

//+------------------------------------------------------------------+
//|                                               Rock-Trader-ME.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 strict
#property indicator_chart_window
#property indicator_buffers 5       // Number of buffers

//--- input parameters
input int      Magic_Value=4;
input int      Magic_Period=20;

int limit, counted_bars;
double BuyVal, SelVal;
double BuyBuffer[];
double SellBuffer[];
double NewBuyBuffer[];
double NewSellBuffer[];
bool Buy = false;
bool Sell = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, BuyBuffer);
   SetIndexStyle(0,DRAW_ARROW,2,1,clrBlue);
   SetIndexArrow(0,119);
   SetIndexLabel(0,"RT Buy SL");
  
   SetIndexBuffer(1, SellBuffer);
   SetIndexStyle(1,DRAW_ARROW,2,1,clrRed);
   SetIndexArrow(1,119);
   SetIndexLabel(1,"RT Sell SL");
   
   SetIndexBuffer(2, NewBuyBuffer);
   SetIndexStyle(2,DRAW_ARROW,2,3,clrBlue);
   SetIndexArrow(2,221);
   SetIndexLabel(2,"RT Buy Now");
   
   SetIndexBuffer(3, NewSellBuffer);
   SetIndexStyle(3,DRAW_ARROW,2,3,clrRed);
   SetIndexArrow(3,222);
   SetIndexLabel(3,"RT Sell Now");
//---
   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 i, Counted_bars;                // Number of counted bars
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   if(Counted_bars<0)return(-1);
   i=Bars-Counted_bars;           // Index of the first uncounted
   while(i>=0)                      // Loop for uncounted bars
     {
      if((iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1)) && (iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,0)>iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)>iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-1","9048034884",1,i) != 2147483647.0))
      {
         BuyBuffer[i]=Low[i];
         BuyVal = High[i];
         Buy = true;
      }

      if((iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1)) && (iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,0)> iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)<iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)) && (iCustom(Symbol(),0,"Rock-Trader-1","9048034884",0,i) != 2147483647.0))
      {
         SellBuffer[i]=High[i];
         SelVal = Low[i];
         Sell = true;
      }
      if ((BuyVal !=0) && (Close[i] > BuyVal) && Buy == true &&  (iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1))&& (iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,0)>iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)>iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)))
      {
         NewBuyBuffer[i] = Low[i] - 10 * Point;
         Buy = false;
         if (Time[i] == Time[1])
         {
            Alert ("Rock Trader: ",Symbol()+" : Sell @ "+Open[0]);
            Alert ("Rock Trader: ",Symbol()+" : Sell StopLoss @ "+BuyVal);
         }         
      }
      if ((iClose(Symbol(),0,i)<SelVal)&& Sell == true && (iATR(Symbol(),0,Magic_Value,i)>iATR(Symbol(),0,Magic_Value,i+1))&& (iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,0)>iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,1)) && (iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i)<iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,i+1)))
      {
         NewSellBuffer[i]=High[i] + 10 * Point;
         Sell = false;
         if (Time[i] == Time[1])
         {
            Alert ("Rock Trader: ",Symbol()+" : Sell @ "+Open[0]);
            Alert ("Rock Trader: ",Symbol()+" : Sell StopLoss @ "+SelVal);
         }
      }         
      i--;                          // Calculating index of the next bar
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
void Calls()
{
double j =  iCustom(Symbol(),0,"Rock-Trader-1","9048034884",0,1);
double h = iCustom(Symbol(),0,"Rock-Trader-2","8590301300",0,1);
double i = iCustom(Symbol(),0,"Rock-Trader-3","9388301300",0,1);
double b = iCustom(Symbol(),0,"Rock-Trader-4","8590301300",0,1);
double c = iCustom(Symbol(),0,"Rock-Trader-5","9388301300",0,1);
}
 

Try changing the final parameter from 0 to i (and 1 to i+1):

iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,0)>iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,1))

to

iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,i)>iStdDev(Symbol(),0,Magic_Period,0,MODE_EMA,PRICE_CLOSE,i+1))
 
 OnCalculate()

don't match with

IndicatorCounted();

try start() instead

 
honest_knave:

Try changing the final parameter from 0 to i (and 1 to i+1):

to


U R Really Honest, thanks, it worked
 
ffoorr:

don't match with

try start() instead


IndicatorCounted() remains available either way, as does Bars().

 
Rock-Trader:

U R Really Honest, thanks, it worked

You're welcome. Glad to help.
Reason: