Experts: NirvamanImax - page 3

 
Hubexde:
//+------------------------------------------------------------------+
//|                                 NirvamanImax.mq4                 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Gabriel Jaime Mejía Arbelaez"
#property link      "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//|                                                   e-Trailing.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|***   Trailing-Stop   ***                                         |
//| 12.09.2005 Àâòîìàòè÷åñêèé Trailing Stop âñåõ îòêðûòûõ ïîçèöèé    |
//|            Âåøàòü òîëüêî íà îäèí ãðàôèê                          |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern bool   ProfitTrailing = True;  // Òðàëèòü òîëüêî ïðîôèò
extern int    TrailingStop   = 8;     // Ôèêñèðîâàííûé ðàçìåð òðàëà
extern int    TrailingStep   = 2;     // Øàã òðàëà
extern bool   UseSound       = True;  // Èñïîëüçîâàòü çâóêîâîé ñèãíàë
extern string NameFileSound  = "expert.wav";  // Íàèìåíîâàíèå çâóêîâîãî ôàéëà
//---- input parameters
extern double       lots = 0.1;
extern int          mn = 555;
static int          prevtime = 0;
extern double       tp = 100;
extern double       sl = 50;
extern double       periodos=13;
extern int          tiempoCierre=15000;
//extern int          TrailingStop=10;   //add
int StartHour=22;
int EndHour=2;
int BrokerTimeZone=0;
int start()
{
   if (Time[0] == prevtime) return(0);
   prevtime = Time[0];
   if (! IsTradeAllowed()) {
      again();
      return(0);
   }
   
   //----------------------------------------cerrando orden abierta despues de la primera barra
   
   
   int total = OrdersTotal();
   for (int i = 0; i < total; i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == mn)
      {
          if(TimeCurrent()-OrderOpenTime()>=tiempoCierre)
          {
             
              OrderClose(OrderTicket(),lots,MarketInfo(Symbol(),MODE_BID),3,GreenYellow);
          }
          else
          {
               return(0);
          }
      }
   }
  //----------------------------------------------------------------------------------------
   int ticket = -1;
   int perceptron = Supervisor();
   int ha=0;
   
   double buff0=0;
   double buff1=0;
   
  
   
   buff0=iCustom(NULL, 0, "HA",2,0);
   buff1=iCustom(NULL, 0, "HA",3,0);
   
   
   
   if(buff0>buff1)
    ha=-1;
   
   if(buff0<buff1)
    ha=1;
   //-----------------------------------------------------------------------------------------
   
   
    double  promedioEMA=iCustom(NULL, 0, "Moving Averages2",periodos,0,0);
   
   
   //----------------------------------------------------------No operar en este rango de horas
   int h=TimeHour(TimeCurrent()-BrokerTimeZone);
       
    if(!(h> StartHour && h<EndHour))
    {
    
    
     
   
   
   if ( perceptron > 0 && ha > 0 && Close[1]>promedioEMA) {
      ticket = OrderSend(Symbol(), OP_BUY, lots, Ask,2, Bid - sl * Point, Bid + tp * Point, WindowExpertName(), mn, 0, Blue);
      Alert("SEÑAL:"+Symbol());
      if (ticket < 0) {
         again();    
      }
   }
   if (perceptron < 0 && ha <0  && Close[1]<promedioEMA) {
      ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 2, Ask + sl * Point, Ask - tp * Point, WindowExpertName(), mn, 0, Red);
      Alert("SEÑAL:"+Symbol());
      if (ticket < 0) {
         again();
      }
   }   
   
   }
    
   return(0);
      
   //------------------------------------------------------------------------------                       
}
void again() {
   prevtime = Time[1];
   Sleep(30000);
}
/*+-------------------------------------------------------------------+
  | supervisor encargado de determinar si se hace long o short        |
  +-------------------------------------------------------------------+*/
double Supervisor()
{
    double iMAX0=iCustom(NULL, 0, "iMAX3alert1",4,0);
    double iMAX1=iCustom(NULL, 0, "iMAX3alert1",5,0);
    
    double iMAX01=iCustom(NULL, 0, "iMAX3alert1",4,1);
    double iMAX11=iCustom(NULL, 0, "iMAX3alert1",5,1);
    
    double b0=0;
    double b1=0;
    double r0=0;
    double r1=0;
    
    b0 = iMAX0;
    b1 = iMAX01;
    r0 = iMAX1;
    r1 = iMAX11;
    
    if(b0 > r0 && b1 < r1)
         return(1);
         
    if(b0 < r0 && b1 > r1)
         return(-1);   
    
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
if(OrderMagicNumber() == mn)
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      TrailingPositions();
    }
  }
}
//+------------------------------------------------------------------+
//| Ñîïðîâîæäåíèå ïîçèöèè ïðîñòûì òðàëîì                             |
//+------------------------------------------------------------------+
void TrailingPositions() {
  double pBid, pAsk, pp;
  pp = MarketInfo(OrderSymbol(), MODE_POINT);
  if (OrderType()==OP_BUY) {
    pBid = MarketInfo(OrderSymbol(), MODE_BID);
    if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
      if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
        ModifyStopLoss(pBid-TrailingStop*pp);
        return;
      }
    }
  }
  if (OrderType()==OP_SELL) {
    pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
    if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
      if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
        ModifyStopLoss(pAsk+TrailingStop*pp);
        return;
      }
    }
  }
}
//+------------------------------------------------------------------+
//| Ïåðåíîñ óðîâíÿ StopLoss                                          |
//| Ïàðàìåòðû:                                                       |
//|   ldStopLoss - óðîâåíü StopLoss                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss) {
  bool fm;
  fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
  if (fm && UseSound) PlaySound(NameFileSound);
}
//+------------------------------------------------------------------+
         
    
telerater
wrote:

Hello Nirvaman, I guess the idea of 'trailing stop' kind of appealed you. I hope you dont mind of my suggestions. Since trading at such a short period like M1, SL&TP has to be dynamic. As long as the entry points are 51 % positive than keeping loses at the min level is crutiualy important. As an example, after the entry point surfing at the positive side has to be ended definately with a result of plus. Either its 0 pip 1pip. While forwardtesting with your code, unfortunately, many time I have experienced trades that couple of times turned from plus to minus then plus again and 50% of time ended minus. For dynamic exiting appliying 20 LWMA (or EMA) Low and High both on the same chart and use long exit at cross of a 20 LWMA Low period, for the short exit at the cross of a 20 LWMA High period. Therefore, once we are at the positive territory depending on the slope (speed) after cople of munites trade becomes safe from minus result.For the profit target may be placed three choices depending on the trade period average of the optimized results. If you like we can discuss more over via mail.. thanks again in advance for your nice work and precious time.


Hubexde
wrote:

Hello, nirvaman, congratulation to your EA which handle with Laguerre Data Distribution. One question please: is it necessary to adjust some parameter of HA or imax3..? You wrote that you plan to put TS on the EA. That is a good idea. The list above listed

TrailingStop=40
TrailingStop,F=1
TrailingStop,1=0
TrailingStop,2=1
TrailingStop,3=50

but there ist no parameter entry in the EA. Can you please put in on?

When I think about popular Distributions of Data I found the Bernoulli Data Distribution. I will test to bring this concept to course moving.


Hello, Nirvaman, I tested your EA with trailingstop but it does not work. Therefore I put one functionable EA on it and you can see the result: during my testings I optimize the parameter and got a smaller profit but less risk. That I can see: optimizing for a small period will not give good results for long periods and vice versa. If we use TS and optimizing for a short period that can be one way ...

I enclose your EA with one TS: NirvamanImaxTS

thx. I dont have problems with that. excelent job. I think my trailing has lot of failures so yours will be a nice add to this code. i will try it

 
Hubexde:
//+------------------------------------------------------------------+
//|                                 NirvamanImax.mq4                 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Gabriel Jaime Mejía Arbelaez"
#property link      "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//|                                                   e-Trailing.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|***   Trailing-Stop   ***                                         |
//| 12.09.2005 Àâòîìàòè÷åñêèé Trailing Stop âñåõ îòêðûòûõ ïîçèöèé    |
//|            Âåøàòü òîëüêî íà îäèí ãðàôèê                          |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern bool   ProfitTrailing = True;  // Òðàëèòü òîëüêî ïðîôèò
extern int    TrailingStop   = 8;     // Ôèêñèðîâàííûé ðàçìåð òðàëà
extern int    TrailingStep   = 2;     // Øàã òðàëà
extern bool   UseSound       = True;  // Èñïîëüçîâàòü çâóêîâîé ñèãíàë
extern string NameFileSound  = "expert.wav";  // Íàèìåíîâàíèå çâóêîâîãî ôàéëà
//---- input parameters
extern double       lots = 0.1;
extern int          mn = 555;
static int          prevtime = 0;
extern double       tp = 100;
extern double       sl = 50;
extern double       periodos=13;
extern int          tiempoCierre=15000;
//extern int          TrailingStop=10;   //add
int StartHour=22;
int EndHour=2;
int BrokerTimeZone=0;
int start()
{
   if (Time[0] == prevtime) return(0);
   prevtime = Time[0];
   if (! IsTradeAllowed()) {
      again();
      return(0);
   }
   
   //----------------------------------------cerrando orden abierta despues de la primera barra
   
   
   int total = OrdersTotal();
   for (int i = 0; i < total; i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == mn)
      {
          if(TimeCurrent()-OrderOpenTime()>=tiempoCierre)
          {
             
              OrderClose(OrderTicket(),lots,MarketInfo(Symbol(),MODE_BID),3,GreenYellow);
          }
          else
          {
               return(0);
          }
      }
   }
  //----------------------------------------------------------------------------------------
   int ticket = -1;
   int perceptron = Supervisor();
   int ha=0;
   
   double buff0=0;
   double buff1=0;
   
  
   
   buff0=iCustom(NULL, 0, "HA",2,0);
   buff1=iCustom(NULL, 0, "HA",3,0);
   
   
   
   if(buff0>buff1)
    ha=-1;
   
   if(buff0<buff1)
    ha=1;
   //-----------------------------------------------------------------------------------------
   
   
    double  promedioEMA=iCustom(NULL, 0, "Moving Averages2",periodos,0,0);
   
   
   //----------------------------------------------------------No operar en este rango de horas
   int h=TimeHour(TimeCurrent()-BrokerTimeZone);
       
    if(!(h> StartHour && h<EndHour))
    {
    
    
     
   
   
   if ( perceptron > 0 && ha > 0 && Close[1]>promedioEMA) {
      ticket = OrderSend(Symbol(), OP_BUY, lots, Ask,2, Bid - sl * Point, Bid + tp * Point, WindowExpertName(), mn, 0, Blue);
      Alert("SEÑAL:"+Symbol());
      if (ticket < 0) {
         again();    
      }
   }
   if (perceptron < 0 && ha <0  && Close[1]<promedioEMA) {
      ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 2, Ask + sl * Point, Ask - tp * Point, WindowExpertName(), mn, 0, Red);
      Alert("SEÑAL:"+Symbol());
      if (ticket < 0) {
         again();
      }
   }   
   
   }
    
   return(0);
      
   //------------------------------------------------------------------------------                       
}
void again() {
   prevtime = Time[1];
   Sleep(30000);
}
/*+-------------------------------------------------------------------+
  | supervisor encargado de determinar si se hace long o short        |
  +-------------------------------------------------------------------+*/
