Experts: Universal EA - page 2

 

Hi,

Good pacofflin, nice and unversal EA,

I do filter the codes, and here under the modivied 4H TFrame

//+------------------------------------------------------------------+
//|                                                        TK EA.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "P.A.Cofflin"
#property link  "p.a.cofflin@gmail.com"
extern string email = "Email me if you want me to check your inputs or just to share :)";
extern string emailaddress = "p.a.cofflin@gmail.com";
extern string OrderSetup = "Order Setup";
extern double MaxLotSize = 200;
extern double MinLotSize = 0.01;
extern double MaxOrders = 1;
extern double OrderExpirationTimer = 7200;
extern double AcountBalanceUsedPercent = 10;
extern double OrderOpenLevel = 10;
extern double Slippage = 3;
extern double TakeProfit = 230;
extern double StopLoss = 180;
extern string space1 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string HedgingOption = "Option to place sell order when buying";
extern bool Hedging = true;
extern string HedgingMultiplier = "The option to change lot size of hedge order";
extern double HedgingLotSizeMultiplier= 1.5;
extern string space2 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string MinimumMultiplier = "Minimum for an order to be closed";
extern double MinimumStopLossMultiplier = 10;
extern double MinimumTakeProfitMultiplier = 10;
extern string space3 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string StopLossTakeProfit = "Following section for different order close options";
extern string TrailingStopandStep = "Sets a trailing stop and step ammount that follows the stop";
extern bool TrailingStopLoss = false;
extern double TrailingStop = 75;
extern double TrailingStep = 5;
extern string PercentageClose = "Sets a percentage to close an order based on Account Equity";
extern bool PercentageStopLoss = false;
extern double AccountPercentageStopLoss = 10;
extern bool PercentageTakeProfit = 0;
extern double AccountPercentageTakeProfit = 10;
extern string CloseTimer = "Closes a trade after a specified amount of seconds";
extern bool StopLossTimer = false;
extern double TimedStopLoss = 7200;
extern bool TakeProfitTimer = false;
extern double TimedTakeProfit = 7200;
extern string StochasticClose = "Closes order after Kperiod crosses Dperiod";
extern bool StochasticTakeProfit = true;
extern double KperiodTakeProfit = 200;
extern double DperiodTakeProfit = 55;
extern double SlowingTakeProfit = 3;
extern bool StochasticStopLoss = false;
extern double KperiodStopLoss = 20;
extern double DperiodStopLoss = 15;
extern double SlowingStopLoss = 3;
extern string space4 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string OrderModifiers = "The following modify an order to minimize loss potential";
extern string PercentChange = "Checks if a certain percentage change has occured"; 
extern bool StochasticPercentChange = false;
extern double StochasticPercentChangeLevel = 1;
extern string TradeLimiter = "Prevents orders two bars above stochastic crossing";
extern bool StochasticTradeLimiter = false;
extern double KperiodLimiter = 20;
extern double DperiodLimiter = 5;
extern double SlowingLimiter = 3;
extern string space5 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string Indicators = "Choose which indicators and parameters to use";
extern bool StochasticBuy = true;
extern double StocOverSoldLevel = 20;
extern double Kperiod = 20;
extern double Dperiod = 5;
extern double Slowing = 3;
extern string MACross = "Moving average crossing buy signal";
extern bool MACrossBuy = false;
extern double SlowMAperiod = 20;
extern double FastMAperiod = 10;
extern string MACDBuySignal = "Buy signal when signal line goes below MACD level";
extern bool MACDBuy = false;
extern double FastEMA = 5;
extern double SlowEMA = 15;
extern double SMA = 2;
extern string VolumeSignal = "Buy signal of two increasing volumes and minimum volume level required for buy signal"; 
extern bool VolumeBuy = false;
extern double VolumeMinimumLevel = 200;
extern string RSISignal = "Buy when fast RSI crosses above slow RSI";
extern bool RSIBuy = false;
extern double FastRSI = 13;
extern double SlowRSI = 26;
bool Buy = false;
bool Sell = false;
extern int MagicNumber = 1;
double pips;  
void MoveTrailingStop()
{int cnt,total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol())
      {if(OrderType()==OP_BUY)
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(Bid-Point*(TrailingStop+TrailingStep),Digits))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-Point*TrailingStop,Digits),OrderTakeProfit(),0,Green);
                  return(0);}}}
         else 
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+Point*(TrailingStop+TrailingStep),Digits)))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+Point*TrailingStop,Digits),OrderTakeProfit(),0,Red);
                  return(0);}}}}}}
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE);
   if (ticksize == 0.00001 || ticksize == 0.001)
   pips = ticksize*10;
   else pips = ticksize;
   
   // Thanks to Jimdandy1958, his youtube tutorials taught me how to code mql4. Check out his tutorials at https://www.youtube.com/watch?v=n8fZINmSv0g.
   // Also check out his websites http://www.jimdandyforex.com and http://jimdandymql4courses.com.
   
 
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
int i=0; 
//
double CurrentStochasticKperiod = iStochastic (NULL,0,Kperiod,Dperiod,Slowing,3,1,0,0);
double FirstStochasticKperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1);
double SecondStochasticKperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2);
double CurrentStochasticDperiod = iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,0);
double FirstStochasticDperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,1);
double SecondStochasticDperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,2);
//
//
double FirstStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,1);
double SecondStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,2);
double FirstStochasticLimiterDperiod =   iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,1);
double SecondStochasticLimiterDperiod =  iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,2);
//
//
double FirstStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,1);
double SecondStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,2);
double FirstStochasticSLDperiod =   iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,1);
double SecondStochasticSLDperiod =  iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,2);
//
//
double FirstStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,1);
double SecondStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,2);
double FirstStochasticTPDperiod =   iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,1);
double SecondStochasticTPDperiod =  iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,2);
//
double SBS = (iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1) - iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2));
double FirstMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,1);
double SecondMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,2);
double FirstMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,1);
double SecondMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,2);
double FirstVolumeBuy = iVolume(NULL,0,1);
double SecondVolumeBuy = iVolume(NULL,0,2);
double FastRSIOne = iRSI(NULL,0,FastRSI,6,1);
double SlowRSIOne = iRSI(NULL,0,SlowRSI,6,1);
double LotSize = (AccountEquity()*(AcountBalanceUsedPercent/100))/1000; 
if (LotSize>MaxLotSize) LotSize = MaxLotSize;
if (LotSize<MinLotSize) LotSize = MinLotSize;
double CurrentLow = iLow(NULL,0,0);
double BuyLowOne = iLow(NULL,0,1);
double BuyLowTwo = iLow(NULL,0,2);
double BuyLowThree = iLow(NULL,0,3);
double BuyLowFour = iLow(NULL,0,4);
double CurrentSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,0);
double FirstSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,1);
double CurrentFastMA = iMA(NULL,0,FastMAperiod,0,3,6,0);
double FirstFastMA = iMA(NULL,0,FastMAperiod,0,3,6,1);
double ExpirationTime = TimeCurrent()+OrderExpirationTimer;
double CurrentClose = iClose(NULL,0,0);
double CloseOne =     iClose(NULL,0,1);
double CurrentOpen = iOpen(NULL,0,0);
double CurrentBuySignal = (iClose(NULL,0,0)-iOpen(NULL,0,0));
double BuySignal = (iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalTwo = (iClose(NULL,0,2)-iOpen(NULL,0,2));
double BuySignalThree = (iClose(NULL,0,3)-iOpen(NULL,0,3));
double CurrentCOMinus = MathAbs(iClose(NULL,0,0)-iOpen(NULL,0,0));
double COMinus = MathAbs(iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalAverage = MathAbs((BuySignal+BuySignalTwo+BuySignalThree)/3);
double MinSell = MathAbs((OrderOpenPrice()-Ask));
double Minsell = MathAbs((Bid-OrderOpenPrice()));
double MinSellLevel = (pips*MinimumStopLossMultiplier);
double MinBuy = MathAbs((OrderOpenPrice()-Ask));
double Minbuy = MathAbs((Bid-OrderOpenPrice()));
double MinBuyLevel = (pips*MinimumTakeProfitMultiplier);
bool RSIBuySignal = FastRSIOne>SlowRSIOne;
bool VolumeMinimum = FirstVolumeBuy>VolumeMinimumLevel;
bool VolumeBuySignal = FirstVolumeBuy>SecondVolumeBuy;
bool MACDBuySignalOne = FirstMACDBuy>FirstMACDBuySignalLine;
bool MACDBuySignalTwo = SecondMACDBuy<FirstMACDBuy;
bool StochasticBuyOne= FirstStochasticLimiterKperiod>FirstStochasticLimiterDperiod;
bool StochasticBuyTwo = SecondStochasticLimiterKperiod>SecondStochasticLimiterDperiod;
bool StochasticBuySignal = FirstStochasticDperiod<FirstStochasticKperiod;
bool StochasticOverSold = FirstStochasticKperiod<StocOverSoldLevel;
bool MACrossBuySignal = CurrentFastMA>CurrentSlowMA;
bool SBSone = SBS>StochasticPercentChangeLevel;
if(OrdersTotal()>=0 && RSIBuy==true) 
  {if(RSIBuySignal==true) Buy=true;
  {if(RSIBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && VolumeBuy==true) 
  {if(VolumeBuySignal==true && VolumeMinimum==true) Buy=true;
  {if(VolumeMinimum==false) Buy=false;
  {if(VolumeBuySignal==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && MACDBuy==true) 
  {if(MACDBuySignalOne==true && MACDBuySignalTwo==true) Buy=true;
  {if(MACDBuySignalOne==false) Buy=false;
  {if(MACDBuySignalTwo==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && StochasticPercentChange==true) 
  {if(SBSone==true) Buy=true;
  {if(SBSone==false) Buy=false;
  }}
if(OrdersTotal()>=0 && MACrossBuy==true) 
  {if(MACrossBuySignal==true) Buy=true;
  {if(MACrossBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && StochasticBuy==true) 
  {if(StochasticBuySignal==true && StochasticOverSold==true) Buy=true;
  {if(StochasticBuySignal==false) Buy=false;
  {if(StochasticOverSold==false) Buy=false;
  }}}
   
if(OrdersTotal()>=0 && StochasticTradeLimiter==true) 
  {if(StochasticBuyOne==true) Buy=true;
  {if(StochasticBuyOne==true && StochasticBuyTwo==true) Buy=false;
  }}
   
   
      if(OrdersTotal()<MaxOrders && Buy==true)
      OrderSend(Symbol(),OP_BUYSTOP,LotSize,Ask+(pips*OrderOpenLevel),3,Ask-(StopLoss*pips),Ask+(pips*TakeProfit),NULL,MagicNumber,ExpirationTime,Green);
      
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountBalance()>(AccountEquity()*(1+((AccountPercentageStopLoss*LotSize)/100))) && PercentageStopLoss==true && MinSell>MinSellLevel)
            {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage ); 
            else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Stop Loss Close");}}}
             
            
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountEquity()>(AccountBalance()*(1+((AccountPercentageTakeProfit*LotSize)/100))) && PercentageTakeProfit==true && MinBuy>MinBuyLevel)
            {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
            else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Take Profit Close");}}}
             
        {for(int i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedStopLoss) < TimeCurrent() && StopLossTimer==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Stop Loss Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedTakeProfit) < TimeCurrent() && TakeProfitTimer==true && OrderProfit()>=MinBuyLevel && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Take Profit Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticSLKperiod<FirstStochasticSLDperiod) && StochasticStopLoss==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Stop Loss Close");}}}
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticTPKperiod<FirstStochasticTPDperiod) && OrderProfit()>0 && StochasticTakeProfit==true && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Take Profit Close");}}}
                
   {for( int i3 = 0 ; i3 < OrdersTotal() ; i3++ ) 
         {if( OrderSelect( i3, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
             {if(OrdersTotal()<=(MaxOrders) && OrdersTotal()>0 && OrderType()==OP_BUY && Hedging==true)
              OrderSend(Symbol(),OP_SELLSTOP,(LotSize*HedgingLotSizeMultiplier),Bid-(pips*OrderOpenLevel),3,Bid+(StopLoss*pips),Bid-(pips*TakeProfit),NULL,1,ExpirationTime,Green);
             }}}
   
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()>0 && TrailingStop>0 && TrailingStopLoss==true && MinBuy>MinBuyLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()<0 && TrailingStop>0 && TrailingStopLoss==true && MinSell>MinSellLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
//----
   return(0);
  }
//+------------------------------------------------------------------+

 

Hi,

Good pacofflin, nice and unversal EA,

I do filter the codes, and here under the modivied 4H TFrame

//+------------------------------------------------------------------+
//|                                                        TK EA.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "P.A.Cofflin"
#property link  "p.a.cofflin@gmail.com"
extern string email = "Email me if you want me to check your inputs or just to share :)";
extern string emailaddress = "p.a.cofflin@gmail.com";
extern string OrderSetup = "Order Setup";
extern double MaxLotSize = 200;
extern double MinLotSize = 0.01;
extern double MaxOrders = 1;
extern double OrderExpirationTimer = 7200;
extern double AcountBalanceUsedPercent = 10;
extern double OrderOpenLevel = 10;
extern double Slippage = 3;
extern double TakeProfit = 230;
extern double StopLoss = 180;
extern string space1 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string HedgingOption = "Option to place sell order when buying";
extern bool Hedging = true;
extern string HedgingMultiplier = "The option to change lot size of hedge order";
extern double HedgingLotSizeMultiplier= 1.5;
extern string space2 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string MinimumMultiplier = "Minimum for an order to be closed";
extern double MinimumStopLossMultiplier = 10;
extern double MinimumTakeProfitMultiplier = 10;
extern string space3 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string StopLossTakeProfit = "Following section for different order close options";
extern string TrailingStopandStep = "Sets a trailing stop and step ammount that follows the stop";
extern bool TrailingStopLoss = false;
extern double TrailingStop = 75;
extern double TrailingStep = 5;
extern string PercentageClose = "Sets a percentage to close an order based on Account Equity";
extern bool PercentageStopLoss = false;
extern double AccountPercentageStopLoss = 10;
extern bool PercentageTakeProfit = 0;
extern double AccountPercentageTakeProfit = 10;
extern string CloseTimer = "Closes a trade after a specified amount of seconds";
extern bool StopLossTimer = false;
extern double TimedStopLoss = 7200;
extern bool TakeProfitTimer = false;
extern double TimedTakeProfit = 7200;
extern string StochasticClose = "Closes order after Kperiod crosses Dperiod";
extern bool StochasticTakeProfit = true;
extern double KperiodTakeProfit = 200;
extern double DperiodTakeProfit = 55;
extern double SlowingTakeProfit = 3;
extern bool StochasticStopLoss = false;
extern double KperiodStopLoss = 20;
extern double DperiodStopLoss = 15;
extern double SlowingStopLoss = 3;
extern string space4 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string OrderModifiers = "The following modify an order to minimize loss potential";
extern string PercentChange = "Checks if a certain percentage change has occured"; 
extern bool StochasticPercentChange = false;
extern double StochasticPercentChangeLevel = 1;
extern string TradeLimiter = "Prevents orders two bars above stochastic crossing";
extern bool StochasticTradeLimiter = false;
extern double KperiodLimiter = 20;
extern double DperiodLimiter = 5;
extern double SlowingLimiter = 3;
extern string space5 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string Indicators = "Choose which indicators and parameters to use";
extern bool StochasticBuy = true;
extern double StocOverSoldLevel = 20;
extern double Kperiod = 20;
extern double Dperiod = 5;
extern double Slowing = 3;
extern string MACross = "Moving average crossing buy signal";
extern bool MACrossBuy = false;
extern double SlowMAperiod = 20;
extern double FastMAperiod = 10;
extern string MACDBuySignal = "Buy signal when signal line goes below MACD level";
extern bool MACDBuy = false;
extern double FastEMA = 5;
extern double SlowEMA = 15;
extern double SMA = 2;
extern string VolumeSignal = "Buy signal of two increasing volumes and minimum volume level required for buy signal"; 
extern bool VolumeBuy = false;
extern double VolumeMinimumLevel = 200;
extern string RSISignal = "Buy when fast RSI crosses above slow RSI";
extern bool RSIBuy = false;
extern double FastRSI = 13;
extern double SlowRSI = 26;
bool Buy = false;
bool Sell = false;
extern int MagicNumber = 1;
double pips;  
void MoveTrailingStop()
{int cnt,total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol())
      {if(OrderType()==OP_BUY)
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(Bid-Point*(TrailingStop+TrailingStep),Digits))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-Point*TrailingStop,Digits),OrderTakeProfit(),0,Green);
                  return(0);}}}
         else 
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+Point*(TrailingStop+TrailingStep),Digits)))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+Point*TrailingStop,Digits),OrderTakeProfit(),0,Red);
                  return(0);}}}}}}
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE);
   if (ticksize == 0.00001 || ticksize == 0.001)
   pips = ticksize*10;
   else pips = ticksize;
   
   // Thanks to Jimdandy1958, his youtube tutorials taught me how to code mql4. Check out his tutorials at https://www.youtube.com/watch?v=n8fZINmSv0g.
   // Also check out his websites http://www.jimdandyforex.com and http://jimdandymql4courses.com.
   
 
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
int i=0; 
//
double CurrentStochasticKperiod = iStochastic (NULL,0,Kperiod,Dperiod,Slowing,3,1,0,0);
double FirstStochasticKperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1);
double SecondStochasticKperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2);
double CurrentStochasticDperiod = iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,0);
double FirstStochasticDperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,1);
double SecondStochasticDperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,2);
//
//
double FirstStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,1);
double SecondStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,2);
double FirstStochasticLimiterDperiod =   iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,1);
double SecondStochasticLimiterDperiod =  iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,2);
//
//
double FirstStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,1);
double SecondStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,2);
double FirstStochasticSLDperiod =   iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,1);
double SecondStochasticSLDperiod =  iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,2);
//
//
double FirstStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,1);
double SecondStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,2);
double FirstStochasticTPDperiod =   iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,1);
double SecondStochasticTPDperiod =  iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,2);
//
double SBS = (iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1) - iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2));
double FirstMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,1);
double SecondMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,2);
double FirstMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,1);
double SecondMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,2);
double FirstVolumeBuy = iVolume(NULL,0,1);
double SecondVolumeBuy = iVolume(NULL,0,2);
double FastRSIOne = iRSI(NULL,0,FastRSI,6,1);
double SlowRSIOne = iRSI(NULL,0,SlowRSI,6,1);
double LotSize = (AccountEquity()*(AcountBalanceUsedPercent/100))/1000; 
if (LotSize>MaxLotSize) LotSize = MaxLotSize;
if (LotSize<MinLotSize) LotSize = MinLotSize;
double CurrentLow = iLow(NULL,0,0);
double BuyLowOne = iLow(NULL,0,1);
double BuyLowTwo = iLow(NULL,0,2);
double BuyLowThree = iLow(NULL,0,3);
double BuyLowFour = iLow(NULL,0,4);
double CurrentSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,0);
double FirstSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,1);
double CurrentFastMA = iMA(NULL,0,FastMAperiod,0,3,6,0);
double FirstFastMA = iMA(NULL,0,FastMAperiod,0,3,6,1);
double ExpirationTime = TimeCurrent()+OrderExpirationTimer;
double CurrentClose = iClose(NULL,0,0);
double CloseOne =     iClose(NULL,0,1);
double CurrentOpen = iOpen(NULL,0,0);
double CurrentBuySignal = (iClose(NULL,0,0)-iOpen(NULL,0,0));
double BuySignal = (iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalTwo = (iClose(NULL,0,2)-iOpen(NULL,0,2));
double BuySignalThree = (iClose(NULL,0,3)-iOpen(NULL,0,3));
double CurrentCOMinus = MathAbs(iClose(NULL,0,0)-iOpen(NULL,0,0));
double COMinus = MathAbs(iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalAverage = MathAbs((BuySignal+BuySignalTwo+BuySignalThree)/3);
double MinSell = MathAbs((OrderOpenPrice()-Ask));
double Minsell = MathAbs((Bid-OrderOpenPrice()));
double MinSellLevel = (pips*MinimumStopLossMultiplier);
double MinBuy = MathAbs((OrderOpenPrice()-Ask));
double Minbuy = MathAbs((Bid-OrderOpenPrice()));
double MinBuyLevel = (pips*MinimumTakeProfitMultiplier);
bool RSIBuySignal = FastRSIOne>SlowRSIOne;
bool VolumeMinimum = FirstVolumeBuy>VolumeMinimumLevel;
bool VolumeBuySignal = FirstVolumeBuy>SecondVolumeBuy;
bool MACDBuySignalOne = FirstMACDBuy>FirstMACDBuySignalLine;
bool MACDBuySignalTwo = SecondMACDBuy<FirstMACDBuy;
bool StochasticBuyOne= FirstStochasticLimiterKperiod>FirstStochasticLimiterDperiod;
bool StochasticBuyTwo = SecondStochasticLimiterKperiod>SecondStochasticLimiterDperiod;
bool StochasticBuySignal = FirstStochasticDperiod<FirstStochasticKperiod;
bool StochasticOverSold = FirstStochasticKperiod<StocOverSoldLevel;
bool MACrossBuySignal = CurrentFastMA>CurrentSlowMA;
bool SBSone = SBS>StochasticPercentChangeLevel;
if(OrdersTotal()>=0 && RSIBuy==true) 
  {if(RSIBuySignal==true) Buy=true;
  {if(RSIBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && VolumeBuy==true) 
  {if(VolumeBuySignal==true && VolumeMinimum==true) Buy=true;
  {if(VolumeMinimum==false) Buy=false;
  {if(VolumeBuySignal==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && MACDBuy==true) 
  {if(MACDBuySignalOne==true && MACDBuySignalTwo==true) Buy=true;
  {if(MACDBuySignalOne==false) Buy=false;
  {if(MACDBuySignalTwo==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && StochasticPercentChange==true) 
  {if(SBSone==true) Buy=true;
  {if(SBSone==false) Buy=false;
  }}
if(OrdersTotal()>=0 && MACrossBuy==true) 
  {if(MACrossBuySignal==true) Buy=true;
  {if(MACrossBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && StochasticBuy==true) 
  {if(StochasticBuySignal==true && StochasticOverSold==true) Buy=true;
  {if(StochasticBuySignal==false) Buy=false;
  {if(StochasticOverSold==false) Buy=false;
  }}}
   
if(OrdersTotal()>=0 && StochasticTradeLimiter==true) 
  {if(StochasticBuyOne==true) Buy=true;
  {if(StochasticBuyOne==true && StochasticBuyTwo==true) Buy=false;
  }}
   
   
      if(OrdersTotal()<MaxOrders && Buy==true)
      OrderSend(Symbol(),OP_BUYSTOP,LotSize,Ask+(pips*OrderOpenLevel),3,Ask-(StopLoss*pips),Ask+(pips*TakeProfit),NULL,MagicNumber,ExpirationTime,Green);
      
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountBalance()>(AccountEquity()*(1+((AccountPercentageStopLoss*LotSize)/100))) && PercentageStopLoss==true && MinSell>MinSellLevel)
            {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage ); 
            else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Stop Loss Close");}}}
             
            
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountEquity()>(AccountBalance()*(1+((AccountPercentageTakeProfit*LotSize)/100))) && PercentageTakeProfit==true && MinBuy>MinBuyLevel)
            {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
            else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Take Profit Close");}}}
             
        {for(int i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedStopLoss) < TimeCurrent() && StopLossTimer==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Stop Loss Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedTakeProfit) < TimeCurrent() && TakeProfitTimer==true && OrderProfit()>=MinBuyLevel && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Take Profit Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticSLKperiod<FirstStochasticSLDperiod) && StochasticStopLoss==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Stop Loss Close");}}}
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticTPKperiod<FirstStochasticTPDperiod) && OrderProfit()>0 && StochasticTakeProfit==true && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Take Profit Close");}}}
                
   {for( int i3 = 0 ; i3 < OrdersTotal() ; i3++ ) 
         {if( OrderSelect( i3, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
             {if(OrdersTotal()<=(MaxOrders) && OrdersTotal()>0 && OrderType()==OP_BUY && Hedging==true)
              OrderSend(Symbol(),OP_SELLSTOP,(LotSize*HedgingLotSizeMultiplier),Bid-(pips*OrderOpenLevel),3,Bid+(StopLoss*pips),Bid-(pips*TakeProfit),NULL,1,ExpirationTime,Green);
             }}}
   
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()>0 && TrailingStop>0 && TrailingStopLoss==true && MinBuy>MinBuyLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()<0 && TrailingStop>0 && TrailingStopLoss==true && MinSell>MinSellLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
//----
   return(0);
  }
//+------------------------------------------------------------------+

 
Elliott_Trader:

Hi,

Good pacofflin, nice and unversal EA,

I do filter the codes, and here under the modivied 4H TFrame

//+------------------------------------------------------------------+
//|                                                        TK EA.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "P.A.Cofflin"
#property link  "p.a.cofflin@gmail.com"
extern string email = "Email me if you want me to check your inputs or just to share :)";
extern string emailaddress = "p.a.cofflin@gmail.com";
extern string OrderSetup = "Order Setup";
extern double MaxLotSize = 200;
extern double MinLotSize = 0.01;
extern double MaxOrders = 1;
extern double OrderExpirationTimer = 7200;
extern double AcountBalanceUsedPercent = 10;
extern double OrderOpenLevel = 10;
extern double Slippage = 3;
extern double TakeProfit = 230;
extern double StopLoss = 180;
extern string space1 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string HedgingOption = "Option to place sell order when buying";
extern bool Hedging = true;
extern string HedgingMultiplier = "The option to change lot size of hedge order";
extern double HedgingLotSizeMultiplier= 1.5;
extern string space2 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string MinimumMultiplier = "Minimum for an order to be closed";
extern double MinimumStopLossMultiplier = 10;
extern double MinimumTakeProfitMultiplier = 10;
extern string space3 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string StopLossTakeProfit = "Following section for different order close options";
extern string TrailingStopandStep = "Sets a trailing stop and step ammount that follows the stop";
extern bool TrailingStopLoss = false;
extern double TrailingStop = 75;
extern double TrailingStep = 5;
extern string PercentageClose = "Sets a percentage to close an order based on Account Equity";
extern bool PercentageStopLoss = false;
extern double AccountPercentageStopLoss = 10;
extern bool PercentageTakeProfit = 0;
extern double AccountPercentageTakeProfit = 10;
extern string CloseTimer = "Closes a trade after a specified amount of seconds";
extern bool StopLossTimer = false;
extern double TimedStopLoss = 7200;
extern bool TakeProfitTimer = false;
extern double TimedTakeProfit = 7200;
extern string StochasticClose = "Closes order after Kperiod crosses Dperiod";
extern bool StochasticTakeProfit = true;
extern double KperiodTakeProfit = 200;
extern double DperiodTakeProfit = 55;
extern double SlowingTakeProfit = 3;
extern bool StochasticStopLoss = false;
extern double KperiodStopLoss = 20;
extern double DperiodStopLoss = 15;
extern double SlowingStopLoss = 3;
extern string space4 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string OrderModifiers = "The following modify an order to minimize loss potential";
extern string PercentChange = "Checks if a certain percentage change has occured"; 
extern bool StochasticPercentChange = false;
extern double StochasticPercentChangeLevel = 1;
extern string TradeLimiter = "Prevents orders two bars above stochastic crossing";
extern bool StochasticTradeLimiter = false;
extern double KperiodLimiter = 20;
extern double DperiodLimiter = 5;
extern double SlowingLimiter = 3;
extern string space5 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string Indicators = "Choose which indicators and parameters to use";
extern bool StochasticBuy = true;
extern double StocOverSoldLevel = 20;
extern double Kperiod = 20;
extern double Dperiod = 5;
extern double Slowing = 3;
extern string MACross = "Moving average crossing buy signal";
extern bool MACrossBuy = false;
extern double SlowMAperiod = 20;
extern double FastMAperiod = 10;
extern string MACDBuySignal = "Buy signal when signal line goes below MACD level";
extern bool MACDBuy = false;
extern double FastEMA = 5;
extern double SlowEMA = 15;
extern double SMA = 2;
extern string VolumeSignal = "Buy signal of two increasing volumes and minimum volume level required for buy signal"; 
extern bool VolumeBuy = false;
extern double VolumeMinimumLevel = 200;
extern string RSISignal = "Buy when fast RSI crosses above slow RSI";
extern bool RSIBuy = false;
extern double FastRSI = 13;
extern double SlowRSI = 26;
bool Buy = false;
bool Sell = false;
extern int MagicNumber = 1;
double pips;  
void MoveTrailingStop()
{int cnt,total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol())
      {if(OrderType()==OP_BUY)
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(Bid-Point*(TrailingStop+TrailingStep),Digits))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-Point*TrailingStop,Digits),OrderTakeProfit(),0,Green);
                  return(0);}}}
         else 
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+Point*(TrailingStop+TrailingStep),Digits)))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+Point*TrailingStop,Digits),OrderTakeProfit(),0,Red);
                  return(0);}}}}}}
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE);
   if (ticksize == 0.00001 || ticksize == 0.001)
   pips = ticksize*10;
   else pips = ticksize;
   
   // Thanks to Jimdandy1958, his youtube tutorials taught me how to code mql4. Check out his tutorials at https://www.youtube.com/watch?v=n8fZINmSv0g.
   // Also check out his websites http://www.jimdandyforex.com and http://jimdandymql4courses.com.
   
 
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
int i=0; 
//
double CurrentStochasticKperiod = iStochastic (NULL,0,Kperiod,Dperiod,Slowing,3,1,0,0);
double FirstStochasticKperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1);
double SecondStochasticKperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2);
double CurrentStochasticDperiod = iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,0);
double FirstStochasticDperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,1);
double SecondStochasticDperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,2);
//
//
double FirstStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,1);
double SecondStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,2);
double FirstStochasticLimiterDperiod =   iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,1);
double SecondStochasticLimiterDperiod =  iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,2);
//
//
double FirstStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,1);
double SecondStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,2);
double FirstStochasticSLDperiod =   iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,1);
double SecondStochasticSLDperiod =  iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,2);
//
//
double FirstStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,1);
double SecondStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,2);
double FirstStochasticTPDperiod =   iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,1);
double SecondStochasticTPDperiod =  iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,2);
//
double SBS = (iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1) - iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2));
double FirstMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,1);
double SecondMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,2);
double FirstMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,1);
double SecondMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,2);
double FirstVolumeBuy = iVolume(NULL,0,1);
double SecondVolumeBuy = iVolume(NULL,0,2);
double FastRSIOne = iRSI(NULL,0,FastRSI,6,1);
double SlowRSIOne = iRSI(NULL,0,SlowRSI,6,1);
double LotSize = (AccountEquity()*(AcountBalanceUsedPercent/100))/1000; 
if (LotSize>MaxLotSize) LotSize = MaxLotSize;
if (LotSize<MinLotSize) LotSize = MinLotSize;
double CurrentLow = iLow(NULL,0,0);
double BuyLowOne = iLow(NULL,0,1);
double BuyLowTwo = iLow(NULL,0,2);
double BuyLowThree = iLow(NULL,0,3);
double BuyLowFour = iLow(NULL,0,4);
double CurrentSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,0);
double FirstSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,1);
double CurrentFastMA = iMA(NULL,0,FastMAperiod,0,3,6,0);
double FirstFastMA = iMA(NULL,0,FastMAperiod,0,3,6,1);
double ExpirationTime = TimeCurrent()+OrderExpirationTimer;
double CurrentClose = iClose(NULL,0,0);
double CloseOne =     iClose(NULL,0,1);
double CurrentOpen = iOpen(NULL,0,0);
double CurrentBuySignal = (iClose(NULL,0,0)-iOpen(NULL,0,0));
double BuySignal = (iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalTwo = (iClose(NULL,0,2)-iOpen(NULL,0,2));
double BuySignalThree = (iClose(NULL,0,3)-iOpen(NULL,0,3));
double CurrentCOMinus = MathAbs(iClose(NULL,0,0)-iOpen(NULL,0,0));
double COMinus = MathAbs(iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalAverage = MathAbs((BuySignal+BuySignalTwo+BuySignalThree)/3);
double MinSell = MathAbs((OrderOpenPrice()-Ask));
double Minsell = MathAbs((Bid-OrderOpenPrice()));
double MinSellLevel = (pips*MinimumStopLossMultiplier);
double MinBuy = MathAbs((OrderOpenPrice()-Ask));
double Minbuy = MathAbs((Bid-OrderOpenPrice()));
double MinBuyLevel = (pips*MinimumTakeProfitMultiplier);
bool RSIBuySignal = FastRSIOne>SlowRSIOne;
bool VolumeMinimum = FirstVolumeBuy>VolumeMinimumLevel;
bool VolumeBuySignal = FirstVolumeBuy>SecondVolumeBuy;
bool MACDBuySignalOne = FirstMACDBuy>FirstMACDBuySignalLine;
bool MACDBuySignalTwo = SecondMACDBuy<FirstMACDBuy;
bool StochasticBuyOne= FirstStochasticLimiterKperiod>FirstStochasticLimiterDperiod;
bool StochasticBuyTwo = SecondStochasticLimiterKperiod>SecondStochasticLimiterDperiod;
bool StochasticBuySignal = FirstStochasticDperiod<FirstStochasticKperiod;
bool StochasticOverSold = FirstStochasticKperiod<StocOverSoldLevel;
bool MACrossBuySignal = CurrentFastMA>CurrentSlowMA;
bool SBSone = SBS>StochasticPercentChangeLevel;
if(OrdersTotal()>=0 && RSIBuy==true) 
  {if(RSIBuySignal==true) Buy=true;
  {if(RSIBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && VolumeBuy==true) 
  {if(VolumeBuySignal==true && VolumeMinimum==true) Buy=true;
  {if(VolumeMinimum==false) Buy=false;
  {if(VolumeBuySignal==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && MACDBuy==true) 
  {if(MACDBuySignalOne==true && MACDBuySignalTwo==true) Buy=true;
  {if(MACDBuySignalOne==false) Buy=false;
  {if(MACDBuySignalTwo==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && StochasticPercentChange==true) 
  {if(SBSone==true) Buy=true;
  {if(SBSone==false) Buy=false;
  }}
if(OrdersTotal()>=0 && MACrossBuy==true) 
  {if(MACrossBuySignal==true) Buy=true;
  {if(MACrossBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && StochasticBuy==true) 
  {if(StochasticBuySignal==true && StochasticOverSold==true) Buy=true;
  {if(StochasticBuySignal==false) Buy=false;
  {if(StochasticOverSold==false) Buy=false;
  }}}
   
if(OrdersTotal()>=0 && StochasticTradeLimiter==true) 
  {if(StochasticBuyOne==true) Buy=true;
  {if(StochasticBuyOne==true && StochasticBuyTwo==true) Buy=false;
  }}
   
   
      if(OrdersTotal()<MaxOrders && Buy==true)
      OrderSend(Symbol(),OP_BUYSTOP,LotSize,Ask+(pips*OrderOpenLevel),3,Ask-(StopLoss*pips),Ask+(pips*TakeProfit),NULL,MagicNumber,ExpirationTime,Green);
      
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountBalance()>(AccountEquity()*(1+((AccountPercentageStopLoss*LotSize)/100))) && PercentageStopLoss==true && MinSell>MinSellLevel)
            {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage ); 
            else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Stop Loss Close");}}}
             
            
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountEquity()>(AccountBalance()*(1+((AccountPercentageTakeProfit*LotSize)/100))) && PercentageTakeProfit==true && MinBuy>MinBuyLevel)
            {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
            else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Take Profit Close");}}}
             
        {for(int i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedStopLoss) < TimeCurrent() && StopLossTimer==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Stop Loss Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedTakeProfit) < TimeCurrent() && TakeProfitTimer==true && OrderProfit()>=MinBuyLevel && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Take Profit Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticSLKperiod<FirstStochasticSLDperiod) && StochasticStopLoss==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Stop Loss Close");}}}
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticTPKperiod<FirstStochasticTPDperiod) && OrderProfit()>0 && StochasticTakeProfit==true && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Take Profit Close");}}}
                
   {for( int i3 = 0 ; i3 < OrdersTotal() ; i3++ ) 
         {if( OrderSelect( i3, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
             {if(OrdersTotal()<=(MaxOrders) && OrdersTotal()>0 && OrderType()==OP_BUY && Hedging==true)
              OrderSend(Symbol(),OP_SELLSTOP,(LotSize*HedgingLotSizeMultiplier),Bid-(pips*OrderOpenLevel),3,Bid+(StopLoss*pips),Bid-(pips*TakeProfit),NULL,1,ExpirationTime,Green);
             }}}
   
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()>0 && TrailingStop>0 && TrailingStopLoss==true && MinBuy>MinBuyLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()<0 && TrailingStop>0 && TrailingStopLoss==true && MinSell>MinSellLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
//----
   return(0);
  }
//+------------------------------------------------------------------+

Hi Elliot and thanks for testing my EA. I will test these inputs out and see what results I get from backtesting. I am having difficulty with my backtesting because of inconsistent data so I am currently trying to find a solution to this problem before continuing any kind of backtesting. I will keep you posted on my progress.


Good luck and happy trading!

 
Elliott_Trader:

Hi,

Good pacofflin, nice and unversal EA,

I do filter the codes, and here under the modivied 4H TFrame

//+------------------------------------------------------------------+
//|                                                        TK EA.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "P.A.Cofflin"
#property link  "p.a.cofflin@gmail.com"
extern string email = "Email me if you want me to check your inputs or just to share :)";
extern string emailaddress = "p.a.cofflin@gmail.com";
extern string OrderSetup = "Order Setup";
extern double MaxLotSize = 200;
extern double MinLotSize = 0.01;
extern double MaxOrders = 1;
extern double OrderExpirationTimer = 7200;
extern double AcountBalanceUsedPercent = 10;
extern double OrderOpenLevel = 10;
extern double Slippage = 3;
extern double TakeProfit = 230;
extern double StopLoss = 180;
extern string space1 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string HedgingOption = "Option to place sell order when buying";
extern bool Hedging = true;
extern string HedgingMultiplier = "The option to change lot size of hedge order";
extern double HedgingLotSizeMultiplier= 1.5;
extern string space2 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string MinimumMultiplier = "Minimum for an order to be closed";
extern double MinimumStopLossMultiplier = 10;
extern double MinimumTakeProfitMultiplier = 10;
extern string space3 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string StopLossTakeProfit = "Following section for different order close options";
extern string TrailingStopandStep = "Sets a trailing stop and step ammount that follows the stop";
extern bool TrailingStopLoss = false;
extern double TrailingStop = 75;
extern double TrailingStep = 5;
extern string PercentageClose = "Sets a percentage to close an order based on Account Equity";
extern bool PercentageStopLoss = false;
extern double AccountPercentageStopLoss = 10;
extern bool PercentageTakeProfit = 0;
extern double AccountPercentageTakeProfit = 10;
extern string CloseTimer = "Closes a trade after a specified amount of seconds";
extern bool StopLossTimer = false;
extern double TimedStopLoss = 7200;
extern bool TakeProfitTimer = false;
extern double TimedTakeProfit = 7200;
extern string StochasticClose = "Closes order after Kperiod crosses Dperiod";
extern bool StochasticTakeProfit = true;
extern double KperiodTakeProfit = 200;
extern double DperiodTakeProfit = 55;
extern double SlowingTakeProfit = 3;
extern bool StochasticStopLoss = false;
extern double KperiodStopLoss = 20;
extern double DperiodStopLoss = 15;
extern double SlowingStopLoss = 3;
extern string space4 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string OrderModifiers = "The following modify an order to minimize loss potential";
extern string PercentChange = "Checks if a certain percentage change has occured"; 
extern bool StochasticPercentChange = false;
extern double StochasticPercentChangeLevel = 1;
extern string TradeLimiter = "Prevents orders two bars above stochastic crossing";
extern bool StochasticTradeLimiter = false;
extern double KperiodLimiter = 20;
extern double DperiodLimiter = 5;
extern double SlowingLimiter = 3;
extern string space5 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
extern string Indicators = "Choose which indicators and parameters to use";
extern bool StochasticBuy = true;
extern double StocOverSoldLevel = 20;
extern double Kperiod = 20;
extern double Dperiod = 5;
extern double Slowing = 3;
extern string MACross = "Moving average crossing buy signal";
extern bool MACrossBuy = false;
extern double SlowMAperiod = 20;
extern double FastMAperiod = 10;
extern string MACDBuySignal = "Buy signal when signal line goes below MACD level";
extern bool MACDBuy = false;
extern double FastEMA = 5;
extern double SlowEMA = 15;
extern double SMA = 2;
extern string VolumeSignal = "Buy signal of two increasing volumes and minimum volume level required for buy signal"; 
extern bool VolumeBuy = false;
extern double VolumeMinimumLevel = 200;
extern string RSISignal = "Buy when fast RSI crosses above slow RSI";
extern bool RSIBuy = false;
extern double FastRSI = 13;
extern double SlowRSI = 26;
bool Buy = false;
bool Sell = false;
extern int MagicNumber = 1;
double pips;  
void MoveTrailingStop()
{int cnt,total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol())
      {if(OrderType()==OP_BUY)
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(Bid-Point*(TrailingStop+TrailingStep),Digits))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-Point*TrailingStop,Digits),OrderTakeProfit(),0,Green);
                  return(0);}}}
         else 
         {if(TrailingStop>0)  
            {if((NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+Point*(TrailingStop+TrailingStep),Digits)))||(OrderStopLoss()==0))
               {OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+Point*TrailingStop,Digits),OrderTakeProfit(),0,Red);
                  return(0);}}}}}}
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   double ticksize = MarketInfo(Symbol(),MODE_TICKSIZE);
   if (ticksize == 0.00001 || ticksize == 0.001)
   pips = ticksize*10;
   else pips = ticksize;
   
   // Thanks to Jimdandy1958, his youtube tutorials taught me how to code mql4. Check out his tutorials at https://www.youtube.com/watch?v=n8fZINmSv0g.
   // Also check out his websites http://www.jimdandyforex.com and http://jimdandymql4courses.com.
   
 
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
int i=0; 
//
double CurrentStochasticKperiod = iStochastic (NULL,0,Kperiod,Dperiod,Slowing,3,1,0,0);
double FirstStochasticKperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1);
double SecondStochasticKperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2);
double CurrentStochasticDperiod = iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,0);
double FirstStochasticDperiod =   iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,1);
double SecondStochasticDperiod =  iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,1,2);
//
//
double FirstStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,1);
double SecondStochasticLimiterKperiod = iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,0,2);
double FirstStochasticLimiterDperiod =   iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,1);
double SecondStochasticLimiterDperiod =  iStochastic(NULL,0,KperiodLimiter,DperiodLimiter,SlowingLimiter,3,1,1,2);
//
//
double FirstStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,1);
double SecondStochasticSLKperiod = iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,0,2);
double FirstStochasticSLDperiod =   iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,1);
double SecondStochasticSLDperiod =  iStochastic(NULL,0,KperiodStopLoss,DperiodStopLoss,SlowingStopLoss,3,1,1,2);
//
//
double FirstStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,1);
double SecondStochasticTPKperiod = iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,0,2);
double FirstStochasticTPDperiod =   iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,1);
double SecondStochasticTPDperiod =  iStochastic(NULL,0,KperiodTakeProfit,DperiodTakeProfit,SlowingTakeProfit,3,1,1,2);
//
double SBS = (iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,1) - iStochastic(NULL,0,Kperiod,Dperiod,Slowing,3,1,0,2));
double FirstMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,1);
double SecondMACDBuy = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,0,2);
double FirstMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,1);
double SecondMACDBuySignalLine = iMACD(NULL,0,FastEMA,SlowEMA,SMA,6,1,2);
double FirstVolumeBuy = iVolume(NULL,0,1);
double SecondVolumeBuy = iVolume(NULL,0,2);
double FastRSIOne = iRSI(NULL,0,FastRSI,6,1);
double SlowRSIOne = iRSI(NULL,0,SlowRSI,6,1);
double LotSize = (AccountEquity()*(AcountBalanceUsedPercent/100))/1000; 
if (LotSize>MaxLotSize) LotSize = MaxLotSize;
if (LotSize<MinLotSize) LotSize = MinLotSize;
double CurrentLow = iLow(NULL,0,0);
double BuyLowOne = iLow(NULL,0,1);
double BuyLowTwo = iLow(NULL,0,2);
double BuyLowThree = iLow(NULL,0,3);
double BuyLowFour = iLow(NULL,0,4);
double CurrentSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,0);
double FirstSlowMA = iMA(NULL,0,SlowMAperiod,0,3,6,1);
double CurrentFastMA = iMA(NULL,0,FastMAperiod,0,3,6,0);
double FirstFastMA = iMA(NULL,0,FastMAperiod,0,3,6,1);
double ExpirationTime = TimeCurrent()+OrderExpirationTimer;
double CurrentClose = iClose(NULL,0,0);
double CloseOne =     iClose(NULL,0,1);
double CurrentOpen = iOpen(NULL,0,0);
double CurrentBuySignal = (iClose(NULL,0,0)-iOpen(NULL,0,0));
double BuySignal = (iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalTwo = (iClose(NULL,0,2)-iOpen(NULL,0,2));
double BuySignalThree = (iClose(NULL,0,3)-iOpen(NULL,0,3));
double CurrentCOMinus = MathAbs(iClose(NULL,0,0)-iOpen(NULL,0,0));
double COMinus = MathAbs(iClose(NULL,0,1)-iOpen(NULL,0,1));
double BuySignalAverage = MathAbs((BuySignal+BuySignalTwo+BuySignalThree)/3);
double MinSell = MathAbs((OrderOpenPrice()-Ask));
double Minsell = MathAbs((Bid-OrderOpenPrice()));
double MinSellLevel = (pips*MinimumStopLossMultiplier);
double MinBuy = MathAbs((OrderOpenPrice()-Ask));
double Minbuy = MathAbs((Bid-OrderOpenPrice()));
double MinBuyLevel = (pips*MinimumTakeProfitMultiplier);
bool RSIBuySignal = FastRSIOne>SlowRSIOne;
bool VolumeMinimum = FirstVolumeBuy>VolumeMinimumLevel;
bool VolumeBuySignal = FirstVolumeBuy>SecondVolumeBuy;
bool MACDBuySignalOne = FirstMACDBuy>FirstMACDBuySignalLine;
bool MACDBuySignalTwo = SecondMACDBuy<FirstMACDBuy;
bool StochasticBuyOne= FirstStochasticLimiterKperiod>FirstStochasticLimiterDperiod;
bool StochasticBuyTwo = SecondStochasticLimiterKperiod>SecondStochasticLimiterDperiod;
bool StochasticBuySignal = FirstStochasticDperiod<FirstStochasticKperiod;
bool StochasticOverSold = FirstStochasticKperiod<StocOverSoldLevel;
bool MACrossBuySignal = CurrentFastMA>CurrentSlowMA;
bool SBSone = SBS>StochasticPercentChangeLevel;
if(OrdersTotal()>=0 && RSIBuy==true) 
  {if(RSIBuySignal==true) Buy=true;
  {if(RSIBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && VolumeBuy==true) 
  {if(VolumeBuySignal==true && VolumeMinimum==true) Buy=true;
  {if(VolumeMinimum==false) Buy=false;
  {if(VolumeBuySignal==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && MACDBuy==true) 
  {if(MACDBuySignalOne==true && MACDBuySignalTwo==true) Buy=true;
  {if(MACDBuySignalOne==false) Buy=false;
  {if(MACDBuySignalTwo==false) Buy=false;
  }}}
if(OrdersTotal()>=0 && StochasticPercentChange==true) 
  {if(SBSone==true) Buy=true;
  {if(SBSone==false) Buy=false;
  }}
if(OrdersTotal()>=0 && MACrossBuy==true) 
  {if(MACrossBuySignal==true) Buy=true;
  {if(MACrossBuySignal==false) Buy=false;
  }}
if(OrdersTotal()>=0 && StochasticBuy==true) 
  {if(StochasticBuySignal==true && StochasticOverSold==true) Buy=true;
  {if(StochasticBuySignal==false) Buy=false;
  {if(StochasticOverSold==false) Buy=false;
  }}}
   
if(OrdersTotal()>=0 && StochasticTradeLimiter==true) 
  {if(StochasticBuyOne==true) Buy=true;
  {if(StochasticBuyOne==true && StochasticBuyTwo==true) Buy=false;
  }}
   
   
      if(OrdersTotal()<MaxOrders && Buy==true)
      OrderSend(Symbol(),OP_BUYSTOP,LotSize,Ask+(pips*OrderOpenLevel),3,Ask-(StopLoss*pips),Ask+(pips*TakeProfit),NULL,MagicNumber,ExpirationTime,Green);
      
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountBalance()>(AccountEquity()*(1+((AccountPercentageStopLoss*LotSize)/100))) && PercentageStopLoss==true && MinSell>MinSellLevel)
            {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage ); 
            else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Stop Loss Close");}}}
             
            
        {for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(AccountEquity()>(AccountBalance()*(1+((AccountPercentageTakeProfit*LotSize)/100))) && PercentageTakeProfit==true && MinBuy>MinBuyLevel)
            {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
             OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
            else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
             OrderClose( OrderTicket(), OrderLots(), Ask, Slippage );
             Print("Account Percentage Take Profit Close");}}}
             
        {for(int i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedStopLoss) < TimeCurrent() && StopLossTimer==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Stop Loss Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if( (OrderOpenTime() + TimedTakeProfit) < TimeCurrent() && TakeProfitTimer==true && OrderProfit()>=MinBuyLevel && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Timed Take Profit Close");}}}
                
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticSLKperiod<FirstStochasticSLDperiod) && StochasticStopLoss==true && OrderProfit()<=MinBuyLevel && MinSell>MinSellLevel)
               {if( OrderType() == OP_BUY && Bid < OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask > OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Stop Loss Close");}}}
        {for(i2 = 0 ; i2 < OrdersTotal() ; i2++ ) 
         {if( OrderSelect( i2, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
            if((FirstStochasticTPKperiod<FirstStochasticTPDperiod) && OrderProfit()>0 && StochasticTakeProfit==true && MinBuy>MinBuyLevel)
               {if( OrderType() == OP_BUY && Bid > OrderOpenPrice()) 
                OrderClose( OrderTicket(), OrderLots(), Bid, Slippage); 
               else if( OrderType() == OP_SELL && Ask < OrderOpenPrice())
                OrderClose( OrderTicket(), OrderLots(), Ask, Slippage);
                Print("Stochastic Take Profit Close");}}}
                
   {for( int i3 = 0 ; i3 < OrdersTotal() ; i3++ ) 
         {if( OrderSelect( i3, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
             {if(OrdersTotal()<=(MaxOrders) && OrdersTotal()>0 && OrderType()==OP_BUY && Hedging==true)
              OrderSend(Symbol(),OP_SELLSTOP,(LotSize*HedgingLotSizeMultiplier),Bid-(pips*OrderOpenLevel),3,Bid+(StopLoss*pips),Bid-(pips*TakeProfit),NULL,1,ExpirationTime,Green);
             }}}
   
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()>0 && TrailingStop>0 && TrailingStopLoss==true && MinBuy>MinBuyLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
{for(i = 0 ; i < OrdersTotal() ; i++ ) 
         {if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; 
          if(OrderProfit()<0 && TrailingStop>0 && TrailingStopLoss==true && MinSell>MinSellLevel)
            {MoveTrailingStop();
            Print("Trailing Stop");}}}
//----
   return(0);
  }
//+------------------------------------------------------------------+

Hi Elliot and thanks for testing my EA. I will test these inputs out and see what results I get from backtesting. I am having difficulty with my backtesting because of inconsistent data so I am currently trying to find a solution to this problem before continuing any kind of backtesting. I will keep you posted on my progress.


Good luck and happy trading!

 
3rjfx:
Is this EA has been tested on a demo account or Strategy Tester? What about the test results?

Hello 3rjfx you are right, when I first wrote the code 0 worked in place of NULL and since it was much easier to write I used it for all of my signals. I have updated the code so please redownload the Universal EA for the most up to date version. I don't have any test results because I made the EA to be changeable to most any strategy that you can conceive. If you have any other questions or comments then feel free to ask.


Good luck and happy trading!

 

For everyone wondering I did replace all of the 0s with NULL and reuploaded the EA so feel free to redownload it and get to back testing.


Good luck and happy trading!

 

hi...

great ea btw. can u add trading time?

 

Hi Patrick,


Ive just found you indicator this week and had some success with using it.   However,   I can choose which indicator I want to use separately but I cant combine any?    any updates at all?


thanks in advance.


Regards,


Stuart

 

I need an EA based on the "DSP Oscilator"

A buy signal is generated when the signal line turns green.

The buy signal is closed when the signal line turns yellow.

A sell signal arises at "red" and closes again at "yellow".

Who can help me?

greeting

Johann Willms


 
johann.w:

This is an English language forum.

Please only post in English.

Use the site's translation tool if necessary.

I have used the tool to edit and translate your post.