Okay, let's analyze the solution for you!
The first: We must know the root of the problem.
- How can we know the price (OLHC) of the symbol, and how many orders or how much their floating F/L are we having?
- The answer is: Database. Yes, what we are seeing in MT4/MT5 is the real-time database of the Broker. And, the Broker retrieves the database from the higher level: Market.
- So, we know the root of the problem now, right? It's database.
Next: Build the the way to implement what you want to do as a diagram.
- The simplest database machine is variable or text file (or something like it). If you are planning to use an ORM, that's great. Now I'm talking about the variable or text file.
- Case 1: If you use your EA to trade one pair only, just simply use a global variable & implement a function to increase or decrease its value.
- Case 2: If you use your EA to trade more than one pair in one chart window only, just simple use an two-dimension array global variable & implement a function with argument(s) to increase / decrease each variable's value.
- Case 3: If you use your EA to trade more than one pair, but in multi chart window (trade EU in EU window, GU in GU window, ...), now the problem is more complex; it must be a cross-border variable, right? The solution for this case is: store order number of each symbol in a separate text file, and you have to implement two necessary functions, the first is for increase/decrease order number of each symbol purpose, one is for count all text file to know the total order number purpose. Why do we have to use multiple text file? Because, using the text file to store value as a database machine is different from one ORM (such as MySQL, SQLSERVER, ...), we can't modify one text file by multiple programs @ the same time but have no problem.
The last: Sample code as flowchart (I have never done with text file on MQL, so use the global variable only):
Case 1:
Have one global variable named EURUSD_OrderSum = 0;
Have one function increaseDecrease(int number) {
return EURUSD_OrderSum + n;
}
Have one open virtual trade function: openVirtualTrade(){
if(okay to sell or buy){
increaseDecrease(1);
}
}
Have one close virtual trade function: closeVirtualTrade(){
if(okay to close){
increaseDecrease(-1);
}
}
Case 2: Nearly same as case 1, have a bit difference.
You'll need to have one two-dimension array global variable: int orderSum[2][1] = {{0}, {0}}; // The first index is various, it depends on how many pairs the EA trades.
And the increase/decrease function must have one more argument increaseDecrease(int resource, int number). The resource is the index of the array when the program calls.
Case 3: I have never done with text file on MQL before, so you have to learn yourself :D
Hello, you can count how many times magic number was appears or write other EA to counting, maybe work in this case. Regards Greg
can you provide some example?
the main idea is like
Virtual- (how do i count the virtual trade? i dont want to execute them..i just want the count number )
buy-1
buy-2
buy-3
buy-4
real trade
buy-5
Okay, let's analyze the solution for you!
The first: We must know the root of the problem.
- How can we know the price (OLHC) of the symbol, and how many orders or how much their floating F/L are we having?
- The answer is: Database. Yes, what we are seeing in MT4/MT5 is the real-time database of the Broker. And, the Broker retrieves the database from the higher level: Market.
- So, we know the root of the problem now, right? It's database.
Next: Build the the way to implement what you want to do as a diagram.
- The simplest database machine is variable or text file (or something like it). If you are planning to use an ORM, that's great. Now I'm talking about the variable or text file.
- Case 1: If you use your EA to trade one pair only, just simply use a global variable & implement a function to increase or decrease its value.
- Case 2: If you use your EA to trade more than one pair in one chart window only, just simple use an two-dimension array global variable & implement a function with argument(s) to increase / decrease each variable's value.
- Case 3: If you use your EA to trade more than one pair, but in multi chart window (trade EU in EU window, GU in GU window, ...), now the problem is more complex; it must be a cross-border variable, right? The solution for this case is: store order number of each symbol in a separate text file, and you have to implement two necessary functions, the first is for increase/decrease order number of each symbol purpose, one is for count all text file to know the total order number purpose. Why do we have to use multiple text file? Because, using the text file to store value as a database machine is different from one ORM (such as MySQL, SQLSERVER, ...), we can't modify one text file by multiple programs @ the same time but have no problem.
The last: Sample code as flowchart (I have never done with text file on MQL, so use the global variable only):
Case 1:
Have one global variable named EURUSD_OrderSum = 0;
Have one function increaseDecrease(int number) {
return EURUSD_OrderSum + n;
}
Have one open virtual trade function: openVirtualTrade(){
if(okay to sell or buy){
increaseDecrease(1);
}
}
Have one close virtual trade function: closeVirtualTrade(){
if(okay to close){
increaseDecrease(-1);
}
}
Case 2: Nearly same as case 1, have a bit difference.
You'll need to have one two-dimension array global variable: int orderSum[2][1] = {{0}, {0}}; // The first index is various, it depends on how many pairs the EA trades.
And the increase/decrease function must have one more argument increaseDecrease(int resource, int number). The resource is the index of the array when the program calls.
Case 3: I have never done with text file on MQL before, so you have to learn yourself :D
err man..thanks for the tips but this step is beyond upper my imagination lol.
can you provide some example?
the main idea is like
Virtual- (how do i count the virtual trade? i dont want to execute them..i just want the count number )
buy-1
buy-2
buy-3
buy-4
real trade
buy-5
Hi, I assume you will use pending order, so you can create EA which save this information into the file or journal. Regards Greg

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to store and count the virtual trade but i have no idea to start since the above code need to make the trade. base on code above how do i twist to make it store a count variable without make it open trade?