EA N7S_AO_772012 - page 9

 
My version with trawl is optimised normally...
 

Hooked on a trawl "booby trawl". The results and sets for last week are not bad. The drawdown is decreasing. Profit is growing.

Do some testing.

Code correction

void trl(){
      total= OrdersTotal(); spread = MarketInfo(Symbol(), MODE_SPREAD);
  for(  i = total - 1; i >= 0; i--) 
     { OrderSelect( i, SELECT_BY_POS, MODE_TRADES); MN=OrderMagicNumber();
       if(OrderSymbol() == Symbol() && MN>= 772012000 && MN<=772012199) 
         {  if ( MN==772012055) { sl = slx; tp = tpx* slx; mn= mnx1;}
            if ( MN==772012155) { sl = sly; tp = tpy* sly; mn= mny1;}
            if ( MN==772012011) { sl = slX; tp = tpX* slX; mn= mnX1;}
            if ( MN==772012111) { sl = slY; tp = tpY* slY; mn= mnY1;}
//Правим SL в зависимости от прибыли (от растояния в пипсах. Первый шаг = sl. ВТорой sl + sl/2 третий sl+ sl/2 + sl / 3 и т.п. 
         
           int prevticket = OrderTicket();if(OrderType() == OP_BUY) 
             {if(DayOfWeek( ) == 5 && Hour( ) >=22)  { OrderClose( prevticket,OrderLots( ) ,Bid,3,Red);} 
              if(Bid > (OrderStopLoss() + ( sl * 2  + spread) * Point)) 
                 { if( BTS()< 0) { OrderClose( prevticket,OrderLots( ) ,Bid,3,Red);} 
                   else  
                   TrailingUdavka(OrderTicket(), sl, sl, sl+ sl/2, sl/2, sl/4);}}
                   //Старый вариант
                   //{ OrderModify(OrderTicket(), OrderOpenPrice(), Bid - sl * Point,0, 0, Blue);}}} 
           else {if(DayOfWeek( ) == 5 && Hour( ) >=22) { OrderClose( prevticket,OrderLots( ) ,Ask,3,Blue);} 
                  if(Ask < (OrderStopLoss() - ( sl * 2 + spread) * Point)) 
                     {if( BTS() > 0) 
                           { OrderClose( prevticket,OrderLots( ) ,Ask,3,Blue);} 
                     else TrailingUdavka(OrderTicket(), sl, sl, sl+ sl/2, sl/2, sl/4);}}
                     //{ OrderModify(OrderTicket(), OrderOpenPrice(), Ask + sl * Point, 0, 0, Blue);}}}
          return(0);}}}
 

The boa constrictor itself

---------------

void TrailingUdavka(int ticket,int trl_dist_1,int level_1,int trl_dist_2,int level_2,int trl_dist_3)
   { 
   double newstop = 0; // новый стоплосс
   double trldist; // расстояние трейлинга (в зависимости от "пройденного" может = trl_dist_1, trl_dist_2 или trl_dist_3)

   // проверяем переданные значения
   if (( trl_dist_1<MarketInfo(Symbol(),MODE_STOPLEVEL)) || ( trl_dist_2<MarketInfo(Symbol(),MODE_STOPLEVEL)) || ( trl_dist_3<MarketInfo(Symbol(),MODE_STOPLEVEL)) || 
   ( level_1<= trl_dist_1) || ( level_2<= trl_dist_1) || ( level_2<= level_1) || ( ticket==0) || (!OrderSelect( ticket, SELECT_BY_TICKET, MODE_TRADES)))
      {
      Print("Трейлинг функцией TrailingUdavka() невозможен из-за некорректности значений переданных ей аргументов.");
      return(0);
      } 
   
   // если длинная позиция (OP_BUY)
   if (OrderType()==OP_BUY)
      {
      // если профит <=trl_dist_1, то trldist=trl_dist_1, если профит>trl_dist_1 && профит<=level_1*Point ...
      if ((Bid-OrderOpenPrice())<= level_1*Point) trldist = trl_dist_1;
      if (((Bid-OrderOpenPrice())> level_1*Point) && ((Bid-OrderOpenPrice())<= level_2*Point)) trldist = trl_dist_2;
      if ((Bid-OrderOpenPrice())> level_2*Point) trldist = trl_dist_3; 
            
      // если стоплосс = 0 или меньше курса открытия, то если тек.цена (Bid) больше/равна дистанции курс_открытия+расст.трейлинга
      if ((OrderStopLoss()==0) || (OrderStopLoss()<OrderOpenPrice()))
         {
         if (Bid>(OrderOpenPrice() + trldist*Point))
         newstop = Bid -  trldist*Point;
         }

      // иначе: если текущая цена (Bid) больше/равна дистанции текущий_стоплосс+расстояние трейлинга, 
      else
         {
         if (Bid>(OrderStopLoss() + trldist*Point))
         newstop = Bid -  trldist*Point;
         }
      
      // модифицируем стоплосс
      if ( newstop>OrderStopLoss())   
      OrderModify( ticket,OrderOpenPrice(), newstop,OrderTakeProfit(),OrderExpiration());
      }
      
   // если короткая позиция (OP_SELL)
   if (OrderType()==OP_SELL)
      { 
      // если профит <=trl_dist_1, то trldist=trl_dist_1, если профит>trl_dist_1 && профит<=level_1*Point ...
      if ((OrderOpenPrice()-(Ask + MarketInfo(Symbol(),MODE_SPREAD)*Point))<= level_1*Point) trldist = trl_dist_1;
      if (((OrderOpenPrice()-(Ask + MarketInfo(Symbol(),MODE_SPREAD)*Point))> level_1*Point) && ((OrderOpenPrice()-(Ask + MarketInfo(Symbol(),MODE_SPREAD)*Point))<= level_2*Point)) trldist = trl_dist_2;
      if ((OrderOpenPrice()-(Ask + MarketInfo(Symbol(),MODE_SPREAD)*Point))> level_2*Point) trldist = trl_dist_3; 
      
      // если стоплосс = 0 или меньше курса открытия, то если тек.цена (Ask) больше/равна дистанции курс_открытия+расст.трейлинга
      if ((OrderStopLoss()==0) || (OrderStopLoss()>OrderOpenPrice()))
         {
         if (Ask<(OrderOpenPrice() - ( trldist + MarketInfo(Symbol(),MODE_SPREAD))*Point))
         newstop = Ask + trldist*Point;
         }

      // иначе: если текущая цена (Bid) больше/равна дистанции текущий_стоплосс+расстояние трейлинга, 
      else
         {
         if (Ask<(OrderStopLoss() - ( trldist + MarketInfo(Symbol(),MODE_SPREAD))*Point))
         newstop = Ask +  trldist*Point;
         }
               
       // модифицируем стоплосс
      if ( newstop>0)
         {
         if ((OrderStopLoss()==0) || (OrderStopLoss()>OrderOpenPrice()))
         OrderModify( ticket,OrderOpenPrice(), newstop,OrderTakeProfit(),OrderExpiration());
         else
            {
            if ( newstop<OrderStopLoss())   
            OrderModify( ticket,OrderOpenPrice(), newstop,OrderTakeProfit(),OrderExpiration());
            }
         }
      }      
   }
 
Casper писал(а) >>

It's not a bad idea, if only it worked :-)

Casper ,please correct this

TrailingUdavka(OrderTicket(), sl, sl, sl+sl/2, sl/2, sl/4);}}

At least like this or at your discretion

TrailingUdavka(OrderTicket(), sl, sl+sl/2, sl/2, 2*sl, sl/4);}}


I already said that I prefer to let profits grow and cut losses, so I treat trailing with caution.
IMHO trailing is not the best way, but someone will probably like it

.

I will do it by fractals first of all when I get to trailing, and in addition just close out of the market.
I also respect one more wisdom, if the price does not go in the right direction for a long time, it will definitely go against you!
Good luck to everyone and profits!!!
P.S.
Casper pay more attention, remember about "assembly effect" and about "dummies"

 
In the last two days of this week I was unable to fully test on the demo (the fifth sign of Alpari is "to blame"))) At midnight tonight I have installed corrected and updated software for nine instruments.
According to the tests these two days were better than last week. Equity $750.
Leaders Euro +$354 Cable +$257 Frank (what is surprising) +$176 Downside yen -$90 eur-yen -$162 and little Canadian -$15 The rest: kiwi +$89, pound +$77 and EURGBP +$59
 
SHOOTER777 >> :

It's not a bad idea, if only it worked :-)

Casper, please correct this

TrailingUdavka(OrderTicket(), sl, sl, sl+sl/2, sl/2, sl/4);}}

At least like this or at my discretion

TrailingUdavka(OrderTicket(), sl, sl+sl/2, sl/2, 2*sl, sl/4);}}


I already said I prefer to let profits grow and cut losses, so I treat trailing with caution.
IMHO trailing is not the best way, but someone will probably like it

.

I will do it with fractals first of all when I get to trailing, and in addition just close the market.
I also respect one more wisdom, if the price does not go in the right direction for a long time, it will definitely go against you!
Good luck and profit!!!
P.S.
Casper pay more attention, remember the "build effect" and the "dummies

"

The further the price moves, the higher the possibility of a pullback. And there is no profit to be lost. I managed to run on euro and pound at last week's set. Both pairs have higher profit and lower drawdown.

As for the challenge - I agree. My mistake. I also need to change the condition. Otherwise it makes too big a step. Somehow that's probably it.

            if(Bid > (OrderStopLoss() + ( sl * 2  + spread) * Point) || true) 
                 { if( BTS()< 0) { OrderClose( prevticket,OrderLots( ) ,Bid,3,Red);} 
                   else  
                   TrailingUdavka(OrderTicket(), sl, sl, sl+ sl/2, sl/2, sl/4);}}
                   //{ OrderModify(OrderTicket(), OrderOpenPrice(), Bid - sl * Point,0, 0, Blue);}}} 
           else {if(DayOfWeek( ) == 5 && Hour( ) >=22) { OrderClose( prevticket,OrderLots( ) ,Ask,3,Blue);} 
                  if(Ask < (OrderStopLoss() - ( sl * 2 + spread) * Point) || true) 
                     {if( BTS() > 0) 
                           { OrderClose( prevticket,OrderLots( ) ,Ask,3,Blue);} 
                     else 
                     TrailingUdavka(OrderTicket(), sl, sl, sl+ sl/2, sl/2, sl/4);}} 
                     //{ OrderModify(OrderTicket(), OrderOpenPrice(), Ask + sl * Point, 0, 0, Blue);}}}

Too lazy to redo the block now. Killed the appropriate if-units by specifying || true. Then again, it would be easy to get it back.

As for the "build effect" and the kettle. I used to program quite seriously in delphi C++ and C#. But that was probably 5-6 years ago. So I can also mess up, the skill is unfortunately lost. That's why I lay out the code.

Again, developer forum...

 

From the reports, it looks like the tool is WORKING in the author's capable hands.

Maybe it's time for real or at least micro-real?

 
goldtrader >> :

From the reports, it looks like the tool is WORKING in the author's capable hands.

Maybe it's time for real or at least micro-real?

I've got a cent on the real...

 
Casper >> :

I've got a cent on my real...

Can I attach you the staat?

 
goldtrader писал(а) >>

From the reports, it looks like the tool is WORKING in the author's capable hands.

Maybe it's time for a real, or at least a micro real?

Take your time!!!

An EA won't work properly on the real if the broker isn't napping.

Or at least you should be able to constantly monitor the terminal.

The Expert Advisor does not know how to work with requotes, etc.

It does not know how to check the status and divide trade streams if you put a lot of instruments.

It lacks one more flag - a ban during news releases and sharp speculative fluctuations,

and prohibition to trade in the same direction on the same bar.

There is no failure protection and the correctness of the input parameters is not checked.

I've had a couple of input parameters reset on my demo.

What is this - a broker joke - my terminal is from Alpari, or just glitches.

There's also something missing.