• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 9:04am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 9:04am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Generic Breakout Version 7 [TD] 70 replies

Generic Finite Impulse Response Filter - Ever wanted to design your own MA? 16 replies

Ronald Raygun's Generic MA crossover 4 replies

Generic Breakout Version 6 [TD] 18 replies

MT4 a generic platform? 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 9
Attachments: Generic MA Crossover Version 2 [TD]
Exit Attachments

Generic MA Crossover Version 2 [TD]

  • Last Post
  •  
  • Page 1 234 5
  • Page 1 234 5
  •  
  • Post #1
  • Quote
  • First Post: Edited at 4:29pm Dec 15, 2009 4:17pm | Edited at 4:29pm
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
The most classic of any trading system, is the humble MA crossover. It is tick-database enabled.

 

  1. extern string Remark1 = "== Main Settings ==";
  2. extern int MagicNumber = 0;

    1. This number should be unique when multiple EAs are attached to a terminal.

  3. extern bool SignalsOnly = False;

    1. If set to true, the EA will only alert you to a trade using any combination of the alerts below.

  4. extern bool Alerts = False;

    1. If set to true, the EA will send a pop-up alert when a trading signal arrives.

  5. extern bool SignalMail = False;

    1. If set to true, the EA will send you an e-mail (assuming you set up your mail in your MT4 Terminal.) when a trading signal arrives.

  6. extern bool PlaySounds = False;

    1. If set to true, the EA will play the file, "alerts.wav" when a trading signal arrives.

  7. extern bool ECNBroker = False;

    1. Some brokers require EAs to first place a trade, and then modify the trade with the stoploss and takeprofit. If your broker requires this, set this value to True.

  8. extern bool TickDatabase = True;

    1. If set to True, the EA will send tick data into the tick database.

  9. extern bool CloseOnOppositeSignal = True;

    1. If set to true, the EA will close a trade if an opposite trading signal appears.

  10. extern bool EachTickMode = True;

    1. If set to true, the EA will take a trade immediately if it sees a signal. If set to false, the EA will take a trade only if there is a signal at the end of the bar.

  11. extern double Lots = 0;

    1. Fixed lot size

  12. extern bool MoneyManagement = False;

    1. Enables/Disables the lot sizing function.

  13. extern int Risk = 0;

    1. The percent of your available margin that you are willing to put into a trade.

  14. extern int Slippage = 5;

    1. Maximum slippage allowed when placing an order.

  15. extern bool UseStopLoss = True;

    1. Enables/Disables the stoploss

  16. extern int StopLoss = 100;

    1. Hard Stoploss in pips.

  17. extern bool UseTakeProfit = False;

    1. Enables/Disables the takeprofit

  18. extern int TakeProfit = 60;

    1. Hard take profit in pips.

  19. extern bool UseTrailingStop = False;

    1. Enables/Disables the trailingstop

  20. extern int TrailingStop = 30;

    1. Trailing stop in pips. Note, the EA will only trail profits.

  21. extern bool MoveStopOnce = False;

    1. Enables/disables the move-to-breakeven function.

  22. extern int MoveStopWhenPrice = 50;

    1. Trigger price to move the stoploss.

  23. extern int MoveStopTo = 1;

    1. Price in pips relative to breakeven to move the stoploss to once the trigger price is hit.
    2. Using these values as an example, the EA will move the stoploss to breakeven + 1 if the trade hits 50 pips profit.

  24. extern string Remark2 = "";
  25. extern string Remark3 = "== MA1 Settings ==";
  26. extern int MA1Period = 0;

    1. Period of the Fast MA

  27. extern int MA1Shift = 0;

    1. Shift of the Fast MA

  28. extern int MA1Method = 0

    1. Method of the Fast MA;
    2. 0 = SMA
    3. 1 = EMA
    4. 2 = SMMA
    5. 3 = LWMA

  29. extern int MA1Price = 0;

    1. Price of the Fast MA
    2. 0 = Close
    3. 1 = Open
    4. 2 = High
    5. 3 = Low
    6. 4 = Median
    7. 5 = Typical
    8. 6 = Weighted

  30. extern int MA1CrossBuffer = 0;

    1. The number of pips above or below MA2 in order to trigger a trade. This is designed to prevent some whiplash and false entries.

  31. extern string Remark4 = "";
  32. extern string Remark5 = "== MA2 Settings ==";
  33. extern int MA2Period = 0;

    1. Period of the Slow MA

  34. extern int MA2Shift = 0;

    1. Shift of the Slow MA

  35. extern int MA2Method = 0;

    1. Method of the Slow MA;
    2. 0 = SMA
    3. 1 = EMA
    4. 2 = SMMA
    5. 3 = LWMA

  36. extern int MA2Price = 0;

    1. Price of the Slow MA
    2. 0 = Close
    3. 1 = Open
    4. 2 = High
    5. 3 = Low
    6. 4 = Median
    7. 5 = Typical
    8. 6 = Weighted

