Experts: Fractals at Close prices EA - page 2

 

You need to comment out the lines.

//Commented string
Незакоментированная строка

To comment out a line, you need to put "//".

 
Vladimir Karputov :

You need to comment out the lines.

You need to put a "//" to comment out a line.

Yes, this was exactly what I did as in the code you sent me earlier and this is the part I leave here below, however none of those who worked at EA close positions in the fractal opposite sign! Is there any other way so I can change it!

 //--- 
   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();
  }
 
kwlin_089:

Yes, this was exactly what I did as in the code you sent me earlier, and this is the part I leave here below, however none of those who worked at EA close positions in a fractal opposite sign! Is there any other way so I can change it!


In that case I am not quite sure what exactly you want. Sorry.

 
Vladimir Karputov:

In that case, I'm not quite sure what you want. Sorry.

I'll try to show an example:

If EA opened a buy because it detected previous_lower[B]<last_lower[A], and in this example the input parameters are "take profit: 500 pips" and "stop loss: 200 pips", technically we expect EA to reach these profit or stop loss levels to close the trade.

But in this version of your EA, when an inverted signal appears, ie. Using the example above, if previous_upper[B]>last_upper[A] appears, EA will terminate the buy transaction that is active without reaching the profit or stop loss.

This is exactly what I need to change, I have tried to change some things in the code, but I can't figure out what part of the code would change this problem to terminate the transactions when the inverted signal appears when the transaction is still open!

If you have a solution you would like to know?

 
kwlin_089:

I will try to show an example:

If EA opened a buy because it detected previous_lower[B]<last_lower[A], and in this example the input parameters are "take profit: 500 pips" and "stop loss: 200 pips", technically we expect EA to reach these profit or stop loss levels to close the trade.

But in this version of your EA, when an inverted signal appears, ie. Using the example above, if previous_upper[B]>last_upper[A] appears, EA will terminate the buy transaction that is active without reaching the profit or stop loss.

This is exactly what I need to change, I have tried to change some things in the code, but I can't figure out which part of the code will change this problem to terminate the transactions when the inverted signal appears when the transaction is still open!

If you have a solution you would like to know?


If I understand correctly you need this:

 //--- 
   if (last_lower!= EMPTY_VALUE && previous_lower!= EMPTY_VALUE )
       if (previous_lower<last_lower)
        {
         //ClosePositions( POSITION_TYPE_SELL ); 
         if (CalculatePositions( POSITION_TYPE_BUY )== 0 && CalculatePositions( POSITION_TYPE_SELL )== 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 && CalculatePositions( POSITION_TYPE_BUY )== 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();
  }

How it works: if there is more than one position (doesn't matter which one: BUY or SELL) then we skip all signals and don't open new positions.

 
Vladimir Karputov :

If I understand correctly, you need this:

How it works: if there is more than one position (it doesn't matter which one: BUY or SELL), we skip all signals and don't open new positions.

Exactly!

Thanks for your help!

 
kwlin_089:

That's right!

Thanks for your help!


You're welcome!

 

Mr Vladimir,

Could you please release this indicator as HTF?

 
zemo:

Mr Vladimir,

Could you please release this indicator as HTF?

No.
 
Dear vladimir ... I hope you can help me to edit this EA so that open transactions based on Fractal close both for each transaction using SL and TP. so everytime there are standard fractals on TF 30 or other TF will do the transaction. Thank you for the help. I wish Vladimir always healthy and always successful. God bless you.