Download MetaTrader 5
To add comments, please log in or register
Do you want to know about the MQL5.community development? Have a look at the Wall!
Brian Kester
794
Brian Kester 2014.06.16 17:01 

Hi

I can assign the ticket numbers to the variables and continually check them against the OrderProfit of all the other open orders, but my problem is this.......What if a 2nd hedge group opens while hedge1 is still open? my variables hedge1ticket1 and hedge1ticket2 are already assigned; or worse, what if 20 hedge orders become open...... how do i assign Hedge1(tickets 1 and 2), hedge2(tickets 1 and 2),  hedge3(tickets 1 and 2), hedge4(tickets 1 and 2),  etc to them?

 

If i do it the way i am currently trying, i will be typing "if" and "then" for weeks...  

 

Should i use an array or string and for loop to assign a number to the first hedge group (ticket 1 and 2 in the first "hedge"),  and then assign #2 the next two hedge tickets(hedge2 ticket1 and ticke2) etc?

Any suggestion will be helpful. Im a new programmer and i tried several days to conceptualize this and cant yet figure it out. I have never used Arrays yet and have not tried yet using strings to assign number like  Hedge("") could be Hedge1 ?    ......see its going to be a lot of work for me in this project learning.

  

 Thank you, ps one day ill come back and answer questions like these for noobs like me.

whroeder1
13623
whroeder1 2014.06.16 17:25  
c3po: how do i assign Hedge1(tickets 1 and 2), hedge2(tickets 1 and 2),  hedge3(tickets 1 and 2), hedge4(tickets 1 and 2),  etc to them?
struct Hedge{ int ticket1; int ticket2; };
int nHedge = 0;
Hedge Hedges[20];
:
Hedge newHedge; newHedge.ticket1=...; newHedge.ticket2=...;
Hedge[nHedge]=newHedge; ++nHedge;
qjol
3243
qjol 2014.06.16 17:29  

the first thing came in my mind, is: don't use variables for that, especially if you wanna use multiple sets,

the smallest problem you have and you forced to restart the terminal/computer and you end up with losing those information

use Global Variables / write to a file instead

Brian Kester
794
Brian Kester 2014.06.16 17:32  
WHRoeder:
 
 

wow thanks WHRoder, you make it look so easy. My code would have been 1000 lines and yours is only 6... wow

Brian Kester
794
Brian Kester 2014.06.16 19:13  
qjol:

the first thing came in my mind, is: don't use variables for that, especially if you wanna use multiple sets,

the smallest problem you have and you forced to restart the terminal/computer and you end up with losing those information

use Global Variables / write to a file instead

Thanks for the tip qjol.
Brian Kester
794
Brian Kester 2014.06.18 01:18  

I've been at it all day, and I understand the structure so far, but would you mind explaining why the colon, what i read applied to a class, and i couldn't relate it to it, "Specifiers of access to elements always end with a colon (:) ..."


struct Hedge{ int ticket1; int ticket2; };
int nHedge = 0;
Hedge Hedges[20];
:
Hedge newHedge; 
newHedge.ticket1=...; 
newHedge.ticket2=...;
Hedge[nHedge]=newHedge; 
++nHedge;
whroeder1
13623
whroeder1 2014.06.18 11:10  
c3po: would you mind explaining why the colon, ..."
  1.  ...
  2. :
    :
    :
/
To add comments, please log in or register