Note: You can enable all of the stoploss options if you so choose, just keep in mind that the EA will use the tightest stoploss available to it.

Attached File
File Type: mq4 Generic MA Crossover Version 2 [TD].mq4   21 KB | 2 downloads
  • Post #2
  • Quote
  • Jan 4, 2010 4:47am Jan 4, 2010 4:47am
  •  camvcvoo
  • | Joined Nov 2006 | Status: Member | 678 Posts
Attached the EA since market open this morning at Malaysian time (GMT+8), although have MA crosses but no trade opened. Refer picture. Thanks.
Attached Image (click to enlarge)
Click to Enlarge

Name: EURJPY H1.JPG
Size: 139 KB
福 子 Victor V
 
 
  • Post #3
  • Quote
  • Jan 5, 2010 2:29pm Jan 5, 2010 2:29pm
  •  dmitry_dos
  • | Joined Sep 2008 | Status: Member | 101 Posts
Quoting camvcvoo
Disliked
Attached the EA since market open this morning at Malaysian time (GMT+8), although have MA crosses but no trade opened. Refer picture. Thanks.
Ignored
Are you sure all your settings are right? The EA works fine on my platform.
 
 
  • Post #4
  • Quote
  • Jan 6, 2010 1:44am Jan 6, 2010 1:44am
  •  camvcvoo
  • | Joined Nov 2006 | Status: Member | 678 Posts
Quoting dmitry_dos
Disliked
Are you sure all your settings are right? The EA works fine on my platform.
Ignored
Can you please post your settings that's working for me to cross check? I followed what Ronald described in the first post. Or maybe you can PM me your settings.

I'm with MIG. You?

Thanks.

福 子 Victor V
 
 
  • Post #5
  • Quote
  • Jan 6, 2010 7:24am Jan 6, 2010 7:24am
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
Any errors in the journal or experts tab?

It's usually:

 

  1. Lot size is 0
  2. SL or TP is too tight

 
 
  • Post #6
  • Quote
  • Jan 6, 2010 6:31pm Jan 6, 2010 6:31pm
  •  dmitry_dos
  • | Joined Sep 2008 | Status: Member | 101 Posts
Quoting camvcvoo
Disliked
Can you please post your settings that's working for me to cross check? I followed what Ronald described in the first post. Or maybe you can PM me your settings.

I'm with MIG. You?

Thanks.

Ignored
I'm with FXDD but I'm using the EA to test strategies. Make sure the lot size is not 0, like Ronald said, also make sure it has a unique magic number.
 
 
  • Post #7
  • Quote
  • Jan 14, 2010 10:28am Jan 14, 2010 10:28am
  •  Tataocb
  • | Joined Nov 2008 | Status: Member | 214 Posts
Hi, it seems to work well. I have one question though, I've only started looking into EAs for 3 days, so at the risk of sounding stupid, is there any way to use price instead a Fast MA. So as when price crosses the slow MA the trade either opens or closes, instead of waiting for an MA to cross?
On a journey to consistency.
 
 
  • Post #8
  • Quote
  • Jan 14, 2010 11:13am Jan 14, 2010 11:13am
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
MA of 1 uses the average of the close price...
 
 
  • Post #9
  • Quote
  • Jan 14, 2010 11:30am Jan 14, 2010 11:30am
  •  Tataocb
  • | Joined Nov 2008 | Status: Member | 214 Posts
Thank you, I've tried that. However, it has to wait for the close to either enter or exit a trade. I tried creating an EA with an EA Builder I found based on a system I used exactly one year ago when I first went live. Which had to do with price crossing certain SWMA, but can't get it to buy/sell when it crosses the SWMA.

