Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
ang_Amp_ZZ
#property  copyright "ANG3110@latchess.com"
//-------------ang_Amp_ZZ---------------
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Blue
//--------------------------------
extern int d=40;
//---------------------------------
double ha[],la[],zz[];
double hi,li,hm,lm,di,j;
int f,f1,ai,bi,aii,bii,f0,aibar,bibar;
di=d*Point;
//----------------------------------------------
int init()  {   
SetIndexStyle(0,DRAW_LINE);   
SetIndexBuffer(0,ha);   
SetIndexBuffer(1,la);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(2,zz);
return(0);  }
//================================
int start()  {   
//--------------------------------
int i,n,cb,cbi,cbn,fs,bar;
//------------------------
//cb=IndicatorCounted();
//if (cb<0) return (-2);
//if (cb>0) cb--;
//cbi=Bars-cb;
//if (Bars<bar | Bars-bar>1) fs=0; bar=Bars;
//if (fs==0) {cbi=Bars-2; cbn=Bars-2; if (cbi<0) return(0); fs=2;}
cbi=Bars-IndicatorCounted()-2;
//-----------------------
//cbi=cbi+4;
for(i=cbi; i>=0; i--){                              
if (i>=Bars-2) {hi=High[i]; li=Low[i];}      
//==============================================================
if (Low[i]>hi) {hi=Low[i]; if (hi>=li+di) li=hi-di;}
if (High[i]<li) {li=High[i]; if (li<=hi-di) hi=li+di;}
//------------------------------------------------------------------------------------

if (High[i]>hi && Low[i]<li) {if (High[i]-hi>li-Low[i]) {f1=2;} else f1=4;} else f1=0;
if (f==0 && High[i]>hi) {hm=High[i]; ai=i; f=2;}
if (f==0 && Low[i]<li) {lm=Low[i]; bi=i; f=4;}

if (f==4 && High[i]>hi && f1!=4) {hm=High[i]; f=2; f0=0; for (n=ai; n>=bi; n--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);} ai=i;}
if (f==2 && High[i]>hm && f1!=4) {hm=High[i]; ai=i; f0=0;}
if (f==2 && Low[i]<li && f1!=2)  {lm=Low[i];  f=4; f0=0; for (n=bi; n>=ai; n--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);} bi=i;}
if (f==4 && Low[i]<lm && f1!=2)  {lm=Low[i];  bi=i; f0=0;}
//---------------------------------------------
if (i==0 && f0==0) {aibar=Bars-ai; bibar=Bars-bi; f0=1;} 
if (f0==2) {ai=Bars-aibar; bi=Bars-bibar;} 

if (i==0 && ai>bi) for (n=ai; n>=bi; n--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);}
if (i==0 && ai<bi) for (n=bi; n>=ai; n--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);}

if (i==0 && f==2) {for (n=ai; n>=0; n--) {zz[n]=Close[0]*(n-ai)/(0-ai)+High[ai]*(n-0)/(ai-0);}}
if (i==0 && f==4) {for (n=bi; n>=0; n--) {zz[n]=Close[0]*(n-bi)/(0-bi)+Low[bi]*(n-0)/(bi-0);}}
if (i==0 && bi==0) {for (n=ai; n>=0; n--) {zz[n]=Low[0]*(n-ai)/(0-ai)+High[ai]*(n-0)/(ai-0); }}
if (i==0 && ai==0) {for (n=bi; n>=0; n--) {zz[n]=High[0]*(n-bi)/(0-bi)+Low[bi]*(n-0)/(bi-0); }}
//--------------------------------------------
ha[i]=hi;
la[i]=li;

//cbi=cbi-2;
}   
//------------------------------------
return(0);  }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---