How to get object values from different symbols

 

Hi,

I'm trying to extract the object values from trend lines on my chart to a csv file. I started with the RSI_to_file script, which can get the indicator values from a number of different symbols in one go. My problem is, because I'm getting the values from an object, I can't specify what symbol the object is on, it keeps taking the object values from the chart the script is attached to. The original RSI_to_file script used iCustom, so it could specify the symbol to get the values from.

In summary, I've got 10 "MyLineHigh" values and 10 "MyLineLow" values on each chart. I want to be able to drop the script on 1 chart and get the price value for each line from the 5 different symbols to a csv. The code at the moment keeps taking the values off the chart the script is attached to. Is there a way I can get the object values of the other symbols?

Thanks.

//+------------------------------------------------------------------+
//|                                               Object_to_File.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.ru/"

#property show_inputs
string SymbolsArray[6]={"","AUDJPY","AUDUSD","EURCAD","EURCHF","EURGBP"};



//+------------------------------------------------------------------+
//| string SymbolByNumber                                   |
//+------------------------------------------------------------------+
string GetSymbolString(int Number)
  {
//----
   string res="";
   res=SymbolsArray[Number];   
//----
   return(res);
  }



//+------------------------------------------------------------------+
//|   âûâîäèò â ôàéë êîòèðîâêè + çíà÷åíèÿ èíäèêàòîðà                 |
//+------------------------------------------------------------------+
void Line_output(string SymbolName)
   {
   
//----
   
   int handle=FileOpen("LineValue.csv",FILE_CSV|FILE_READ|FILE_WRITE, ';');
   
   if(handle>0) 
   {
   FileSeek(handle, 0, SEEK_END);
   FileWrite(handle,"Symbol;Time;High;Low");
   
   
   for (int i=10;i>0;i--)
      {
      FileWrite(handle,SymbolName,TimeToStr(ObjectGet("MyLineHigh"+i,OBJPROP_TIME1))
         ,ObjectGet("MyLineHigh"+i,OBJPROP_PRICE1), ObjectGet("MyLineLow"+i,OBJPROP_PRICE1)) ;
         
      }
   FileClose(handle);
   handle=0;
   }      
//----
   return;
   }
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
  int SymbolCounter; 
//----
   
   for (SymbolCounter=1;SymbolCounter<6;SymbolCounter++)
      {
                 
         Line_output(GetSymbolString(SymbolCounter));
            
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Tadeusz:

Hi,

I'm trying to extract the object values from trend lines on my chart to a csv file. I started with the RSI_to_file script, which can get the indicator values from a number of different symbols in one go. My problem is, because I'm getting the values from an object, I can't specify what symbol the object is on, it keeps taking the object values from the chart the script is attached to. The original RSI_to_file script used iCustom, so it could specify the symbol to get the values from.

In summary, I've got 10 "MyLineHigh" values and 10 "MyLineLow" values on each chart. I want to be able to drop the script on 1 chart and get the price value for each line from the 5 different symbols to a csv. The code at the moment keeps taking the values off the chart the script is attached to. Is there a way I can get the object values of the other symbols?

Thanks.

You cannot get the properties of Objects on other charts only the chart that your code is running on.
 
Tadeusz:. Is there a way I can get the object values of the other symbols?


If you don't mind the confusion on the current chart, or clean it up, you can. Just calculate the objects according to the symbol, period data you want, but draw them on the current chart. After you get the values delete the objects. I call a function where symbol and timeframe are parameters and get the values when returned from the function. This way I get the values for example of ZUP objects on several pairs and timeframes.

Another way is to directly output the calculated values without objects, if it is applicable for your situation. I think you can instantly write your MyLineHigh values to csv when calculated. This way there is no need of chart cleanup, but you have to modify that fuinction or whatever that draws the objects.

for example:

calculate("EURUSD", PERIOD_H1);

get_object_values();

delete_objects();

calculate("GBPUSD", PERIOD_H4);

get_object_values();

delete_objects();

etc.

Reason: