what am i doing wrong

 

in the following code i am trying to draw an arrow on the cci 8 change


but i think i am doing something wrong, but can't figure it out


help


//+------------------------------------------------------------------+
//| custom_cci.mq4 |
//| Copyright © 2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
extern int cciperiod=8;
double CrossUp[];
double CrossDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 241);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 242);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
double cci80 =NormalizeDouble(iCCI(Symbol(),0,8,PRICE_CLOSE,0),Digits);
double cci81 =NormalizeDouble(iCCI(Symbol(),0,8,PRICE_CLOSE,1),Digits);

if (cci80>cci81) {CrossUp[0]=1;}
if (cci80<cci81) {CrossDown[0]=1;}

//----
return(0);
}
//+------------------------------------------------------------------+

 
Is the indicator value CrossUp/Down[0] = 1 somewhere around the current price? Perhaps you just can't see the arrows at 1.0000 price level.
 

int start()
{
//----

DrawObject(Time[0],High[0],171,Yellow,1);

//----
return(0);
}

void DrawObject(datetime dte_time, double dbl_amount, int int_icon, color o_color, int int_width)
{
string name = "current_spread_"+ (Ask-Bid);
ObjectDelete(name);
ObjectCreate(name, OBJ_ARROW, 0, dte_time, dbl_amount);
ObjectSet(name, OBJPROP_ARROWCODE, int_icon);
ObjectSet(name, OBJPROP_COLOR, o_color);
ObjectSet(name, OBJPROP_WIDTH, int_width);
//ObjectsRedraw(); - only uncomment if your not using this elsewhere in your code
}

Greets JB

 

Basically what I wish to do is


If the current candle cci value is lower than the previous candle cci value then arrow down


If the current candle cci value is higher than the previous candle cci value then arrow up


So this tells me the price divergence.


I just copied the previous code from somewhere to make it work this way, but it did not.

Reason: