Which method is fast and resource friendly for multicurrency scanner?

Arpit T
507
  • 67% (6)
  • 22% (2)
  • 11% (1)
Total voters: 9
Keith Watford
Moderator
35484
Arpit T:
  • Buffer
  • Objects
  • Global Variable
Multi-currency scanner? Do you mean multi-symbol or some sort of currency strength meter?

Please explain your method for using objects or Global Variables in such a scanner .

Fernando Carreiro
10836
Your question makes no sense. A multi-symbol scanner would make use of none of those, especially not Objects or Global Variables. Buffers would be the only one that might be considered if you were to scan indicator values for those symbols, but it still does not make much sense in terms of your question.
Arpit T
507
Arpit T  
Keith Watford #:
Multi-currency scanner? Do you mean multi-symbol or some sort of currency strength meter?

Please explain your method for using objects or Global Variables in such a scanner .

Multi symbol scanner which scans any value from it. in Russian Multi Symbol = Multicurrency

Arpit T
507
Arpit T  
Fernando Carreiro #:
Your question makes no sense. A multi-symbol scanner would make use of none of those, especially not Objects or Global Variables. Buffers would be the only one that might be considered if you were to scan indicator values for those symbols, but it still does not make much sense in terms of your question.
It's not true. I also believed that buffer will be only way but it's true that objects can be converted into buffer, however this is not a right approach, but possible. GlobalVariableGet and GlobalVariableSet can also be used to scan multi symbol and it's more faster than buffers in my test 
Keith Watford
Moderator
35484
Arpit T #:
Multi symbol scanner which scans any value from it. in Russian Multi Symbol = Multicurrency

I don't know Russian, but I very much doubt that "Multicurrency" is a Russian word.

Keith Watford
Moderator
35484
Arpit T #:
It's not true. I also believed that buffer will be only way but it's true that objects can be converted into buffer, however this is not a right approach, but possible. GlobalVariableGet and GlobalVariableSet can also be used to scan multi symbol and it's more faster than buffers in my test 

Please explain how an object can be converted into a buffer from a multi-symbol scanner.

Please explain how GlobalVariableGet and GlobalVariableSet can also be used from a multi-symbol scanner.

I have already asked for explanations of your methods and you have not clarified.

Keith Watford #:
Multi-currency scanner? Do you mean multi-symbol or some sort of currency strength meter?

Please explain your method for using objects or Global Variables in such a scanner .

The only way that I see this is possible would be to have charts open for every symbol being scanned and each chart having an indicator running to create these objects and Global Terminal Values. To access objects on another chart, the scanner would also have to know the chart id. This seems rather clumsy to me.

Arpit T
507
Arpit T  
Keith Watford #:

Please explain how an object can be converted into a buffer from a multi-symbol scanner.

Please explain how GlobalVariableGet and GlobalVariableSet can also be used from a multi-symbol scanner.

I have already asked for explanations of your methods and you have not clarified.

The only way that I see this is possible would be to have charts open for every symbol being scanned and each chart having an indicator running to create these objects and Global Terminal Values. To access objects on another chart, the scanner would also have to know the chart id. This seems rather clumsy to me.

kindly read this

https://www.mql5.com/en/articles/2744


 for objects to Buffer convert, see this simple code

double Up[1];
double Price2=NormalizeDouble(ObjectGetDouble(0,Name,OBJPROP_PRICE,1),Digits());
       
            UP[0]=Price2; // Buffer
MQL5 Programming Basics: Global Variables of the MetaTrader 5 Terminal
MQL5 Programming Basics: Global Variables of the MetaTrader 5 Terminal
  • www.mql5.com
Global variables of the terminal provide an indispensable tool for developing sophisticated and reliable Expert Advisors. If you master the global variables, you will no more be able to imagine developing EAs on MQL5 without them.
Keith Watford
Moderator
35484
Arpit T #:

read this

https://www.mql5.com/en/articles/2744

 for objects to Buffer convert, see this simple code