double Supervisor()
{
    double iMAX0=iCustom(NULL, 0, "iMAX3alert1",4,0);
    double iMAX1=iCustom(NULL, 0, "iMAX3alert1",5,0);
    
    double iMAX01=iCustom(NULL, 0, "iMAX3alert1",4,1);
    double iMAX11=iCustom(NULL, 0, "iMAX3alert1",5,1);
    
    double b0=0;
    double b1=0;
    double r0=0;
    double r1=0;
    
    b0 = iMAX0;
    b1 = iMAX01;
    r0 = iMAX1;
    r1 = iMAX11;
    
    if(b0 > r0 && b1 < r1)
         return(1);
         
    if(b0 < r0 && b1 > r1)
         return(-1);   
    
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
if(OrderMagicNumber() == mn)
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      TrailingPositions();
    }
  }
}
//+------------------------------------------------------------------+
//| Ñîïðîâîæäåíèå ïîçèöèè ïðîñòûì òðàëîì                             |
//+------------------------------------------------------------------+
void TrailingPositions() {
  double pBid, pAsk, pp;
  pp = MarketInfo(OrderSymbol(), MODE_POINT);
  if (OrderType()==OP_BUY) {
    pBid = MarketInfo(OrderSymbol(), MODE_BID);
    if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
      if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
        ModifyStopLoss(pBid-TrailingStop*pp);
        return;
      }
    }
  }
  if (OrderType()==OP_SELL) {
    pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
    if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
      if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
        ModifyStopLoss(pAsk+TrailingStop*pp);
        return;
      }
    }
  }
}
//+------------------------------------------------------------------+
//| Ïåðåíîñ óðîâíÿ StopLoss                                          |
//| Ïàðàìåòðû:                                                       |
//|   ldStopLoss - óðîâåíü StopLoss                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss) {
  bool fm;
  fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
  if (fm && UseSound) PlaySound(NameFileSound);
}
//+------------------------------------------------------------------+
         
    
telerater
wrote:

Hello Nirvaman, I guess the idea of 'trailing stop' kind of appealed you. I hope you dont mind of my suggestions. Since trading at such a short period like M1, SL&TP has to be dynamic. As long as the entry points are 51 % positive than keeping loses at the min level is crutiualy important. As an example, after the entry point surfing at the positive side has to be ended definately with a result of plus. Either its 0 pip 1pip. While forwardtesting with your code, unfortunately, many time I have experienced trades that couple of times turned from plus to minus then plus again and 50% of time ended minus. For dynamic exiting appliying 20 LWMA (or EMA) Low and High both on the same chart and use long exit at cross of a 20 LWMA Low period, for the short exit at the cross of a 20 LWMA High period. Therefore, once we are at the positive territory depending on the slope (speed) after cople of munites trade becomes safe from minus result.For the profit target may be placed three choices depending on the trade period average of the optimized results. If you like we can discuss more over via mail.. thanks again in advance for your nice work and precious time.


Hubexde
wrote:

Hello, nirvaman, congratulation to your EA which handle with Laguerre Data Distribution. One question please: is it necessary to adjust some parameter of HA or imax3..? You wrote that you plan to put TS on the EA. That is a good idea. The list above listed

TrailingStop=40
TrailingStop,F=1
TrailingStop,1=0
TrailingStop,2=1
TrailingStop,3=50

but there ist no parameter entry in the EA. Can you please put in on?

When I think about popular Distributions of Data I found the Bernoulli Data Distribution. I will test to bring this concept to course moving.


Hello, Nirvaman, I tested your EA with trailingstop but it does not work. Therefore I put one functionable EA on it and you can see the result: during my testings I optimize the parameter and got a smaller profit but less risk. That I can see: optimizing for a small period will not give good results for long periods and vice versa. If we use TS and optimizing for a short period that can be one way ...

I enclose your EA with one TS: NirvamanImaxTS

awsome job. thx again

 

it's absurd to test an EA only on one week .............

normally i take at least one year to may include some different situations :-)))))))))))))

