Hi guys, I'm trying to code the double bottom chart pattern using fractals, and although the compiler says there are no errors, it doesnt seem to work in an EA. can you help me figure out whats wrong?
<CODE REMOVED>
double val1,val2,v1[],v2[]; double Lows[],Highs[]; double highshift[],lowshift[]; double p1[],p2[]; //these can tell me what the shift value is : { //always use brackets with if statements!! it makes things alot easier v1[i] = High[i]; //so if an upper fractal exists, we assign the high value to the buffer to draw it there.How many elements does v1 have when you assign to v1[i]?
How many elements does v1 have when you assign to v1[i]?
99 since i goes from 1 to 99. but it can be arbitrary. I just need enough bars to have 2 lower fractals and 1 upper fractal in between them.
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
Thanks for the tip. I corrected it.
99 since i goes from 1 to 99. but it can be arbitrary. I just need enough bars to have 2 lower fractals and 1 upper fractal in between them.
Wrong. v1[] has ZERO. "i" is irrelevant.
why? I thought whenever v[i]=something I am assigning a value to the ith element of the array. I used code from the support and resistance indicator, which runs fine.
//+------------------------------------------------------------------+ //| Support and Resistance | //| Copyright © 2004 Barry Stander | //| http://myweb.absa.co.za/stander/4meta/ | //+------------------------------------------------------------------+ #property copyright "Click here: Barry Stander" #property link "http://myweb.absa.co.za/stander/4meta/" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Blue //---- buffers double v1[]; double v2[]; double val1; double val2; int i; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexArrow(0, 119); //first number is the line index, which is from 0 to 7. so we can have up to 8 different things drawn SetIndexArrow(1, 119); //from one indicator. the second number is the code for the symbol. //---- SetIndexStyle(0, DRAW_ARROW, STYLE_DOT, 1); //describes what and how the line will be drawn SetIndexDrawBegin(0, i-1); //2nd number refers to the first bar where it will be drawn. SetIndexBuffer(0, v1); //basically assigns the double values from the array v1 to the buffer SetIndexLabel(0,"Resistance"); //basically labelling our buffer //---- SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,1); SetIndexDrawBegin(1,i-1); SetIndexBuffer(1, v2); SetIndexLabel(1,"Support"); //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { i = Bars; //number of bars in current chart. it means we will apply the indicator to all the bars in chart. while(i >= 0) { val1 = iFractals(NULL, 0, MODE_UPPER, i); //---- if(val1 > 0) v1[i] = High[i]; //so if an upper fractal exists, we assign the high value to the buffer to draw it there. else v1[i] = v1[i+1]; //otherwise, we use the previous fractal level. val2 = iFractals(NULL, 0, MODE_LOWER, i); //same as above, except its lower fractals. //---- if(val2 > 0) v2[i] = Low[i]; else v2[i] = v2[i+1]; i--; } return(0); //we basically return an arbitrary value like 0 because thats how the function has to be written. } //+------------------------------------------------------------------+
why? I thought whenever v[i]=something I am assigning a value to the ith element of the array. I used code from the support and resistance indicator, which runs fine.
You are assigning it to the ith element IF the array has i elements. You declared the arrays as zero length. Either the original code resized the array or the array was originally a indicator buffer (autoresizing to Bars)
You are assigning it to the ith element IF the array has i elements. You declared the arrays as zero length. Either the original code resized the array or the array was originally a indicator buffer (autoresizing to Bars)
Ok got it. so if I wanted an array with 100 elements, I would write
double v1[100];
right? Ok I did that. I have it in an EA, so that I buy when the pattern shows up. But when I press start for backtesting, nothing seems to happen. I'm not sure if the EA just takes a really really long time to load, or if its something else. I pressed start and waited 20 minutes, but the progress bar is not moving at all.
Ok got it. so if I wanted an array with 100 elements, I would write
double v1[100];
right? Ok I did that. I have it in an EA, so that I buy when the pattern shows up. But when I press start for backtesting, nothing seems to happen. I'm not sure if the EA just takes a really really long time to load, or if its something else. I pressed start and waited 20 minutes, but the progress bar is not moving at all.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys, I'm trying to code the double bottom chart pattern using fractals, and although the compiler says there are no errors, it doesnt seem to work in an EA. can you help me figure out whats wrong?