Need help with Halftrend & RSI scalping EA

 

Hello,

i'm new to Mql4 and although i have managed to create some basic algorithms for EAs, i am struggling with creating a particular EA for one of the strategies that i have been using for a couple months. You can find the basis of the strategy in this video: 

86% Win Rate Highly Profitable Secret Strategy | RSI + Secret Indicator


The code that i have written up till now is as below:

extern int StopLoss = 10;
extern double Lots = 0.2;

extern double RSIHigh = 90.0;
extern double RSILow = 10.0;


void OnTick()
  {
   
   //Empty string for signal
   string signal="";
   
   //Creating ATR for Halftrend and the 10-90 RSI for Overbought/Oversold conditions
      double HalfTrend = iCustom(NULL, 0, "half-trend", 2, 0, 0);
      double RSIValue = iRSI(Symbol(), Period(), 2, PRICE_CLOSE, 0);
  
  //Buy Conditions
     if (PRICE_OPEN > HalfTrend && RSIValue < RSILow && PRICE_OPEN > Close[1]) {
          
            signal="BUY"; 
            }
  //Sell Conditions
     if (PRICE_OPEN < HalfTrend && RSIValue > RSIHigh && PRICE_OPEN < Close[1]){
        
            signal="SELL";
            }
            
  //Positions will be opened when there are no open trades
   if(signal=="BUY" && OrdersTotal()==0)
     {
      OrderSend(_Symbol, OP_BUY, Lots, Ask, 0, Low[1]-StopLoss, 2*(Low[1]-StopLoss), NULL, 0, 0, Green);
      //Even though a TP had been set, we need to also close the order at the other end of the close of RSI
          //Needs OrderClose here!!
     }
   if(signal=="SELL" && OrdersTotal()==0)
     {
      OrderSend(_Symbol, OP_SELL, Lots, Bid, 0, High[1]+StopLoss, 2*(High[1]+StopLoss), NULL, 0, 0, Red);   
           //Needs OrderClose here too!!
     }          
   
}


It does not show any error when compiling but when i try in on the Back Tester, it opens no trades whatsoever. 

The issues i think this one has:

1-) I'm trying to add a Stop Loss 1 pip below the low of the last candle. But i'm not sure if the "Low[1]-StopLoss" section in OrderSend is the right way to go. I guess Take Profit value has the same issue as well.

2-) I think there's a mistake with BUY and SELL conditions too. For BUY condition i have tried with "if (PRICE_OPEN > HalfTrend) {" and "if (Open[0] > HalfTrend) {" both to no avail.


Any help or suggestions would be greatly appreciated.

 
SeferAmcaFTW:

Hello,

i'm new to Mql4 and although i have managed to create some basic algorithms for EAs, i am struggling with creating a particular EA for one of the strategies that i have been using for a couple months. You can find the basis of the strategy in this video: 

86% Win Rate Highly Profitable Secret Strategy | RSI + Secret Indicator


The code that i have written up till now is as below:


It does not show any error when compiling but when i try in on the Back Tester, it opens no trades whatsoever. 

The issues i think this one has:

1-) I'm trying to add a Stop Loss 1 pip below the low of the last candle. But i'm not sure if the "Low[1]-StopLoss" section in OrderSend is the right way to go. I guess Take Profit value has the same issue as well.

2-) I think there's a mistake with BUY and SELL conditions too. For BUY condition i have tried with "if (PRICE_OPEN > HalfTrend) {" and "if (Open[0] > HalfTrend) {" both to no avail.


Any help or suggestions would be greatly appreciated.

Well a lot of things needs to be corrected but for start

PRICE_OPEN is an enumeration. It doesn't hold the price data for bar open.

Use

Open[0]  // Current bar open

You would also need to get the trend value of the half trend indicator to identify up trend and down trend.

So the logic can be 

 if(half trend==upTrendVal && rsiPreviousBar<10 && closeCurrentBar>previousHigh)
  // Buy order

  // Opposite for sell order
 
Navdeep Singh #:


You would also need to get the trend value of the half trend indicator to identify up trend and down trend.


I thought "double HalfTrend" already gives the value of the Half-Trend indicator. Do i need to add a buffer for that? 

Reason: