You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thanks thrdel, I will look into your coding. You are really so kind. Thanks again
If you mean that it isn't the best way to close an order I agree but if the guy doesn't want to use OrderSelect (or doesn't know how) and doesn't leave any open orders in the market it works.
We try to help each other here and your answer did not helped a bit, you didn't show him how to use Order Select function and his EA isn't working any better now due to your comment.
Next time you want to help, do it the right way, put the right code in there so others may actually learn something .
Thanks everyone who post to my question. My intention is to enter trade when bar2 meet certain conditions. I am testing on GBPJPY and open one trade at a time as I am very new to MQL4. With only one trade i am able to use ticket in Orderclose(). I am still not familiar with OrderSelect. So the trade will close if bar3 meet certain condition. I would like to ask any question, is there a way to store the execution of the program inside a file for debugging purpose? As I found that when the program execute, I dont know which part of the execution went wrong.
You're welcome Chuale, I learned much from others on this forum too so no problem. You don't really need to save the execution of the program into a file, there are a few ways to watch your variables values and any errors that may come up. I use mostly Comment() function and Print () function. I can send examples to you if you need. As I mentioned before GBPJPY didn't give me positive results but USDJPY did. I only run a back test for a month (Jan21/2014 - Feb25/2015) and with my settings the return was a bit over 400 USD. I will test other pairs as soon as I have a bit of time and let you know. Also if you need help with how to use Print() or Comment() to see values on screen in real time, let me know. Previously attached picture was your EA performance graph over a month period. Doesn't look to bad so far.
Dear thedel,
Thank you
Yes, i am using Print(). I need to know how to use OrderSelect() if there are more open trades. For a single trade, if I use SELECT_BY_POS, what shall be the value for index (OrderSelect (int index, in select, int pool=MODE_TRADES)? Is it 1?
or what value?
Thanks everyone who post to my question. My intention is to enter trade when bar2 meet certain conditions. I am testing on GBPJPY and open one trade at a time as I am very new to MQL4. With only one trade i am able to use ticket in Orderclose(). I am still not familiar with OrderSelect. So the trade will close if bar3 meet certain condition. I would like to ask any question, is there a way to store the execution of the program inside a file for debugging purpose? As I found that when the program execute, I dont know which part of the execution went wrong.
Here is an example of how to use Order Select function :
In this example, the CountTrades function checks all open and pending orders, discards the ones that don't have a matching symbol and magic number and counts only the ones that we need.
In this example it will select from most recent one to the first one.
If you need more help with it let me know.
If you mean that it isn't the best way to close an order I agree but if the guy doesn't want to use OrderSelect (or doesn't know how) and doesn't leave any open orders in the market it works.
We try to help each other here and your answer did not helped a bit, you didn't show him how to use Order Select function and his EA isn't working any better now due to your comment.
Next time you want to help, do it the right way, put the right code in there so others may actually learn something .
if you try to help then explain it correctly
you said
First you count orders with OrdersTotal().
total=OrdersTotal();
bad example...... you gave
if the guy doesn't want use OrderSelect() then he has to stop programming EA's
big nonsens what you tell here, https://www.mql5.com/en/forum/149958/page2#915413
i commented your example code and told you what you had to do
there are plenty examples i have given how to do ...
google for it if you want find them
There are a couple of things you did wrong. I assume you want this EA to work on JPY pairs on M1 time frame. Do you want to place orders on new bar only and close orders on new bar only or do you want entry on new bar and exit if conditions are met? Here is what I think :
First you count orders with OrdersTotal().
Then calculate your variables
If there are orders in the market check if they have to be closed
If no orders in the market, check if entry conditions are met.
Let me know if you have any questions.
when compiled the following:it said Time function not define. Please advise.
ok i got it fixed as I typed wrongly the parenthesis for Time, it is suppose to be [] instead of (). Thanks