Menu
Brokers
MT4 Forex Brokers
MT5 Forex brokers
PayPal Brokers
Skrill Brokers
Oil Trading Brokers
Gold Trading Brokers
Web Browser Platform
Brokers with CFD Trading
ECN Brokers
Bitcoin FX Brokers
PAMM Forex Brokers
With Cent Accounts
With High Leverage
Cryptocurrency Brokers
Forums
All threads
New threads
New posts
Trending
Search forums
What's new
New threads
New posts
Latest activity
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Reply to thread
Forums
Trading Platforms
MetaTrader Expert Advisors
Need help with EA.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
[QUOTE="cyxstudio, post: 39939, member: 21534"] I have made at least 10 different EAs and none of them works. I = am sorta giving up trying. Anyone here that is good with this stuff would you please write an example EA so that i could learn from it. conditions : 1. Open buy position when 2 Day RSI index is below 5 AND Ask price is above 200 Day moving average. 2. Close buy position when Ask price is above 5 Day moving average. 3. Open sell position when 2 Day RSI is above 95 AND Bid price is below 200 Day moving average 4. Close sell position when Bid price is below 5 day moving average. picture for guidance [IMG]http://i.imgur.com/OJh4Zs1.jpg[/IMG] [IMG]http://i.imgur.com/WRE30Ku.jpg[/IMG] My own attempt. LOL [code=mql4]//+------------------------------------------------------------------+ //| My Strategy 4.mq4 | //| Copyright 2013, MetaQuotes Software Corp. | //| [url]http://www.metaquotes.net[/url] | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" extern double StopLoss = 40; extern double TakeProfit = 40; extern double Lots = 0.1; extern double Slippage = 5; extern double RSINow; extern double MA200; extern double MA5; extern bool A1 = false; extern bool A2 = false; extern int Ticket; extern int Ticket2; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Alert("Minimum Stop Level is " + MarketInfo(Symbol(), MODE_STOPLEVEL)); //find out minimum stop loss RSINow = iRSI(NULL, 1440, 2, PRICE_CLOSE, 0); MA200 = iMA(NULL, 1440, 200, 0, MODE_SMA, PRICE_CLOSE,0); MA5 = iMA(NULL, 1440, 5, 0, MODE_SMA, PRICE_CLOSE,0); Alert(RSINow); Alert(MA200); Alert(MA5); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- RSINow = iRSI(NULL, 1440, 2, PRICE_CLOSE, 0); MA200 = iMA(NULL, 1440, 200, 0, MODE_SMA, PRICE_CLOSE,0); MA5 = iMA(NULL, 1440, 5, 0, MODE_SMA, PRICE_CLOSE,0); //check if a long position is possible if (A1 == false && RSINow < 5 && Ask > MA200) { Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Bid - ( StopLoss * Point ), Ask + ( TakeProfit * Point )); if(Ticket>0) { if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)) { Print("BUY order opened : ",OrderOpenPrice()); A1 = true; } if (Ticket < 0) { Print("Error opening BUY order : ",GetLastError()); return(0); } } } //check if a short position is possible if (A2 == false && RSINow > 95 && Bid < MA200) { Ticket2 = OrderSend(Symbol(), OP_BUY, Lots, Bid, Slippage, Ask + ( StopLoss * Point ), Bid - ( TakeProfit * Point )); if(Ticket2>0) { if(OrderSelect(Ticket2,SELECT_BY_TICKET,MODE_TRADES)) { Print("SELL order opened : ",OrderOpenPrice()); A2 = true; } if (Ticket2 < 0) { Print("Error opening SELL order : ",GetLastError()); return(0); } } } //check if buy position can be closed if ((A1 == true) && (Ask > MA5)) { OrderClose(Ticket, Lots, Bid, Slippage, Violet); A1 = false; return(0); } //check if sell position can be closed if ((A2 == true) && (Bid < MA5)) { OrderClose(Ticket2, Lots, Bid, Slippage, Violet); A2 = false; return(0); } //---- return(0); } //+------------------------------------------------------------------+[/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Top
Bottom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…