stonejiang wrote >>
i tried to write a indicator. this indicator should looks like zigzag.
the from the left first bar use the first bar's openprice as the first zag point.
then from left to right, if some the price is max or min than the first point over 20points draw section, and then the next point is max or min than the previous point over 20 points
my code:
please help to make this right. thank you.
Not sure what your ideas is, hope the below code is what you need.
#property copyright "Copyright ?2009, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- input parameters extern int pipstep=20; //---- buffers double ExtMapBuffer1[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_SECTION); SetIndexBuffer(0,ExtMapBuffer1); SetIndexEmptyValue(0,0.0); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- int limit; static double last = 0; //---- last counted bar will be recounted limit = Bars - counted_bars - 1; int i = limit; while (i>=0) { if(i == Bars-1) last = Open[i]; if (High[i] > last+pipstep*Point) { last = High[i]; ExtMapBuffer1[i] = High[i]; } else { if (Low[i] < last-pipstep*Point) { last = Low[i]; ExtMapBuffer1[i] = Low[i]; } else { ExtMapBuffer1[i] = 0; } } i--; } return(0); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
i tried to write a indicator. this indicator should looks like zigzag.
the from the left first bar use the first bar's openprice as the first zag point.
then from left to right, if some the price is max or min than the first point over 20points draw section, and then the next point is max or min than the previous point over 20 points
my code:
please help to make this right. thank you.