Charting

 

I have a file with Symbol, Price and Description which are read into dynamic arrays mySymbol, myEntry, myDescription

I have written a script to open a new Chart for each entry:

- Symbol of the Chart is determined by the element from mySymbol

- Horizontal Line with the level from myEntry, name of Horizontal line from mySymbol, description from myDescription, colour is colourEntry, line style is lineStyleDot

 

What works:

- Opens all the Charts

- puts in Horizontal line with correct price level and correct name

 

What doesn’t work:

- the description doesn’t get populated

- the colour is not set, stays at red

- the linestyle is not set, stays at solidline

 

 

I have attached script and text file.

Any help is appreciated.

Files:
 

try this 

#property show_inputs
input color ColourEntry=clrGold;                         // Colour for Entry
input ENUM_LINE_STYLE LineStyle=STYLE_DOT;//Style For Entry 
input int LineWidth=1;//Line Width
string mySymbol[];
double myEntry[];
string myDescription[];
long myChartID[];

//+------------------------------------------------------------------+
int start()
{
   int handle;
   int counter = 0;
   string str;
   
   handle = FileOpen("myText.txt", FILE_CSV|FILE_READ|FILE_WRITE, "\t");
   
   if(handle==-1)
      return(0); 
   
   if(FileSize(handle)==0)
   {
      FileClose(handle);
      return(0);
   }

   
   
   while(!FileIsEnding(handle))
   {
      ArrayResize(mySymbol,counter+1);
      ArrayResize(myEntry,counter+1);
      ArrayResize(myDescription,counter+1);
      ArrayResize(myChartID,counter+1);
      

      str=FileReadString(handle);
      mySymbol[counter] = str;

      str=FileReadString(handle);
      myEntry[counter] =StringToDouble(str);

      str=FileReadString(handle);
      myDescription[counter] =str;

      counter++;
   }

   FileClose(handle); 
   
   for(int i = 0; i < ArraySize(mySymbol);  i++)
   {  
    
      myChartID[i] =ChartOpen(mySymbol[i],PERIOD_M1);
      
      ChartSetInteger(myChartID[i],CHART_BRING_TO_TOP,0,true);

      ObjectCreate(myChartID[i],mySymbol[i],OBJ_HLINE,0,0,myEntry[i]);
      ObjectSetInteger(myChartID[i],mySymbol[i],OBJPROP_COLOR,ColourEntry);
      ObjectSetInteger(myChartID[i],mySymbol[i],OBJPROP_WIDTH,LineWidth);
      ObjectSetInteger(myChartID[i],mySymbol[i],OBJPROP_BACK,True);
      ObjectSetInteger(myChartID[i],mySymbol[i],OBJPROP_STYLE,LineStyle);
      ObjectSetString(myChartID[i],mySymbol[i],OBJPROP_TOOLTIP,myDescription[i]);
      WindowRedraw();
      ChartRedraw(myChartID[i]);
   } 
   
   return(0);
}
//+------------------------------------------------------------------+

 
Lorentzos Roussos:

try this 

Thank you for that Lorentzos.

ObjectSetString did the trick.

For the Description (rather than the tooltip) I used 

 
libby000:

Thank you for that Lorentzos.

ObjectSetString did the trick.

For the Description (rather than the tooltip) I used 

Yes , ObjectSetText does not work with Horizontal Lines

Reason: