Accessing indicator Array from EA

Mohamed Mostafa Mohamed Sonbol  

Hello

i have an array inside the indicator , how can i use it in another EA?

i can think that it needs to be copied to buffer and access it using icustom ?

if thats the case how can i copy the array to the buffer ? i cant seem to find anything about it or maybe i am missing it .

or maybe there is another way?


thank you 

William Roeder  
Mohamed Mostafa Mohamed Sonbol:

i have an array inside the indicator , how can i use it in another EA?

i can think that it needs to be copied to buffer and access it using icustom ?

  1. You can't. ICustom can only read buffers.
  2. Why copy it to a buffer, just use a buffer.
Dominik Egert  
Mohamed Mostafa Mohamed Sonbol:

Hello

i have an array inside the indicator , how can i use it in another EA?

i can think that it needs to be copied to buffer and access it using icustom ?

if thats the case how can i copy the array to the buffer ? i cant seem to find anything about it or maybe i am missing it .

or maybe there is another way?


thank you 

Inside the indicator, where you have your array, change the array to be a buffer of the indicator, and use it instead.Now your data is available via iCistom. And you can access the data from outside.


Mohamed Mostafa Mohamed Sonbol  
William Roeder #:
  1. You can't. ICustom can only read buffers.
  2. Why copy it to a buffer, just use a buffer


yes i can do that, but what if the array contains strings, how can u transfer that ?

Dominik Egert  
Mohamed Mostafa Mohamed Sonbol #:


yes i can do that, but what if the array contains strings, how can u transfer that ?

Depends on what type of strings. If they are just a couple predefined types, like "sell", "long" whatever, you will have to represent them with a number. And in case you have combinations, then you need to use a bit field. To convert an ulong bit field to double, you should use a union to do that.

This way, you have a max combination of 64 on/off states you can represent simultaneously.

If you are trying to transfer "Prosa", you will have to use a file to do so.

But I would guess the buffer solution would cover your needs.
Mohamed Mostafa Mohamed Sonbol  
Dominik Egert #:
Depends on what type of strings. If they are just a couple predefined types, like "sell", "long" whatever, you will have to represent them with a number. And in case you have combinations, then you need to use a bit field. To convert an ulong bit field to double, you should use a union to do that.

This way, you have a max combination of 64 on/off states you can represent simultaneously.

If you are trying to transfer "Prosa", you will have to use a file to do so.

But I would guess the buffer solution would cover your needs.

Thank Dominik

True , the buffer solution will cover my needs

i was just trying to answer a question that jumped my mind about strings.

thanks 

Dominik Egert  
Mohamed Mostafa Mohamed Sonbol #:

Thank Dominik

True , the buffer solution will cover my needs

i was just trying to answer a question that jumped my mind about strings.

thanks 

Most of the time, people use strings wrongly.

For some reason, I don't know why, especially beginners, use strings to represent some state.

Strings are usually only required to interact with the user, store/load bulk data.

Strings have some disadvantages, like not being able to be optimized, not being predictable, slow in comparison operations and so on.

There is almost no justified use case for strings in algorithmic trading applications outside the above mentioned situations.
phade  
There's also something called "GlobalVariableGet" in the api which allows you to retrieve variables from one script to another running on the same terminal. But I haven't tried it 
Tobias Johannes Zimmer  
phade #:
There's also something called "GlobalVariableGet" in the api which allows you to retrieve variables from one script to another running on the same terminal. But I haven't tried it 
It works, but it will only store double values and be deleted if they are not refreshed within a month.

But with some imagination you can use them for every type. 

It doesn't do anything magic either, they are stored in a global variables file in the terminal folder
Reason: