Page 1 of 9

The Center of gravity MT4 Expert Advisor

PostPosted: Fri Oct 09, 2009 7:42 am
by hansjlachmann
EA can be downloaded here:
http://forex-strategies-revealed.com/files/MT4/CenterOfGravity_1.mq4

i will soon implement CoG 2 indicator into Script in order to run it in an Expert advisor

regards
Hans

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Fri Oct 09, 2009 7:57 am
by hansjlachmann
the same indicator in a script file. Just copy the fuction void CenterOfCGravity() into any expert advisor

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Fri Oct 09, 2009 9:40 am
by hansjlachmann
I have implemented the Center of Gravity 2 indicator into script
function GravityCenter2()

For testing the script generates Alert message with the 7 levels

kind regard Hans

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Fri Oct 09, 2009 10:00 am
by hansjlachmann
example Expert Advisor with the COG2 indicator. This one is not profitable, its just an example
Functions CheckIndicatorForOpen (entry strategy) and CheckIndicatorForClose (exit strategy) needs to be modified

kind regards
Hans

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Sat Oct 10, 2009 10:58 am
by edlogic
thanks a lot Hans
i am looking at it now
maybe some time we can talk on skype
i would like that
my name on skype is the same as here
give me a call any time

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Sun Oct 11, 2009 12:10 am
by edlogic
the very first thing i am going to do is change the buffer variable names to something more meaningful instead of g_ibuf_104 etc .

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Sun Oct 11, 2009 8:25 pm
by edlogic
ok i have a rough draft of the code that opens trades on the cog lines above and below the middle cog line
it works according to the original rules and right now it is for 5 digit systems - will need adjustments to work for the 4 digits
i have only done a little testing so far but it seems to be opening the trades at the right time

the next problems to tackle :

stop loss needs to be made relative to the outer most cog line rather than a fixed value from the open price
right now i have a fixed lot size set of 0.10 - it needs to have your code plugged back in for optimizing again
since the spread between the cog lines can be more than 20 pips then that means that the stoploss from the inner most cog line to 10 or 20 past the outtermost cog line can be as high as 80 pips or so - that means some form of risk limitation should be set up where a maximum spread for stoploss and the number of open orders etc needs to be made -

here is my first version
CenterOfGravity2test.mq4
rough first version for getting ideas flowing
(13.47 KiB) Downloaded 2134 times

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Mon Oct 12, 2009 4:40 pm
by edlogic
i thought of a different approach from the standard rules
that would be to not open orders at the time of first passing the cog line
but waiting until the price peaks out and starts reversing and then open the orders as the price passes back across the cog line in the opposite direction
i think that would reduce draw down and margin usage
i just wonder if the trend would often reverse as the price peaked - if that happened then you wouldn't have any orders placed as price moved back through the cog lines
hmmm - it is starting to seem like we might need a trend strength measurement

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Tue Oct 13, 2009 8:18 am
by hansjlachmann
i tried to implement this into my previous EA with the Cog 1, that you only enter a trade when the price reverses back through the cog line. It wasnt any success either.
I think we need to combine this strategy with some other indicator. Edlogic, I will try to call you on Skype soon...

regards Hans

Re: The Center of gravity MT4 Expert Advisor

PostPosted: Sat Oct 17, 2009 10:45 pm
by edlogic
here is the latest modification to the same rule scheme of opening orders as they first pass the COG lines .

from here i will try coding it to wait until after price goes beyond a COG line and then returns - and open the order as it comes back past the COG line in the direction of the order
i am also going to try setting the stop loss and take profit at offsets from the outer COG lines

CenterOfGravity2test11.mq4
cleaned up and consolidated code
(17.43 KiB) Downloaded 2589 times


these ea scripts work on the principle of the Gravity_Center2.mq4 indicator download that is found on this page

http://forex-strategies-revealed.com/sc ... y/cpage-12