TMA_CG: EA to buy at support & sell at resistance

Post Reply
dudest
Trader
Posts: 1847
Joined: Tue May 08, 2012 2:37 pm

Re: TMA_CG: EA to buy at support & sell at resistance

Post by dudest »

Based on recent feedback, I am uploading "TMACG_Gold_M15_STACKING_C" to Post #1

a) Symbol and Magic Number checks added to every fuction
--> Symbol needs to be XAU* [ e.g, XAUUSD, XAUUSDm, etc; so long as XAU is in the name ]
--> You can now configure Magic Numbers for normal (default: 1000) and stack trades (default: 3000).
--> The functions will only operate on the configured magic numbers

Code: Select all

extern int MagicNumber_Normal = 1000;
extern int MagicNumber_Stack = 3000;
b) Avoid opening stack trade when too near to TP
--> False by default ( for people like me )
--> Default minimum distance to TP to allow for stack trade: 30pips ( only taken to account if AvoidStackingNearTP = true )

Code: Select all

extern bool AvoidStackingNearTP = false;
extern double MinimumStackTPPips = 30.0;
===

For those not needing above two features, you can continue using "TMACG_Gold_M15_STACKING_B" if you don't want to change the one running on Empty4 right now ( no change in core functionality ).

Cheers
MrLong

Re: TMA_CG: EA to buy at support & sell at resistance

Post by MrLong »

Hi dudest,

&& should be ||

Code should be : if ( (OrderMagicNumber() != 1000) || (OrderMagicNumber() != 3000) ) continue;

Andy
bazze

Re: TMA_CG: EA to buy at support & sell at resistance

Post by bazze »

dudest » Mon Jan 13, 2014 1:16 pm wrote:
bazze » Mon Jan 13, 2014 1:35 pm wrote:Three trades closed so far...-$99,+$124.16 and +$18.56.That gives a total of +$36.93 on my $5000 demoacc.Changed the risk from 3 to 2,rest default...Looking good so far :clap:
Edit: New trade open,at the moment up $16...
That's great bazze :)

So if I calculate correctly:

# Your lotsize = (0.02 * 5000 = $100) / (30pips SL) = $3.3 per pip ==> 0.33 lots

Trade 1: -$99 ==> 30 pips SL
Trade 2: +$124.16 ==> 37.62 pips TP
Trade 3: +$18.56 ==> 5.62 pips TP

My trades today so far:
Trade 1: -54.1 pips ( got slipped crazy :/ that's almost an extra trade worth of SL! )
Trade 2: +38.0 pips
Trade 3: +4.8 pips
Trade 4: BUY trade waiting for NY to open before deciding where to go :)

Cheers!
Yeah,it seems like this have a potensial :smile: At the moment the EA have four trades open,so far approx.+$150.So we'll see how the EA handles this :?:
dudest
Trader
Posts: 1847
Joined: Tue May 08, 2012 2:37 pm

Re: TMA_CG: EA to buy at support & sell at resistance

Post by dudest »

MrLong » Mon Jan 13, 2014 4:31 pm wrote:Hi dudest,

&& should be ||

Code should be : if ( (OrderMagicNumber() != 1000) || (OrderMagicNumber() != 3000) ) continue;

Andy
Hi Andy!

Thanks for pointing this out.

At first, I thought it should be || (OR), but then it occurred to me that with an OR, you only need one of the tests to evaluate to true for the whole function to be true.

So in our case: if ( (OrderMagicNumber() != 1000) || (OrderMagicNumber() != 3000) ) continue;
--> If the magic number is not 1000 (say it's 3000): the function will eval to true based on the first condition, and 'continue' will apply (without testing the 2nd condition), wrongly skipping a valid order.

So I put: if ( (OrderMagicNumber() != 1000) && (OrderMagicNumber() != 3000) ) continue;
--> So that BOTH conditions have to evaluate to true for the particular selected order to be skipped (continue).
--> So if a magic number is 3000: second condition fails, function evaluates to false -> order is (rightly) processed
--> If a magic number is 100: both conditions eval to true, and order is (rightly) skipped

I think the || would apply if I was testing the conditions in order to immediately execute the code for them (as opposed to testing the conditions to remove the unwanted orders).

==

Please correct me if I'm missing something.... :| I could be wrong.

Cheers
MrLong

Re: TMA_CG: EA to buy at support & sell at resistance

Post by MrLong »

Hi,

&& would be checking if the magicnumber is both these value.

|| would mean if the value is not either of these numbers.

So you would be saying if the magic numbers are not either 1000 or 3000 continue, they don't belong to my EA.

Edit:

Try:
if (OrderMagicNumber() != 1000) continue;
if (OrderMagicNumber() != 3000) continue;

Edit:
I've just run a test and I'm wrong, your code works.
Sorry :oops:



Andy
dudest
Trader
Posts: 1847
Joined: Tue May 08, 2012 2:37 pm

Re: TMA_CG: EA to buy at support & sell at resistance

Post by dudest »

dudest » Mon Jan 13, 2014 4:26 pm wrote:Based on recent feedback, I am uploading "TMACG_Gold_M15_STACKING_C" to Post #1

a) Symbol and Magic Number checks added to every fuction
--> Symbol needs to be XAU* [ e.g, XAUUSD, XAUUSDm, etc; so long as XAU is in the name ]
--> You can now configure Magic Numbers for normal (default: 1000) and stack trades (default: 3000).
--> The functions will only operate on the configured magic numbers

Code: Select all

