Help Lisa!!draw an arrow in the main window

To add comments, please log in or register
Powderhase
27
Powderhase  

Hi!

i have this cool code, but  i do not manage to get an arrow in the chart window each time the signal is send:-(

can anybody help me??

Thanks!

Lisa


#property indicator_chart_window


#property indicator_buffers 1

#property indicator_color1 LightSeaGreen
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
//---- input parameters






extern int CCIPeriod=14;

extern int CCIHigh=100;

extern int CCILow=-100;
extern int SMA_Period=9;
  
int PlayedSoundH = False;

bool message_sent;



int PlayedSoundL = False;
int R1=0;
  int R2=0;
  int R3=0;
  int Routput=0;
  
//---- buffers

double CCIBuffer[];

double RelBuffer[];

double DevBuffer[];

double MovBuffer[];
double Buytrigger[];
double Selltrigger[];
double Signal[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int init()

  {

   string short_name;

//---- 3 additional buffers are used for counting.

   IndicatorBuffers(4);

   

   SetIndexBuffer(1, RelBuffer);

   SetIndexBuffer(2, DevBuffer);

   SetIndexBuffer(3, MovBuffer);
   
SetIndexEmptyValue(0,0);

SetIndexEmptyValue(1,0);

//---- indicator lines

   SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 234);
   SetIndexBuffer(0, Signal);
   SetIndexBuffer(1, Buytrigger);
   SetIndexBuffer(2, Selltrigger); 
   
//----
   SetIndexLabel(0,"Signal");
   SetIndexLabel(1,"Buytrigger");
   SetIndexLabel(2,"Selltrigger");
   SetIndexBuffer(0,CCIBuffer);

//---- name for DataWindow and indicator subwindow label

   short_name="CCI("+CCIPeriod+")";

   IndicatorShortName(short_name);

   SetIndexLabel(0,short_name);

//----

   SetIndexDrawBegin(0,CCIPeriod);

//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Commodity Channel Index                                          |

//+------------------------------------------------------------------+

int start()

  {
 R1 = (iMA (NULL, NULL,SMA_Period,0,MODE_EMA,PRICE_CLOSE,0)*10000 - iMA(NULL, NULL,SMA_Period,0,MODE_EMA,PRICE_CLOSE,1)*10000);
    R2 = (iMA (NULL, NULL,SMA_Period,0,MODE_EMA,PRICE_CLOSE,1)*10000 - iMA(NULL, NULL,SMA_Period,0,MODE_EMA,PRICE_CLOSE,2)*10000);
     R3 = (iMA (NULL, NULL,SMA_Period,0,MODE_EMA,PRICE_CLOSE,2)*10000 - iMA(NULL, NULL,SMA_Period,0,MODE_EMA,PRICE_CLOSE,3)*10000);
          
            Routput = (R1 + R2 + R3) / 0.3; 
            
   int    i,k,counted_bars=IndicatorCounted();

   double price,sum,mul;

   if(Bars<=CCIPeriod) return(0);

//---- initial zero

   if(counted_bars<1)

     {

      for(i=1;i<=CCIPeriod;i++) CCIBuffer[Bars-i]=0.0;

      for(i=1;i<=CCIPeriod;i++) DevBuffer[Bars-i]=0.0;

      for(i=1;i<=CCIPeriod;i++) MovBuffer[Bars-i]=0.0;

     }

//---- last counted bar will be recounted

   int limit=Bars-counted_bars;

   if(counted_bars>0) limit++;

//---- moving average

   for(i=0; i<limit; i++)

      MovBuffer[i]=iMA(NULL,0,CCIPeriod,0,MODE_SMA,PRICE_TYPICAL,i);

//---- standard deviations

   i=Bars-CCIPeriod+1;

   if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;

   mul=0.015/CCIPeriod;

   while(i>=0)

     {

      sum=0.0;

      k=i+CCIPeriod-1;

      while(k>=i)

       {

         price=(High[k]+Low[k]+Close[k])/3;

         sum+=MathAbs(price-MovBuffer[i]);

         k--;

       }

      DevBuffer[i]=sum*mul;

      i--;

     }

   i=Bars-CCIPeriod+1;

   if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;

   while(i>=0)

     {

      price=(High[i]+Low[i]+Close[i])/3;

      RelBuffer[i]=price-MovBuffer[i];

      i--;

     }

//---- cci counting

   i=Bars-CCIPeriod+1;

   if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;

   while(i>=0)

     {

      if(DevBuffer[i]==0.0) CCIBuffer[i]=0.0;

      else CCIBuffer[i]=RelBuffer[i]/DevBuffer[i];

      i--;

     }

   if(CCIBuffer[0]<CCIHigh){PlayedSoundH = False;}

   

   if(CCIBuffer[0]>CCILow){PlayedSoundL = False;}  

   

   

   

   if( CCIBuffer[0]>=CCIHigh && PlayedSoundH == False){
    if(message_sent==1)
      {
      
       message_sent=0;
      }
    

        }

   



   if( CCIBuffer[0]<=CCILow && PlayedSoundL == False && Routput<0 && iMACD(NULL,0,1,26,9,PRICE_CLOSE,MODE_MAIN,0)>0){
    if(message_sent==0)
      {
       SendNotification("CCI100: " + Symbol() + " low"); 
        ObjectCreate(" Buy Trigger " +Buytrigger[i]+"", OBJ_RECTANGLE, 0, Time[i], High[i], Time[i+1], Low[i]); 
      ObjectSetInteger(0," Buy Trigger " +Buytrigger[i]+"",OBJPROP_COLOR,PaleGreen);
      }
       
       message_sent=1;
      }
     



    

      return(0);

  }
To add comments, please log in or register