It's not clear what you are trying to do.
What data type does orderOpen() return?
What is the data type of orderTicket1, which is declared in the global scope?
Why are you trying to create a local structure with an identifier that is already used for a global object? Do you need a new instance of the structure, or do you want to change the one that is declared at the global level?
Thank you for your reply.
orderOpen() returns an integer which is the order ticket.
Basically, I want this:
Array/Struct called Locks with two columns:
ticket locked 254587896 1 587856963 1 458789563 0
Then look it up:
if (Locks.587856963 == 1) {Print("It's locked.");
You can't assign int to a struct:
orderTicket1 = orderOpen("buy");
Here is a simple script to check this:
struct LockStruct { int ticket; int locked; }; void OnStart() { // Here I declared a structure and assigned some values to it. Because in your code the structure // already existed in the global scope and contained some values. LockStruct orderTicket1 = {2, 1}; //--- orderTicket1 = get123(); // Error: 'get123' - parameter passed as reference, variable expected } int get123() { return(123); }
You can't assign int to a struct:
You can assign this to a struct member, but not to the struct:
struct LockStruct { int ticket; int locked; }; void OnStart() { LockStruct orderTicket1 = {2, 1}; orderTicket1.ticket = get123(); // OK } int get123() { return(123); }
This is also completely wrong:
LockStruct orderTicket1 = {orderTicket1,1};
Check out the documentation on structures:
https://www.mql5.com/en/docs/basis/types/classes
Despite the fact that this is MQL5 documentation, all the information in the link above applies to MQL4 too
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
If I am interpreting this correctly, I cannot name a struct instance after the value of a variable (orderTicket1 which is declared in the global scope). Only "hard" names are allowed.
So I can't do this:
Because I can only use "hard" names.
LockStruct SomeTicket = { ticket = orderTicket1; locked = 1 };
But then I can't perform lookups:
Then how is a struct any better than:
SomeTicket_ticket = orderTicket1; SomeTicket_locked = 1;
which won't let me perform lookups either?
Is there anything in MQL4 that remotely resembles an associative array?