Experts: Fractals at Close prices EA

 

Fractals at Close prices EA:

An Expert Advisor based on the "Fractals at Close prices" indicator.


Author: Vladimir Karputov

 

****

 

This is interesting! the idea is good, but the fractal doesn't help! If you change the fractal indicator with a zigzag indicator, the result can be much better! I leave my advice here!

 

The idea is the same but with a zigzag indicator and open order only after a gap like this one in the image, we will have a more interesting EA!

Files:
zigzag.png  19 kb
 
kwlin_089:

The idea is the same, but with a zigzag indicator and an open order only after a gap like this one in the image, we will have a more interesting EA!


On ZigZag was this code: Last ZZ50

Strategy based on the ZigZag indicator and pending orders.

The code was born in the branch Strategy based on the indicator "ZigZag" - "Last ZZ50".

Author of the idea - Vitaly Muzichenko, MQL5 code implementation - Vladimir Karputov.

The general principle of the strategy "Last ZZ50":

Strategy based on "ZigZag" indicator - "Last ZZ50"

In the ZigZag indicator, we always consider the last two rays: AB and BC. The AB ray is a ray that is not fixed yet and can change (point A can change its position).

Pending orders are placed in the middle of the ray AB and BC with such a calculation that:

  • The triggering of a pending order on ray AB is a case of continuation of the trend demonstrated by ray BC;
  • triggering of the pending order on the ray BC is a case of trend reversal, which is demonstrated by the ray BC.

Since ray AB is a ray that is not fixed yet and can change (point A can change its position), the pending order will be modified all the time so that its price is always in the middle of ray AB.

Trailing of open positions works according to the rule: wait until the position is in profit (excluding commission and swap) by at least (Trailing Stop + Trailing Step) pips, and then switch on trailing for this position.

 
Vladimir Karputov :

There was this code for ZigZag: Last ZZ50

Strategy based on ZigZag indicator and pending orders.

The code was born in the branch Strategy based on ZigZag indicator - "Last ZZ50".

The author of the idea is Vitaly Muzichenko, MQL5 code implementation - Vladimir Karputov.

The general principle of the strategy "Last ZZ50":

In the ZigZag indicator we always consider the last two rays: AB and BC. The AB ray is a ray that is not fixed yet and can change (point A can change its position).

Pending orders are placed in the middle of the ray AB and BC with such a calculation that:

  • The triggering of a pending order on ray AB is a case of continuation of the trend demonstrated by ray BC;
  • triggering of the pending order on the ray BC is the case of trend reversal, which is demonstrated by the ray BC.

Since ray AB is a ray that is not fixed yet and can change (point A can change its position), the pending order will be modified all the time so that its price is always in the middle of ray AB.

Trailing of open positions works according to the rule: wait until the position is in profit (excluding commission and swap) by at least (Trailing Stop + Trailing Step) pips, and then switch on trailing for this position.

The problem with this "Last ZZ50" strategy is that it opens many pending orders in the middle of the indicator zigzag, and this causes a lot of confusion leading to many losses and drawdowns. The way you have built this "Fractals at Close Prices EA" indicator, it is more interesting to adapt the zigzag indicator.

If there is a way to make an EA, that would be interesting! I think it would create an excellent EA!
 
kwlin_089:
The problem with this "Last ZZ50" strategy is that it opens many pending orders in the middle of the indicator zigzag, ***

It is never too late to put a limit on the number of consecutive open positions.

 

Does it have any function to keep it from closing the order in the opposite signal?

 

Maybe true/false to enable and disable the opposite sign or even tell me what I can extract from the code so I can test it without closing orders in the opposite sign! Thank you for your co-operation with this EA!

 
kwlin_089:

Does it have any function to keep it from closing the order in the opposite signal?


You just need to comment out those lines:

   if(InpStarHour<InpEndHour) // trade in one day
     {
      if(time_current<time_start || time_current>=time_end)
        {
         CloseAllPositions();
         return;
        }
     }
   else if(InpStarHour>InpEndHour) // trade with transition next day
     {
      if(struct_time_current.hour<InpStarHour && struct_time_current.hour>=InpEndHour)
        {
         CloseAllPositions();
         return;
        }
     }
   else if(InpStarHour==InpEndHour)
     {
      // trade full day!!!
     }
 
Vladimir Karputov :

You just need to comment out those lines:

I did that, but it didn't work, then that part of the code posted apparently has to do with opening and closing the chart! But what I need is that it doesn't close the position when the opposite fractal signal appears, that is, I want to close the position only at "stop loss" or "take profit"

I tried to comment out this part of the code, which turned out to be correct, but it doesn't work

 //--- 
   if (last_lower!= EMPTY_VALUE && previous_lower!= EMPTY_VALUE )
       if (previous_lower<last_lower)
        {
          ClosePositions( POSITION_TYPE_SELL ); 
         if (CalculatePositions( POSITION_TYPE_BUY )== 0 )
           {
             double sl=(InpTakeProfit== 0 )? 0.0 :m_symbol. Ask ()-ExtStopLoss;
             double tp=(InpStopLoss== 0 )? 0.0 :m_symbol. Ask ()+ExtTakeProfit;
            OpenBuy(sl,tp);
           }
        }
   if (last_upper!= EMPTY_VALUE && previous_upper!= EMPTY_VALUE )
       if (previous_upper>last_upper)
        {
          ClosePositions( POSITION_TYPE_BUY ); 
         if (CalculatePositions( POSITION_TYPE_SELL )== 0 )
           {
             double sl=(InpTakeProfit== 0 )? 0.0 :m_symbol. Bid ()+ExtStopLoss;
             double tp=(InpStopLoss== 0 )? 0.0 :m_symbol. Bid ()-ExtTakeProfit;
            OpenSell(sl,tp);
           }
        }
 //--- 
   Trailing();
  }