A loop to save price an indicators values

To add comments, please log in or register
rookypipskiller
7
rookypipskiller  

Hello

I Use this code to save price and CCI value and ASI value.

The saved file name contain the indicators period.

I save a CCI(14) but i would like to save CCI(15) in an other file, CCI(16) in an other file ...

Can you help me please ?

#property copyright "Copyright © 2013 Trading Attitude"
#property link      "http://www.trading-attitude.com"

//#property indicator_chart_window

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue

//---- input parameters
extern int       Periode_CCI=14;
extern int       Periode_ASI=300;
extern int       BLOCK = 20;

   int   handle;
   
double iBuffer1[];

int init() {

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,iBuffer1);

   string name = "My Indicator 1";

   IndicatorShortName(name);

   string filename = Symbol()+"_"+Period() + "_"+BLOCK+"_"+Periode_CCI+"_"+Periode_ASI+".txt";
   handle=FileOpen(filename,FILE_CSV|FILE_WRITE,';');
   
   return(1);
}

int deinit() {
   FileClose (handle);

   return(0);
}

int start() {
   int countedBars=IndicatorCounted();

   if (countedBars<0) {
      return(-1);
   }

   if (countedBars>0) {
      countedBars--;
   }

   int pos = Bars - countedBars;
pos--;
   

   while(pos>=1) {
      double CCI = iCCI(NULL,0,Periode_CCI,PRICE_TYPICAL,pos);
      double ASI = iCustom(NULL,0,"_ASI",Periode_ASI,0,pos);
      iBuffer1[pos]= ASI; 
      FileWrite (handle,Time[pos]+";"+Open[pos],Low[pos],High[pos],Close[pos],CCI,ASI);
   
      pos--;
   }
   Comment("Finished "+countedBars+" - "+Bars); 
   return(0);
}


Thank you

paul selvan
629
paul selvan  
When CCI 14 file is well saved , then open another one for CCI15.And then so on for CCI16
To add comments, please log in or register