take in account that one economic cycle is 5 year...

 
nirvaman:
Hubexde:
//+------------------------------------------------------------------+
//|                                 NirvamanImax.mq4                 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Gabriel Jaime Mejía Arbelaez"
#property link      "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//|                                                   e-Trailing.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|***   Trailing-Stop   ***                                         |
//| 12.09.2005 Àâòîìàòè÷åñêèé Trailing Stop âñåõ îòêðûòûõ ïîçèöèé    |
//|            Âåøàòü òîëüêî íà îäèí ãðàôèê                          |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern bool   ProfitTrailing = True;  // Òðàëèòü òîëüêî ïðîôèò
extern int    TrailingStop   = 8;     // Ôèêñèðîâàííûé ðàçìåð òðàëà
extern int    TrailingStep   = 2;     // Øàã òðàëà
extern bool   UseSound       = True;  // Èñïîëüçîâàòü çâóêîâîé ñèãíàë
extern string NameFileSound  = "expert.wav";  // Íàèìåíîâàíèå çâóêîâîãî ôàéëà
//---- input parameters
extern double       lots = 0.1;
extern int          mn = 555;
static int          prevtime = 0;
extern double       tp = 100;
extern double       sl = 50;
extern double       periodos=13;
extern int          tiempoCierre=15000;
//extern int          TrailingStop=10;   //add
int StartHour=22;
int EndHour=2;
int BrokerTimeZone=0;
int start()
{
   if (Time[0] == prevtime) return(0);
   prevtime = Time[0];
   if (! IsTradeAllowed()) {
      again();
      return(0);
   }
   
   //----------------------------------------cerrando orden abierta despues de la primera barra
   
   
   int total = OrdersTotal();
   for (int i = 0; i < total; i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == mn)
      {
          if(TimeCurrent()-OrderOpenTime()>=tiempoCierre)
          {
             
              OrderClose(OrderTicket(),lots,MarketInfo(Symbol(),MODE_BID),3,GreenYellow);
          }
          else
          {
               return(0);
          }
      }
   }
  //----------------------------------------------------------------------------------------
   int ticket = -1;
   int perceptron = Supervisor();
   int ha=0;
   
   double buff0=0;
   double buff1=0;
   
  
   
   buff0=iCustom(NULL, 0, "HA",2,0);
   buff1=iCustom(NULL, 0, "HA",3,0);
   
   
   
   if(buff0>buff1)
    ha=-1;
   
   if(buff0<buff1)
    ha=1;
   //-----------------------------------------------------------------------------------------
   
   
    double  promedioEMA=iCustom(NULL, 0, "Moving Averages2",periodos,0,0);
   
   
   //----------------------------------------------------------No operar en este rango de horas
   int h=TimeHour(TimeCurrent()-BrokerTimeZone);
       
    if(!(h> StartHour && h<EndHour))
    {
    
    
     
   
   
   if ( perceptron > 0 && ha > 0 && Close[1]>promedioEMA) {
      ticket = OrderSend(Symbol(), OP_BUY, lots, Ask,2, Bid - sl * Point, Bid + tp * Point, WindowExpertName(), mn, 0, Blue);
      Alert("SEÑAL:"+Symbol());
      if (ticket < 0) {
         again();    
      }
   }
   if (perceptron < 0 && ha <0  && Close[1]<promedioEMA) {
      ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 2, Ask + sl * Point, Ask - tp * Point, WindowExpertName(), mn, 0, Red);
      Alert("SEÑAL:"+Symbol());
      if (ticket < 0) {
         again();
      }
   }   
   
   }
    
   return(0);
      
   //------------------------------------------------------------------------------                       
}
void again() {
   prevtime = Time[1];
   Sleep(30000);
}
/*+-------------------------------------------------------------------+
  | supervisor encargado de determinar si se hace long o short        |
  +-------------------------------------------------------------------+*/
double Supervisor()
{
    double iMAX0=iCustom(NULL, 0, "iMAX3alert1",4,0);
    double iMAX1=iCustom(NULL, 0, "iMAX3alert1",5,0);
    
    double iMAX01=iCustom(NULL, 0, "iMAX3alert1",4,1);
    double iMAX11=iCustom(NULL, 0, "iMAX3alert1",5,1);
    
    double b0=0;
    double b1=0;
    double r0=0;
    double r1=0;
    
    b0 = iMAX0;
    b1 = iMAX01;
    r0 = iMAX1;
    r1 = iMAX11;
    
    if(b0 > r0 && b1 < r1)
         return(1);
         
    if(b0 < r0 && b1 > r1)
         return(-1);   
    
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
if(OrderMagicNumber() == mn)
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      TrailingPositions();
    }
  }
}
//+------------------------------------------------------------------+
//| Ñîïðîâîæäåíèå ïîçèöèè ïðîñòûì òðàëîì                             |
//+------------------------------------------------------------------+
void TrailingPositions() {
  double pBid, pAsk, pp;
  pp = MarketInfo(OrderSymbol(), MODE_POINT);
  if (OrderType()==OP_BUY) {
    pBid = MarketInfo(OrderSymbol(), MODE_BID);
    if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
      if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
        ModifyStopLoss(pBid-TrailingStop*pp);
        return;
      }
    }
  }
  if (OrderType()==OP_SELL) {
    pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
    if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
      if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
        ModifyStopLoss(pAsk+TrailingStop*pp);
        return;
      }
    }
  }
}
//+------------------------------------------------------------------+
//| Ïåðåíîñ óðîâíÿ StopLoss                                          |
//| Ïàðàìåòðû:                                                       |
//|   ldStopLoss - óðîâåíü StopLoss                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss) {
  bool fm;
  fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
  if (fm && UseSound) PlaySound(NameFileSound);
}
//+------------------------------------------------------------------+
         
    
telerater
wrote:

