//+------------------------------------------------------------------+ //| P&P_EA_RSI.mq4 | //| Copyright © 2013, P&P Investment Strategies sagl | //| http://www.ppinvestment.ch | //+------------------------------------------------------------------+ #property copyright "P&P Investment Strategies © 2013" #property link "http://www.ppinvestment.ch" static datetime lastBar; extern double StopLoseBuy = 210; extern double TakeProfitBuy = 370; extern double StopLoseSell = 280; extern double TakeProfitSell = 360; extern double Lots = 1; extern int RsiPeriod = 4; extern double RsiBuyHigh = 50; extern double RsiBuyLow = 19; extern double RsiSellHigh = 75; extern double RsiSellLow = 50; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { lastBar= Time[ 0]; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(Bars< 10) { Print("bars less than 10"); return(0); } // si attiva subito dopo la chiusura della candela if( lastBar!= Time[ 0]) { lastBar= Time[ 0]; // apre posizione di BUY quando RSI attraversa il livello minimo con una certa pendenza if( iRSI(NULL, 0, RsiPeriod, PRICE_CLOSE, 2)< RsiBuyLow && iRSI(NULL, 0, RsiPeriod, PRICE_CLOSE, 1)> RsiBuyHigh) { OrderSend( Symbol(), OP_BUY, Lots, Ask, 3, Ask- ( StopLoseBuy* Point), Ask+ ( TakeProfitBuy* Point), "P&P_EA_MACD", 803, 0, Red); } // apre posizione di SELL quando RSI attraversa il livello massimo con una certa pendenza if( iRSI(NULL, 0, RsiPeriod, PRICE_CLOSE, 2)> RsiSellHigh && iRSI(NULL, 0, RsiPeriod, PRICE_CLOSE, 1)< RsiSellLow) { OrderSend( Symbol(), OP_SELL, Lots, Bid, 3, Bid+ ( StopLoseSell* Point), Bid- ( TakeProfitSell* Point), "P&P_EA_MACD", 803, 0, Blue); } } return(0); } //+------------------------------------------------------------------+