Please help with simple indicator
I can't be much help as I haven't quite got to grips with histograms.
However you don't size the Bar2[] array and why do you need it anyway? Simply use Close[i] instead
#property copyright "Copyright 2013, Jimdandy1958" #property link "http://www.jimdandyforex.com" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_width1 3 #property indicator_color2 Red #property indicator_width2 3 #property indicator_maximum 1 #property indicator_minimum 0 extern int TimeFrame = 0; //string TF; double Bar_UP[]; double Bar_DN[]; /////////////////////////////////// int init() { IndicatorDigits(1); SetIndexBuffer(0,Bar_UP); SetIndexBuffer(1,Bar_DN); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexLabel(0,"UP Candle"); SetIndexLabel(1,"Down Candle"); return(0); } ////////////////////////////////////// int deinit() { return(0); } /////////////////////////////////////////// int start() { int limit; int counted_bars=IndicatorCounted(); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++) { if(Open[i] < Close[i]){Bar_UP[i]=1;Bar_DN[i]=EMPTY_VALUE;} else if(Open[i] > Close[i]){Bar_DN[i]=1;Bar_UP[i]=EMPTY_VALUE;} } return(0); } //+------------------------------------------------------------------+PipPip....Jimdandy
Thank you Jimdandy! That was very helpful!
I was over complicating everything and I had variables I didn't need. So, I am guessing that when I tried to set Bar[i] = Open[i] that I can't do that? Can I not set an array equal to another array?
I have been trying to write an indicator that will assign a 0 for a down bar and a 1 for an up bar. Here is the code for it. All my indicator is doing is printing red bars. So it seems my algorithm is wrong even though I do not see how. I am getting the open of the last bar and if it is less than the close of that same bar then it means the bar went up and then visa versa. So please help show me what is wrong with this?