double Price2=NormalizeDouble(ObjectGetDouble(0,Name,OBJPROP_PRICE,1),Digits());
       
            UP[cont1]=Price2; // Buffer

Yes, I know how to use Global Terminal Variables and I have converted a number of indicators to use buffers instead of objects.

double Price2=NormalizeDouble(ObjectGetDouble(0,Name,OBJPROP_PRICE,1),Digits());

Note that the above code gets the value of an object that is on the current chart. Not very useful for a multi-symbol scanner.

You still haven't answered my questions.

Keith Watford #:

Please explain how an object can be converted into a buffer from a multi-symbol scanner.

Please explain how GlobalVariableGet and GlobalVariableSet can also be used from a multi-symbol scanner.

Ok, a simple exercise for you.

Create a simple indicator to get values using an object and a GV for a symbol that is different to the symbol that the indicator is attached to. Bear in mind that there may not be a chart open with the  relevant symbol and time-frame.

Arpit T
507
Arpit T  
Keith Watford #:

Yes, I know how to use Global Terminal Variables and I have converted a number of indicators to use buffers instead of objects.

Note that the above code gets the value of an object that is on the current chart. Not very useful for a multi-symbol scanner.

You still haven't answered my questions.

Ok, a simple exercise for you.

Create a simple indicator to get values using an object and a GV for a symbol that is different to the symbol that the indicator is attached to. Bear in mind that there may not be a chart open with the  relevant symbol and time-frame.

first we have to draw the object to multi symbol then we can convert into buffer, example

int total = SymbolTotal(true);
double price1,price2,PriceBuffer[];
for(int i=0;i<=total;i++){
string sym = SymbolName(i,true)
ArrayResize(PriceBuffer,total);
ArraySetAsSeries(PriceBuffer,true);
price1 = iClose(sym,PERIOD_M5,1);
ObjectCreate(0,"line1",OBJ_HLINE,0,0,price1))

if(ObjectFind(0,"line1")>0) price2=NormalizeDouble(ObjectGetDouble(0,"line1",OBJPROP_PRICE,1),Digits());
Pricebuffer[i] = price2;


}

for Global Terminal Variables, we can store symbol name, price using iClose and can run a scanner

Keith Watford
Moderator
35484
Arpit T #:

first we have to draw the object to multi symbol then we can convert into buffer, example

int total = SymbolTotal(true);
double price1,price2,PriceBuffer[];
for(int i=0;i<=total;i++){
string sym = SymbolName(i,true)
ArrayResize(PriceBuffer,total);
ArraySetAsSeries(PriceBuffer,true);
price1 = iClose(sym,PERIOD_M5,1);
ObjectCreate(0,"line1",OBJ_HLINE,0,0,price1))

if(ObjectFind(0,"line1")>0) price2=NormalizeDouble(ObjectGetDouble(0,"line1",OBJPROP_PRICE,1),Digits());
Pricebuffer[i] = price2;


}

for Global Terminal Variables, we can store symbol name, price using iClose and can run a scanner

I am not going to address the many errors in your code, you need to sort them yourself.

You are not actually using any object. For some reason you create an object in the current chart using iClose(), then you get the value from the object! (incidentally the code fails because an object can only be created once)

Why not just use iClose() ??

See the lines commented out and the replacement last line.

   int total = SymbolsTotal(true);
   double price1,price2,PriceBuffer[];
   for(int i=0; i<total; i++)
     {
      string sym = SymbolName(i,true);
      ArrayResize(PriceBuffer,total);
      ArraySetAsSeries(PriceBuffer,true);
      //price1 = iClose(sym,PERIOD_M5,1);
      //ObjectCreate(0,"line1",OBJ_HLINE,0,0,price1);

      //if(ObjectFind(0,"line1")>0)
      //   price2=NormalizeDouble(ObjectGetDouble(0,"line1",OBJPROP_PRICE,1),Digits());
      //PriceBuffer[i] = price2;
      PriceBuffer[i] = iClose(sym,PERIOD_M5,1);
     }