Dukascopy
 
 
Wiki JStore Search Login

Incorrect an indicator convert. Could you help me with this?
 Post subject: Incorrect an indicator convert. Could you help me with this? Post rating: 0   New post Posted: Tue 14 Jan, 2014, 18:38 

User rating: 0
Joined: Tue 14 Jan, 2014, 17:51
Posts: 1
Location: KazakstanKazakstan
I'm sorry. My English is not really good, but i have some problem, with my indicator.

What does it do?

1) First of all, it puts the data into the TempBuffer[i] from linear weighted MA with period 13.

2) Then from each bar's low is subtract MA and puts data into the M_Range[i].

3) After all, it finds the arithmetic average all bars and draws the static line from this average number.

I have 2 same indicators for Low and for High.

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
//---- input parameters
extern int BearsPeriod=13;
extern double Mult = 1.00;
//---- buffers
double BearsBuffer[];
double LevBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 1 additional buffer used for counting.
   IndicatorBuffers(3);
   IndicatorDigits(Digits);
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,BearsBuffer);
   SetIndexBuffer(1,LevBuffer);
   SetIndexBuffer(2,TempBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="Bears("+BearsPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetLevelValue(0,0.00);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Bears Power                                                      |
//+------------------------------------------------------------------+
int start()
  {
   int
      i,
      counted_bars=0;
//----
   if(Bars<=BearsPeriod)
      return(0);
//----
   int
      limit=Bars-counted_bars;
   if(counted_bars>0)
      limit++;
   for(i=0; i<limit; i++)
      TempBuffer[i]=iMA(NULL,0,BearsPeriod,0,MODE_LWMA,PRICE_MEDIAN,i);
//----
   double M_Range[];
   ArrayResize(M_Range,Bars);
   i=Bars-BearsPeriod-counted_bars-1;
   while(i>=0)
     {
      BearsBuffer[i]=Low[i]-TempBuffer[i];
      M_Range[i]=MathAbs(BearsBuffer[i]); 
      i--;
     }
   
   for(i=0; i<=Bars-BearsPeriod-1; i++)
      double Volume_B = Volume_B+M_Range[i];
   double Value = NormalizeDouble(Volume_B/(Bars-BearsPeriod-1),5)*Mult;
   for(i=0; i<=Bars-BearsPeriod-1; i++)
      LevBuffer[i]=Value;
   SetLevelValue(1,Value);
   SetLevelValue(2,-Value);
//----
   return(0);
  }


And for High
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
//---- input parameters
extern int BullsPeriod=13;
extern double Mult = 1.00;
//---- buffers
double BullsBuffer[];
double LevBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 1 additional buffer used for counting.
   IndicatorBuffers(3);
   IndicatorDigits(Digits);
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,BullsBuffer);
   SetIndexBuffer(1,LevBuffer);
   SetIndexBuffer(2,TempBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="Bulls("+BullsPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetLevelValue(0,0.00);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Bulls Power                                                      |
//+------------------------------------------------------------------+
int start()
  {
   int
       i,
       counted_bars=0;
//----
   if(Bars<=BullsPeriod) return(0);
//----
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++;
   for(i=0; i<limit; i++)
      TempBuffer[i]=iMA(NULL,0,BullsPeriod,0,MODE_LWMA,PRICE_MEDIAN,i);
//----
   double M_Range[];
   ArrayResize(M_Range,Bars);
   i=Bars-BullsPeriod-counted_bars-1;
   while(i>=0)
     {
      BullsBuffer[i]=High[i]-TempBuffer[i];
      M_Range[i]=MathAbs(BullsBuffer[i]);
      i--;
     }
   for(i=0; i<=Bars-BullsPeriod-1; i++)
      double Volume_B = Volume_B+M_Range[i];
   double Value = NormalizeDouble(Volume_B/(Bars-BullsPeriod-1),5)*Mult;
   for(i=0; i<=Bars-BullsPeriod-1; i++)
      LevBuffer[i]=Value;
   SetLevelValue(1,Value);
   SetLevelValue(2,-Value);
//----
   return(0);
  }
//+------------------------------------------------------------------+


This is indicators in Metatrader.
Image

This is in JForex, after compilation.
Image

Please, could you help me with this problem?


 
 Post subject: Re: Incorrect an indicator convert. Could you help me with this? Post rating: 1   New post Posted: Wed 22 Jan, 2014, 15:50 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please see this indicator version.
There is a new parameter "isHigh". If it is checked, "high" version is drawn, otherwise "low" version is used.


Attachments:
Indicator1.mq4 [2.3 KiB]
Downloaded 76 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com