Hello Nirvaman, I guess the idea of 'trailing stop' kind of appealed you. I hope you dont mind of my suggestions. Since trading at such a short period like M1, SL&TP has to be dynamic. As long as the entry points are 51 % positive than keeping loses at the min level is crutiualy important. As an example, after the entry point surfing at the positive side has to be ended definately with a result of plus. Either its 0 pip 1pip. While forwardtesting with your code, unfortunately, many time I have experienced trades that couple of times turned from plus to minus then plus again and 50% of time ended minus. For dynamic exiting appliying 20 LWMA (or EMA) Low and High both on the same chart and use long exit at cross of a 20 LWMA Low period, for the short exit at the cross of a 20 LWMA High period. Therefore, once we are at the positive territory depending on the slope (speed) after cople of munites trade becomes safe from minus result.For the profit target may be placed three choices depending on the trade period average of the optimized results. If you like we can discuss more over via mail.. thanks again in advance for your nice work and precious time.


Hubexde
wrote:

Hello, nirvaman, congratulation to your EA which handle with Laguerre Data Distribution. One question please: is it necessary to adjust some parameter of HA or imax3..? You wrote that you plan to put TS on the EA. That is a good idea. The list above listed

TrailingStop=40
TrailingStop,F=1
TrailingStop,1=0
TrailingStop,2=1
TrailingStop,3=50

but there ist no parameter entry in the EA. Can you please put in on?

When I think about popular Distributions of Data I found the Bernoulli Data Distribution. I will test to bring this concept to course moving.


Hello, Nirvaman, I tested your EA with trailingstop but it does not work. Therefore I put one functionable EA on it and you can see the result: during my testings I optimize the parameter and got a smaller profit but less risk. That I can see: optimizing for a small period will not give good results for long periods and vice versa. If we use TS and optimizing for a short period that can be one way ...

I enclose your EA with one TS: NirvamanImaxTS

thx. I dont have problems with that. excelent job. I think my trailing has lot of failures so yours will be a nice add to this code. i will try it


 

Hi Nirv,

Can you make this work on a micro account and ready for download to MT4 EA. I have tried but I'm no programmer, yet.

 

SymbolEURUSDFXF (Euro vs US Dollar)
Period1 Minute (M1) 2007.03.30 17:01 - 2011.09.30 00:59 (2009.06.15 - 2009.06.19)
ModelEvery tick (the most precise method based on all available least timeframes)
Parameterslots=0.1; mn=555; tp=40; sl=18; periodos=3; tiempoCierre=24900;
Bars in test1667668Ticks modelled34632921Modelling quality99.00%
Mismatched charts errors0
Initial deposit10000.00
Total net profit175.80Gross profit868.80Gross loss-693.00
Profit factor1.25Expected payoff2.93
Absolute drawdown48.00Maximal drawdown107.00 (1.05%)Relative drawdown1.05% (107.00)
Total trades60Short positions (won %)30 (40.00%)Long positions (won %)30 (40.00%)
Profit trades (% of total)24 (40.00%)Loss trades (% of total)36 (60.00%)
Largestprofit trade40.00loss trade-20.00
Averageprofit trade36.20loss trade-19.25
Maximumconsecutive wins (profit in money)3 (118.00)consecutive losses (loss in money)4 (-80.00)
Maximalconsecutive profit (count of wins)118.00 (3)consecutive loss (count of losses)-80.00 (4)
Averageconsecutive wins1consecutive losses2
 

hi,

 where can i find the file heikin_ashi_smoothed.mq4? many thanks for this code 

Reason: