Download MetaTrader 5
To add comments, please log in or register
Find and download Code Base apps via MetaTrader. It is fast!
terrace au
7
terrace au 2015.02.11 16:48 

Hi,

  

I've tired for a few days where I still can't solve the equation. The default setting for the 2 "Tenkan Sen" and "Kijun Sen" is set by taking the highest high+lowest low/2. I wanted to change the setting to  high+lowest low * 0.618 & high+lowest low * 0.382 . No matter how I tried, it cannot be done. Please help me to amend the code.

 

#property indicator_chart_window

#property indicator_buffers 7

#property indicator_color1 Red

#property indicator_color2 Blue

#property indicator_color3 SandyBrown

#property indicator_color4 Thistle

#property indicator_color5 Lime

#property indicator_color6 SandyBrown

#property indicator_color7 Thistle

 

 

//---- input parameters

 

extern int Tenkan=18;

extern int Kijun=52;

 

 

//---- buffers

 

double Tenkan_Buffer[];

double Kijun_Buffer[];

 

 

//----

 

int a_begin;

 

 

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

//| Custom indicator initialization function |

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

 

int init()

 

 

{

 

//----

 

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,Tenkan_Buffer);

SetIndexDrawBegin(0,Tenkan-1);

SetIndexLabel(0,"Tenkan Sen");

 

 

//----

 

SetIndexStyle(1,DRAW_LINE);

SetIndexBuffer(1,Kijun_Buffer);

SetIndexDrawBegin(1,Kijun-1);

SetIndexLabel(1,"Kijun Sen");

return(0);

 

 

}

 

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

//| Ichimoku Kinko Hyo |

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

 

int start()

 

 

{

 

int i,k;

double counted_bars=IndicatorCounted();

double high,low,price,a1,b2;

 

 

 

//----

 

if(Bars<=Tenkan || Bars<=Kijun) return(0);

 

 

//---- initial zero

 

if(counted_bars<1)

 

 

{

 

for(i=1;i<=Tenkan;i++) Tenkan_Buffer[Bars-i]=0;

for(i=1;i<=Kijun;i++) Kijun_Buffer[Bars-i]=0;

 

 

}

 

//---- Tenkan Sen

 

i=Bars-Tenkan;

if(counted_bars>Tenkan) i=Bars-counted_bars-1;

while(i>=0)

 

 

{

 

high=High[i]; low=Low[i]; k=i-1+Tenkan;

while(k>=i)

 

 

{

 

price=High[k];

if(high<price) high=price;

price=Low[k];

if(low>price) low=price;

k--;

 

 

}

 

Tenkan_Buffer[i]=(high+low)*0.618;

i--;

 

 

}

 

//---- Kijun Sen

 

i=Bars-Kijun;

if(counted_bars>Kijun) i=Bars-counted_bars-1;

while(i>=0)

 

 

{

 

high=High[i]; low=Low[i]; k=i-1+Kijun;

while(k>=i)

 

 

{

 

price=High[k];

if(high<price) high=price;

price=Low[k];

if(low>price) low=price;

k--;

 

 

}

 

Kijun_Buffer[i]=(high+low)*0.382;

i--;

 

 

}

 

 

 

return(0);

 

 

}

 

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

Carl Schreiber
5937
Carl Schreiber 2015.02.11 17:18  

Please edit your post and post your code suing the SRC-button!!

Furthermore it would be nice if you delete all the unnecessary empty lines.

/
To add comments, please log in or register