Like I said, I'm new to all of this. Could it be that the strategy tester sometimes misses on triggers you set on your EA or am I setting the conditions for a trade to open/close incorrectly?
On a journey to consistency.
 
 
  • Post #10
  • Quote
  • Jan 14, 2010 11:31am Jan 14, 2010 11:31am
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
Set eachtickmode to true (I think you set it to false?)
 
 
  • Post #11
  • Quote
  • Jan 14, 2010 12:14pm Jan 14, 2010 12:14pm
  •  Tataocb
  • | Joined Nov 2008 | Status: Member | 214 Posts
Yours works great, it opens and closes whenever there is a croos; I meant the one I tried, is where it sometimes wont seem to work.

In order to adapt yours to the strategy I want, is there a way to add another MA for closing trades. You see, my strategy opens a trade when price crosses certain MA and closes when it crosses a different MA, so as to use as a TP or a SL (depending if the trade was a win or a loss)?
On a journey to consistency.
 
 
  • Post #12
  • Quote
  • Jan 14, 2010 12:50pm Jan 14, 2010 12:50pm
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
Yeah, you'd need a different EA.

I'm sure there are programmers out there who wouldn't mind helping you out with that.
 
 
  • Post #13
  • Quote
  • Jan 14, 2010 12:57pm Jan 14, 2010 12:57pm
  •  Tataocb
  • | Joined Nov 2008 | Status: Member | 214 Posts
Thank you, and sorry if I asked too many questions. I'll keep on reasearching to see what I can do. This EA works great BTW, it does everything it's supposed to do. Thank you for sharing it with us.
On a journey to consistency.
 
 
  • Post #14
  • Quote
  • Jan 14, 2010 2:17pm Jan 14, 2010 2:17pm
  •  pichi
  • | Joined Apr 2009 | Status: Member | 22 Posts
Thanks RR, EA started putting her backtets working well, but then I said "ordermodify error 1..."
 
 
  • Post #15
  • Quote
  • Jan 14, 2010 3:01pm Jan 14, 2010 3:01pm
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
Ordermodify error 1 means nothing. I didn't notice any problems in the EA's operation, so I'm ignoring it.
 
 
  • Post #16
  • Quote
  • Feb 1, 2010 10:33am Feb 1, 2010 10:33am
  •  ns_karthik
  • | Commercial Member | Joined May 2006 | 1,808 Posts
Quoting Ronald Raygun
Disliked
MA of 1 uses the average of the close price...
Ignored
it doesnt work for me....no trades taken despite many crosses...
 
 
  • Post #17
  • Quote
  • Feb 1, 2010 11:03am Feb 1, 2010 11:03am
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
The rest of the settings?

There is a pip cross buffer in the EA, so it's possible those many crosses were small as a result of whiplash.
 
 
  • Post #18
  • Quote
  • Feb 1, 2010 2:17pm Feb 1, 2010 2:17pm
  •  reachjj
  • | Joined Dec 2009 | Status: Member | 265 Posts
Hi,

tried this with EU 15min with setting of 21 and 55 EMA. It looks good but I can there is a lot of drawdown.

Can you please add any filter based on hiher tf to filter out the signals on lower tf.

Much appreciated.

Thanks
Prakash
 
 
  • Post #19
  • Quote
  • Feb 2, 2010 10:48am Feb 2, 2010 10:48am
  •  todd960960
  • | Joined Nov 2008 | Status: Member | 470 Posts
Thx RR for another fine working EA. Question, must I have the 'tick database' true? Does it matter?

thx,
todd
 
 
  • Post #20
  • Quote
  • Feb 2, 2010 12:34pm Feb 2, 2010 12:34pm
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
The TickDatabase option is not required, but would be nice if enabled.

I'm simply collecting ticks from your EAs to add to the database found here (www.RonaldRaygunForex.com/TickDB/Archive). The download folder is updated once weekly Saturday at 2AM (EST) with the previous week's ticks. I assure you that I am only collecting these data points:

 

  1. Bid
  2. Ask
  3. Time
  4. BrokerName


I am currently working on some machine learning research to build on my "Old Dog New Tricks" thread, the collected tick data will make my research a lot easier.

 
 
  • Platform Tech
  • /
  • Generic MA Crossover Version 2 [TD]
  • Reply to Thread
    • Page 1 234 5
    • Page 1 234 5
0 traders viewing now
  • More
Top of Page
Forex Factory Blog Updated: Alerting All Members
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022