Passing String Variables Using Globals
Results 1 to 7 of 37

Thread: Passing String Variables Using Globals

  1. #1
    If you are able to pass string variables using global variables, can anyone tell me? I understand you are able to pass other variables, like integer, doubles and boolean, and not need to add anything additional, but whenever I try to pass a string all I get is a lot of 0's.

    Any thoughts?

    Thanks.

  2. #2
    It seems not....even should you try and create it manually from the platform it will not accept alpha characters.

    I figure the next best would be to either write to file, or whether it's a very brief series, you could convert and save each letter based on its ascii code.

  3. #3
    In fact, what I was attempting to do was produce a string of numbers (both integers and doubles) separated by spaces, then pass that on as a global, and convert it back into the respective numbers once it reaches it's destination.

    I'm thinking now perhaps, since there are just four or five numbers, I can setup a for statement and assign a factor to each value and pass them through a global. Or, if nothing else, create a separate global for every one separately, although I'm not sure I want to do this? I'm liable to have six or seven charts available, or more, with four or five globals assigned to each, and it might find a bit confusing.

    Or, perhaps I could produce a string beginning with the number 1, and add all the other factors, at least the first four, which should be just one digit, so it looks to be an actual whole number. I then pass it as a global and could convert that, and reverse the process on the other end. I believe I would try this first ...


    Hey, thanks.

  4. #4
    Hi there,

    I would just go the Global Variable(Gvar) route....you may have something like 10 000 Gvars, so if you're able to keep track of the different examples of this EA, then there should be no difficulty storing as many variables as you'd like.

    I typically use a routine that assigns a exceptional MagicNumber to every instance of an EA, dependent on currency pair, time frame, EA identifier and unique EA instance ID. You can use a similar arrangement so that every chart(EA instance) can keep an eye on its Gvars via its MagicNumber. SO by way of illuion :-

    EA 1 EURGBP MagicNumber = 15645 gt;gt;gt;Gvar name = string 15645_var1, 15645_var2,15645_var3,....
    EA 1 EURUSD MagicNumber = 10222 gt;gt;gt;Gvar name = string 10222 _var1, 10222 _var2,10222 _var3,...

  5. #5
    I really got it to function in the second case it works alright and I called above. But, it doesn't deal with. I had been trying to talk and forth between two separate accounts using this TradeSwitch DLL ... that, the way in which the code was written, was just setup to communie 1 way. So, I thought if I altered the EA's (provided) to search for globals about the particular account that's transmitting (and obtained on the other account), rather than sending information via a particular Symbol(), then I could eliminate any potential crosstalk, as both accounts are transmitting and receiving.

    Like I said, when conveying just 1 way, it works wonderful. But, as soon as I hook up the second account to receive, I'm dead in the water.

    Quote Originally Posted by ;
    EA 1 EURGBP MagicNumber = 15645 gt;gt;gt;Gvar title = string 15645_var1, 15645_var2,15645_var3,....
    EA 1 EURUSD MagicNumber = 10222 gt;gt;gt;Gvar title = string 10222 _var1, 10222 _var2,10222 _var3,....
    Yes, this really is what is neat about globals, as it allows to create variables on the fly, so to speak.

  6. #6
    Why not research using dll's and only letting it manage all of the cross-talk and variables etc rather than trying to shoehorn it into mt4?

  7. #7
    Sure, provided of course that you understand what you are doing. Additionally, since I am using more than one instance of this EA I am applying this to (currently eight, on each account) I figured it'd be easiest for each EA to make a international specific to the chart, and make a single EA that registers for globals and interfaces with the DLL, to transmit the information over to another account, and vice versa. I believe that is pretty straight forward enough.

    Though, actually if I could find a way to ship the info from each EA (each instance) straight to the DLL without using globals, then it might be easier. In reality I attempted something but couldn't get it to work. I probably should go back and check.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.