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
My own attempt. LOL
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


My own attempt. LOL
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); } //+------------------------------------------------------------------+
Last edited by a moderator: