Open trade on new candle
27 replies
slowbutsure
9 years ago #112139
HI
I just want a rule that says as soon as a new candle opens, then enter a trade. Can anyone tell me how?\
Thanks
slowbutsure
9 years ago #124663
On the Open P/L I can see it has a magic number, so its only going to look at the trade with that magic number. The only thing I can think of is that the value in pips of both trades should be assigned a variable each, and then the two variables added together. I just can’t see how to do it?
slowbutsure
9 years ago #124664
I think I solved that. But its still not opening trades on the 2nd currency pair. Can you take a look at the strategy file attached and see if I have done anything wrong?
Thanks
slowbutsure
9 years ago #124665
hmm fixed it.
slowbutsure
9 years ago #124668
One last problem with this strategy…
I am adding the open p/l together for both currencies and the rule is, if the total profit is >= 5 pips then close both trades.
However, its closing at 5 pips regardless of whether its 5 pips profit or 5 pips loss, or 3 pips profit and 2 pips loss etc.
How do I ensure it only closes when the open p/l is positive 5 pips?
slowbutsure
9 years ago #124734
I am adding the open p/l together for both currencies and the rule is, if the total profit is >= 5 pips then close both trades.
However, its closing at 5 pips regardless of whether its 5 pips profit or 5 pips loss, or 3 pips profit and 2 pips loss etc.
How do I ensure it only closes when the open p/l is positive 5 pips?
Mark Fric
9 years ago #124737
can you attach your strategy here? it should recognize between positive and negative PL.
Mark
StrategyQuant architect
slowbutsure
9 years ago #124740
Here it is.
Mark Fric
9 years ago #124765
and it will return open profit for all trades on the same symbol.
The solution is to use custom function, but don’t worry, it is not complicated.
Open file EA Wizard/code/CustomFunctions.mq4 and add the following function there:
Mark
StrategyQuant architect
slowbutsure
9 years ago #124778
Thanks Mark, thats very helpful.
Eddiebund
9 years ago #125372
Mark
This is a very interesting strategy which I was looking test. Unfortunately, when i add the code above to CustomFunctions it doesn’t compile and shows the errors
Actually when I removed the additional code the last 2 errors still exist
Can you advise please
Thanks
Eddie
Mark Fric
9 years ago #125394
Hello Eddie,
are you trying to compile the COmpiledFunctions.mq4 file by itself?
It isn’t supposed to work like this. The contents of this file is attached to every EA created in EA Wizard, so don’t compile this custom file, but normal EA that you export from EA Wizard.
It should have these functions already included.
Mark
StrategyQuant architect
Eddiebund
9 years ago #125409
Thanks for that Mark
It is now working and gives me the basis of something to try and develop
Cheers