Simple experts - page 24

 
traderduke:

mntiwana

Check my latest comment for your answer. I'll see if I can add it to your EA. Some times the Reentry can turn a loser into a winner and a small winner into a big winner.

Best of luck

Ray


Hi traderduke

Thanks for your consideration,really i am keen interested to have complete this EA with as much possible trade controlling options and accessories/features and i see your code with fantastic MM options,but honestly i can not add/remove any digit of code because of my zero coding knowledge :)

if you kindly do it for me it will be a great help to me ..... as for re entering in current trend,i think it will be an extra option,of course with true/false,with a condition if previous bar(currently close Nbar is same according to trend,for example if we are in up trend (buy) Nbar should be of up trend color and if Nbar is of opposite color,let EA to wait till any next Nbar will be of up trend color (bar in the past to take in consideration for the signal).

i noticed no spread control snippet in your code and no option for test bar,test bar means how many bars to wait/test for opening a order,usually minimum 1 bar is used.and later we will be add some filter as confirmation for  buy/sell signaling condition,that can be of any reliable kind (cci,stoch,adx or any thing)

here is the re entering code part from your EA but i don't know which line to add and where,and which part of code/lines delete from previous code.

the lower code part is error function.

regards
void ReadIndicatorValues()
{                         //Indic_Name = "ema (r-squared) adaptive (experiment) 1.3"; Buffer10 can equal 0(range) or 1(up) or -1(Dwn)
  trend    = iCustom(NULL,0,Indic_Name,0,Emaperiod, Pricetouse, Doublesmoothed, Filtertouse, FilterPeriodtouse, ApplyFilterto, 10,0);
  trend1   = iCustom(NULL,0,Indic_Name,0,Emaperiod, Pricetouse, Doublesmoothed, Filtertouse, FilterPeriodtouse, ApplyFilterto, 10,1);
  trend2   = iCustom(NULL,0,Indic_Name,0,Emaperiod, Pricetouse, Doublesmoothed, Filtertouse, FilterPeriodtouse, ApplyFilterto, 10,2);  
  
                          //Indic_Name1 = "ema (r-squared) adaptive (experiment) 1.3" Buffer10 can equal 0(range) or 1(up) or -1(Dwn)
  trendre  = iCustom(NULL,0,Indic_Name1,0,Emaperiodre,Pricetousere,Doublesmoothedre,Filtertousere,FilterPeriodtousere,ApplyFiltertore,10,0);
  trendre1 = iCustom(NULL,0,Indic_Name1,0,Emaperiodre,Pricetousere,Doublesmoothedre,Filtertousere,FilterPeriodtousere,ApplyFiltertore,10,1);
  trendre2 = iCustom(NULL,0,Indic_Name1,0,Emaperiodre,Pricetousere,Doublesmoothedre,Filtertousere,FilterPeriodtousere,ApplyFiltertore,10,2);
  
}

bool BuySignal()
{
     ReadIndicatorValues();
     if(RevTrd)  
     {
     if ( trend == 1 && trend1 == 1 && (trend2 == -1 || trend2 == 0)
     && TimeCondition()) return(true);  return(false);
     }
     if(!RevTrd)
     {
     if ( trend == 1 && trend1 == 1
     && TimeCondition()) return(true);  return(false);
     }
return(0);
}  

bool BuySignalReentry()
{
     ReadIndicatorValues();
     if(UseReentry)
     {if(trend1 == 1 &&          
     (trendre1 == 1 && trendre2 == -1)
     && TimeCondition()) return(true);  return(false);
     }
return(0);
}  

bool SellSignal()
{
     ReadIndicatorValues();
     if(RevTrd)  
     {if ( trend == -1 && trend1 == -1 && (trend2 == 1 || trend2 == 0)
     && TimeCondition()) return(true);  return(false);
     }
     if(!RevTrd)
     {
     if ( trend == -1 && trend1 == -1
     && TimeCondition()) return(true);  return(false);
     }
return(0);
}

bool SellSignalReentry()
{
     ReadIndicatorValues();
     if(UseReentry)
     { if(trend1 == -1 &&
      trendre1 == -1 && trendre2 == 1
      && TimeCondition()) return(true);  return(false);
      }
return(0);
}  

bool BuyExitSignal()
{
     ReadIndicatorValues();
     if (( ExitMode ==0 && (OrderType()==OP_BUY) &&
     (trend1 == -1 || trend1 == 0)
      ) || !TimeCondition()) return(true);  return(false);
}
bool SellExitSignal()
{
     ReadIndicatorValues();
     if ((ExitMode ==0 && (OrderType()==OP_SELL) &&
     (trend1 == 1 || trend1 == 0)
      ) || !TimeCondition()) return(true);  return(false);
}

int start()
{
    // Only run once per completed bar L-118
    
     if(timeprev==Time[0]) return(0);
     timeprev = Time[0];
  
//+------------------------------------------------------------------+
//| Check for Open Position                                          |
//+------------------------------------------------------------------+
  
  HandleOpenPositions();
  
//+------------------------------------------------------------------+
//| Check if OK to make new trades                                   |
//+------------------------------------------------------------------+
    
if (TimeCondition()&& DaySelection())
   {

// Only allow 1 trade per Symbol
  if (CheckOpenPositions() > 0 &&  !UseReentry) return(0);  
  //if (CheckOpenPositions() > 0 && ((!RevTrd || RevTrd) && !UseReentry)) return(0);
  //if (CheckOpenPositions() > Reentrytrades && ((!RevTrd || RevTrd) && UseReentry) ) return(0);
  if (CheckOpenPositions() > Reentrytrades  ) return(0);  
    lotMM = GetLots();
  
   if( BuySignal()|| BuySignalReentry()) //&& Close[1] > upper)  
      {
             OpenBuyOrder();
         return(0);
      }
    
      if(SellSignal() || SellSignalReentry()) //&& Close[1] < lower)
      {
      OpenSellOrder();
      }
      return(0);
  }
return (0);
}

//+----------------------------------------------------------------------------+
//|  Error functions                                                           |
//+----------------------------------------------------------------------------+

string errordescription(int code){
   string error;
   switch(code){
      case 0:
      case 1:error="no error";break;
      case 2:error="common error";break;
      case 3:error="invalid trade parameters";break;
      case 4:error="trade server is busy";break;
      case 5:error="old version of the client terminal";break;
      case 6:error="no connection with trade server";break;
      case 7:error="not enough rights";break;
      case 8:error="too frequent requests";break;
      case 9:error="malfunctional trade operation";break;
      case 64:error="account disabled";break;
      case 65:error="invalid account";break;
      case 128:error="trade timeout";break;
      case 129:error="invalid price";break;
      case 130:error="invalid stops";break;
      case 131:error="invalid trade volume";break;
      case 132:error="market is closed";break;
      case 133:error="trade is disabled";break;
      case 134:error="not enough money";break;
      case 135:error="price changed";break;
      case 136:error="off quotes";break;
      case 137:error="broker is busy";break;
      case 138:error="requote";break;
      case 139:error="order is locked";break;
      case 140:error="long positions only allowed";break;
      case 141:error="too many requests";break;
      case 145:error="modification denied because order too close to market";break;
      case 146:error="trade context is busy";break;
      case 4000:error="no error";break;
      case 4001:error="wrong function pointer";break;
      case 4002:error="array index is out of range";break;
      case 4003:error="no memory for function call stack";break;
      case 4004:error="recursive stack overflow";break;
      case 4005:error="not enough stack for parameter";break;
      case 4006:error="no memory for parameter string";break;
      case 4007:error="no memory for temp string";break;
      case 4008:error="not initialized string";break;
      case 4009:error="not initialized string in array";break;
      case 4010:error="no memory for array\' string";break;
      case 4011:error="too long string";break;
      case 4012:error="remainder from zero divide";break;
      case 4013:error="zero divide";break;
      case 4014:error="unknown command";break;
      case 4015:error="wrong jump (never generated error)";break;
      case 4016:error="not initialized array";break;
      case 4017:error="dll calls are not allowed";break;
      case 4018:error="cannot load library";break;
      case 4019:error="cannot call function";break;
      case 4020:error="expert function calls are not allowed";break;
      case 4021:error="not enough memory for temp string returned from function";break;
      case 4022:error="system is busy (never generated error)";break;
      case 4050:error="invalid function parameters count";break;
      case 4051:error="invalid function parameter value";break;
      case 4052:error="string function internal error";break;
      case 4053:error="some array error";break;
      case 4054:error="incorrect series array using";break;
      case 4055:error="custom indicator error";break;
      case 4056:error="arrays are incompatible";break;
      case 4057:error="global variables processing error";break;
      case 4058:error="global variable not found";break;
      case 4059:error="function is not allowed in testing mode";break;
      case 4060:error="function is not confirmed";break;
      case 4061:error="send mail error";break;
      case 4062:error="string parameter expected";break;
      case 4063:error="integer parameter expected";break;
      case 4064:error="double parameter expected";break;
      case 4065:error="array as parameter expected";break;
      case 4066:error="requested history data in update state";break;
      case 4099:error="end of file";break;
      case 4100:error="some file error";break;
      case 4101:error="wrong file name";break;
      case 4102:error="too many opened files";break;
      case 4103:error="cannot open file";break;
      case 4104:error="incompatible access to a file";break;
      case 4105:error="no order selected";break;
      case 4106:error="unknown symbol";break;
      case 4107:error="invalid price parameter for trade function";break;
      case 4108:error="invalid ticket";break;
      case 4109:error="trade is not allowed";break;
      case 4110:error="longs are not allowed";break;
      case 4111:error="shorts are not allowed";break;
      case 4200:error="object is already exist";break;
      case 4201:error="unknown object property";break;
      case 4202:error="object is not exist";break;
      case 4203:error="unknown object type";break;
      case 4204:error="no object name";break;
      case 4205:error="object coordinates error";break;
      case 4206:error="no specified subwindow";break;
      default:error="unknown error";
   }
   return(error);
 
mladen:

Ray

That indicator has period for first parameter (there is no time frame - I assume that 0 is for time frame - as first parameter)

mladen

Sometimes I can't believe my own Blindness, can't see the forest for the trees.

Thank you, I apologize, that question should have never been asked.

Ray

 

I agree with Pava in post 227. So I have an idea for a simple EA that would eliminate TP, SL Trailing. I have been trading this manually for several months and it is profitable. As an EA this should be even more profitable.

Two MAs. one fast and the other slower. The slow one would control direction. The fast one would be the trigger.  The trigger needs to occur when the fast MA turns direction, when that direction agrees with the slow MA. All trades close when the slow MA changes directions.

I have seen some MAs based on a single MA change direction, but then all these extra parameters are added to control the trade. The difficulty seems in being able to set the trigger at the candle when direction changes. Most EAs change 2-3 bars after the direction change.

What I have been using in manual trading is HMA set to period 2-5 as fast MA and the  "absolutely no lag lwma" (which actually does have lag) set to period of 13 as slow MA. I usually trad on H4 but sometimes move to 1H.

Can any of you superb programmers make an EA from this? I have tried studying MTL but do not understand well enough to do this. 

 
shockr:

I agree with Pava in post 227. So I have an idea for a simple EA that would eliminate TP, SL Trailing. I have been trading this manually for several months and it is profitable. As an EA this should be even more profitable.

Two MAs. one fast and the other slower. The slow one would control direction. The fast one would be the trigger.  The trigger needs to occur when the fast MA turns direction, when that direction agrees with the slow MA. All trades close when the slow MA changes directions.

I have seen some MAs based on a single MA change direction, but then all these extra parameters are added to control the trade. The difficulty seems in being able to set the trigger at the candle when direction changes. Most EAs change 2-3 bars after the direction change.

What I have been using in manual trading is HMA set to period 2-5 as fast MA and the  "absolutely no lag lwma" (which actually does have lag) set to period of 13 as slow MA. I usually trad on H4 but sometimes move to 1H.

Can any of you superb programmers make an EA from this? I have tried studying MTL but do not understand well enough to do this. 

"Absolutely no lag lwma" was made by me as a joke to show how easy is to make a perfect repainter, and it repaints
 
mladen:

Here is this EA (from the series of "simple" experts) that has added control not to allow an order to be opened on a same bar on which another order from that same EA has been closed. It checks if the order closed on the same bar is the same type as the type that should be opened, and if it is, it prevents opening a new order. Order in an opposite direction than the direction of a new order does not prevent opening a new order

Hi mladen

What is the setting " Divisor for Hull variation (2->Original hull average) " ?  What function does it perform?

Thanks 

Files:
hull input.PNG  21 kb
 
slatusman:

Hi mladen

What is the setting " Divisor for Hull variation (2->Original hull average) " ?  What function does it perform?

Thanks 

That is actually calculating a variation of hull average. If you use 2, then it is the same as the original Hull
 
mladen:
That is actually calculating a variation of hull average. If you use 2, then it is the same as the original Hull
I want to plot the hullma on the chart. I found a mt5 indi you made. If you could create a mt4 version that would be fabulous. 
 
slatusman:
I want to plot the hullma on the chart. I found a mt5 indi you made. If you could create a mt4 version that would be fabulous. 
Any hull ma is plotted on the chart.
 
mladen:
"Absolutely no lag lwma" was made by me as a joke to show how easy is to make a perfect repainter, and it repaints

That's funny! When I first saw it I had to try it. But it has the curve that works for my manual trades.

Are you able to make an EA like what I mentioned above? Or is there already one that does what I want? 

ps. I am flexible about which MAs are used. Some of your MAs are great! Thank you. I appreciate your work.

 
oguz:

Dear @mladen,

"simple (stepma of rsi adaptive ema 2.9) EA" in the same direction trend, opens an average of 4 - 5 orders consecutively.

How do I get it to open a maximum of 1 or 2 orders in the same trend direction?

Is this possible? 

Explain with pictures,your setting and multiple taken trades.
Reason: