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
...
Yes, you understood correctly
As of setting to fasle : mql is a C/C++ like language, whic means that false == 0 and true == 1. So you can use that way. You can not declare the type of the global variable since they are exclusively double, but using the upper ways you can use them as if they were boolean
Ahh.. I see. Because Global Variables save their values in memory. So as you say when it finishes backtesting and its at 5000 say, this is saved to memory even if the backtesting is re-run so it will never return false because BarsGV isnt below 5000? Jeez this is deep.
And also, if it generates an error, it sets HasOrderedGV to false so it can continue with the rest of the code?
Have I understood you correctly?
BTW- is this allowed?
GlobalVariableSet(HasOrderedGV, false);
Because in MQL4 Book it says:
Its working again. Awesome.
Thanks.
Or it was...
I put in my usual test dates which is 04.01.2011- 20.07.2012. It worked well yesterday evening when I inserted the BarsGV in init(), but when I tested it this morning without making any changes it placed just one order on 17.01.2011. Then I backtested it again 5 minnutes later, without making any changes and it returned about 30 orders from 19.01.2011- 21.04.2011!
Basically it works as it should but clonks out short of my specified finishing date. No errors are in the journal, does my print() as it should etc. My entry criteria should develop trades right up to the 20.07.2012.
It seems really tempermental and I can only assume its to do with my GlobalVariable. What do you think?
This is my Journal:
2012.07.23 09:08:16 2011.03.21 16:18 Tester: take profit #2 at 1.42100 (1.42100 / 1.42125)
2012.07.23 09:08:15 2011.03.04 14:39 Tester: take profit #1 at 1.40040 (1.40043 / 1.40068)
2012.07.23 09:08:14 2011.02.04 13:39 Tester: stop loss #3 at 1.35700 (1.35699 / 1.35724)
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Ticket Number 3 Symbol EURUSD Price 1.3718 SL 1.357 TP 0
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: EA attempting to place take profit level...successful
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: modify #3 buy 0.01 EURUSD at 1.37175 sl: 1.35700 tp: 1.41600 ok
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Take profit position calculated successfully
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Order Placed successfully
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: EA attempting to place buy order...
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: open #3 buy 0.01 EURUSD at 1.37175 sl: 1.35700 ok
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Position size calculated successfully using derived risk percentage
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Risk percentage ready for use in lots calculation
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Previous order in profit. Risk of 3% allocated
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Ticket number 2 obtained for last opened order
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Ticket number 2 obtained for last opened order
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Checking buying criteria... successful. Order ready to be placed
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Ticket Number 2 Symbol EURUSD Price 1.36 SL 1.3396 TP 0
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: EA attempting to place take profit level...successful
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: modify #2 buy 0.01 EURUSD at 1.35995 sl: 1.33960 tp: 1.42100 ok
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Take profit position calculated successfully
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Order Placed successfully
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: EA attempting to place buy order...
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: open #2 buy 0.01 EURUSD at 1.35995 sl: 1.33960 ok
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Position size calculated successfully using derived risk percentage
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Risk percentage ready for use in lots calculation
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Previous order in profit. Risk of 3% allocated
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Ticket number 1 obtained for last opened order
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Ticket number 1 obtained for last opened order
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Checking buying criteria... successful. Order ready to be placed
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Ticket Number 1 Symbol EURUSD Price 1.3442 SL 1.3254 TP 0
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: EA attempting to place take profit level...successful
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: modify #1 buy 0.01 EURUSD at 1.34415 sl: 1.32540 tp: 1.40040 ok
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Take profit position calculated successfully
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Order Placed successfully
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: EA attempting to place buy order...
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: open #1 buy 0.01 EURUSD at 1.34415 sl: 1.32540 ok
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Position size calculated successfully using derived risk percentage
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Risk percentage ready for use in lots calculation
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: No previous orders identified. Risk of 1% allocated
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Ticket number -1 obtained for last opened order
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Checking buying criteria... successful. Order ready to be placed
2012.07.23 09:08:12 H4 Period EA inputs: MagicNumber=42; RiskRewardRatio=3; D1SlowMAPeriod=200; D1FastMAPeriod=50; FastMACDPeriod=12; SlowMACDPeriod=26; SignalPeriod=9; DNCPeriod=120; SL_Period=10;
It runs like clockwork but for some reason decides to stop placing orders after a certain period of time...
...
Sorry,
But that data is not enough to tell what is happening to your EA. As I said a couple of times, without the code all I can do is guess , and from the data attached I can not even guess
This is my Journal:
2012.07.23 09:08:16 2011.03.21 16:18 Tester: take profit #2 at 1.42100 (1.42100 / 1.42125)
2012.07.23 09:08:15 2011.03.04 14:39 Tester: take profit #1 at 1.40040 (1.40043 / 1.40068)
2012.07.23 09:08:14 2011.02.04 13:39 Tester: stop loss #3 at 1.35700 (1.35699 / 1.35724)
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Ticket Number 3 Symbol EURUSD Price 1.3718 SL 1.357 TP 0
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: EA attempting to place take profit level...successful
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: modify #3 buy 0.01 EURUSD at 1.37175 sl: 1.35700 tp: 1.41600 ok
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Take profit position calculated successfully
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Order Placed successfully
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: EA attempting to place buy order...
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: open #3 buy 0.01 EURUSD at 1.37175 sl: 1.35700 ok
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Position size calculated successfully using derived risk percentage
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Risk percentage ready for use in lots calculation
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Previous order in profit. Risk of 3% allocated
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Ticket number 2 obtained for last opened order
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Ticket number 2 obtained for last opened order
2012.07.23 09:08:14 2011.02.01 04:00 H4 Period EA EURUSD,H4: Checking buying criteria... successful. Order ready to be placed
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Ticket Number 2 Symbol EURUSD Price 1.36 SL 1.3396 TP 0
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: EA attempting to place take profit level...successful
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: modify #2 buy 0.01 EURUSD at 1.35995 sl: 1.33960 tp: 1.42100 ok
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Take profit position calculated successfully
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Order Placed successfully
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: EA attempting to place buy order...
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: open #2 buy 0.01 EURUSD at 1.35995 sl: 1.33960 ok
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Position size calculated successfully using derived risk percentage
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Risk percentage ready for use in lots calculation
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Previous order in profit. Risk of 3% allocated
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Ticket number 1 obtained for last opened order
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Ticket number 1 obtained for last opened order
2012.07.23 09:08:13 2011.01.21 20:00 H4 Period EA EURUSD,H4: Checking buying criteria... successful. Order ready to be placed
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Ticket Number 1 Symbol EURUSD Price 1.3442 SL 1.3254 TP 0
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: EA attempting to place take profit level...successful
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: modify #1 buy 0.01 EURUSD at 1.34415 sl: 1.32540 tp: 1.40040 ok
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Take profit position calculated successfully
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Order Placed successfully
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: EA attempting to place buy order...
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: open #1 buy 0.01 EURUSD at 1.34415 sl: 1.32540 ok
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Position size calculated successfully using derived risk percentage
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Risk percentage ready for use in lots calculation
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: No previous orders identified. Risk of 1% allocated
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Ticket number -1 obtained for last opened order
2012.07.23 09:08:13 2011.01.19 04:00 H4 Period EA EURUSD,H4: Checking buying criteria... successful. Order ready to be placed
2012.07.23 09:08:12 H4 Period EA inputs: MagicNumber=42; RiskRewardRatio=3; D1SlowMAPeriod=200; D1FastMAPeriod=50; FastMACDPeriod=12; SlowMACDPeriod=26; SignalPeriod=9; DNCPeriod=120; SL_Period=10;
It runs like clockwork but for some reason decides to stop placing orders after a certain period of time...Hello mladen, ive attached the file. Hopefully I have written it OK so it makes sense!
...
From what I can see from the code : counted bars (the IndicatorCounted() function) does not work in EAs.(I am jusassuming that you are using that since the code is lacking the CountedBars definition)
It can work only in indicators
Hello mladen, ive attached the file. Hopefully I have written it OK so it makes sense!
Sorry mladen, I didnt know what you meant by the CountedBars function as I havent used that in my code, so I downloaded the file I had posted and opened it and ts completely different to the one I actually attached. Weird?
I definitely attached the right one, is it because I have a padlock sign next to the file on my computer - thats all I can think of?
You must have been thinking what the hell when you opened that code because theres hardly anything in it.
...
I was referring to this part of the code
CountedBars = Bars
else
return (-888);And I do not see at all where CountedBars is declared (I even fail to compile that code - not just because of the lack of declaration for that variable)
Sorry mladen, I didnt know what you meant by the CountedBars function as I havent used that in my code, so I downloaded the file I had posted and opened it and ts completely different to the one I actually attached. Weird?
I definitely attached the right one, is it because I have a padlock sign next to the file on my computer - thats all I can think of?
You must have been thinking what the hell when you opened that code because theres hardly anything in it.Sorry mladen, the code you have viewed via the file I attached is completely wrong- it bears no resemblance to my current code despite attaching the correct file (I double checked the file name).
All I can think of is that the file I am working on has a padlock next to it on my system. Dont know what that is or does. Any ideas/?
PS- its my own EA because I used the create EA wizard and it has my name at the top next to copyright,