extern int MagicNumber_Normal = 1000;
extern int MagicNumber_Stack = 3000;
b) Avoid opening stack trade when too near to TP
--> False by default ( for people like me )
--> Default minimum distance to TP to allow for stack trade: 30pips ( only taken to account if AvoidStackingNearTP = true )

Code: Select all

extern bool AvoidStackingNearTP = false;
extern double MinimumStackTPPips = 30.0;
===

For those not needing above two features, you can continue using "TMACG_Gold_M15_STACKING_B" if you don't want to change the one running on Empty4 right now ( no change in core functionality ).

Cheers
Ver "TMACG_Gold_M15_STACKING_C" uploaded

Also contains code to check (when placed on a chart) whether trades belonging to it are already running (to avoid placement of multiple trades of the same type (esp at the same area) )

Also contains LibCSS code as extracted from LibCSS.mqh by SpiderX (thanks Spidey!)

Cheers
Last edited by dudest on Tue Jan 14, 2014 9:16 am, edited 1 time in total.
dudest
Trader
Posts: 1847
Joined: Tue May 08, 2012 2:37 pm

Re: TMA_CG: EA to buy at support & sell at resistance

Post by dudest »

MrLong » Mon Jan 13, 2014 8:04 pm wrote:Hi,

&& would be checking if the magicnumber is both these value.

|| would mean if the value is not either of these numbers.

So you would be saying if the magic numbers are not either 1000 or 3000 continue, they don't belong to my EA.

Edit:

Try:
if (OrderMagicNumber() != 1000) continue;
if (OrderMagicNumber() != 3000) continue;

Edit:
I've just run a test and I'm wrong, your code works.
Sorry :oops:



Andy
No Andy, I'm grateful that you ran checks, and we are sure that the code works!

Thanks Andy :)

Cheers
User avatar
cad0811
Trader
Posts: 97
Joined: Sat Sep 08, 2012 1:09 pm

Re: TMA_CG: EA to buy at support & sell at resistance

Post by cad0811 »

dudest » Tue Jan 14, 2014 2:34 am wrote:
MrLong » Mon Jan 13, 2014 8:04 pm wrote:Hi,

&& would be checking if the magicnumber is both these value.

|| would mean if the value is not either of these numbers.

So you would be saying if the magic numbers are not either 1000 or 3000 continue, they don't belong to my EA.

Edit:

Try:
if (OrderMagicNumber() != 1000) continue;
if (OrderMagicNumber() != 3000) continue;

Edit:
I've just run a test and I'm wrong, your code works.
Sorry :oops:



Andy
No Andy, I'm grateful that you ran checks, and we are sure that the code works!

Thanks Andy :)

Cheers
Sorry to disturb you!I test the C version, if currencies have the suffix, still doesn't work, thank you!When no suffix is working.

Supplement: I use roboforex two accounts to test, a suffix, without a suffix.

Thank you again for your work!
Thank you so much for all the people here!Thank you for your selfless!My growth cannot leave your work!Cheers!
User avatar
varso
Trader
Posts: 44
Joined: Mon Oct 22, 2012 7:19 am

Re: TMA_CG: EA to buy at support & sell at resistance

Post by varso »

cad0811 » Tue Jan 14, 2014 6:07 am wrote:
dudest » Tue Jan 14, 2014 2:34 am wrote:
MrLong » Mon Jan 13, 2014 8:04 pm wrote:Hi,

&& would be checking if the magicnumber is both these value.

|| would mean if the value is not either of these numbers.

So you would be saying if the magic numbers are not either 1000 or 3000 continue, they don't belong to my EA.

Edit:

Try:
if (OrderMagicNumber() != 1000) continue;
if (OrderMagicNumber() != 3000) continue;

Edit:
I've just run a test and I'm wrong, your code works.
Sorry :oops:



Andy
No Andy, I'm grateful that you ran checks, and we are sure that the code works!

Thanks Andy :)

Cheers
Sorry to disturb you!I test the C version, if currencies have the suffix, still doesn't work, thank you!When no suffix is working.

Supplement: I use roboforex two accounts to test, a suffix, without a suffix.

Thank you again for your work!
I confirm this problem. I have also roboforex and the name for gold is XAUUSD.m with "m" like suffix.
And many others brokers have suffix.
Please if you can repair this problem it will be very grateful.
Thank you
dudest
Trader
Posts: 1847
Joined: Tue May 08, 2012 2:37 pm

Re: TMA_CG: EA to buy at support & sell at resistance

Post by dudest »

cad0811 » Tue Jan 14, 2014 8:07 am wrote:
Sorry to disturb you!I test the C version, if currencies have the suffix, still doesn't work, thank you!When no suffix is working.

Supplement: I use roboforex two accounts to test, a suffix, without a suffix.

Thank you again for your work!
varso » Tue Jan 14, 2014 9:42 am wrote:
I confirm this problem. I have also roboforex and the name for gold is XAUUSD.m with "m" like suffix.
And many others brokers have suffix.
Please if you can repair this problem it will be very grateful.
Thank you
Hi guys,

Thanks for your feedback!

Could either of you please post up a VERY CLEAR chart of your XAUUSD.m also showing the F9 (quotes) window?

( i.e, open up XAUUSD.m, remove indis & whatnot, change the scheme to something clear (e.g black over white), press F9, then take screenshot and upload )

I haven't hard-coded names anywhere, so I'm wondering whether your Digits are off? (affects the Pip Factor)

Also check your Journal and Experts tabs for ANY errors and paste those too if you find them

Cheers
Post Reply

Return to “Automated trading systems”