Invalid stops only for selling break even

 

I was looking for information in the community for not ask again what was asked, but the invalid stops are being shown for me too, but... only for selling positions, very weird, since I only have to change the logical inverting it for selling, it's the only difference from buy.

  for(int bSell=PositionsTotal()-1;bSell>=0;bSell--)
  {
  string symbolSell = PositionGetSymbol(bSell);
  if(symbolSell == Symbol())
  {
  if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
  {
  if(m_position.StopLoss() > m_position.PriceOpen() - (breakStep01*_Point))
  {
  if(price <= m_position.PriceOpen() - (breakEven01*_Point))
  {
   trade.PositionModify(PositionGetTicket(bSell),m_position.PriceOpen() - (breakStep01*_Point),m_position.TakeProfit());
  }

It's giving this problem a lot of times only for sell, for buy it's ok.

 
Marcos Gomes Artischeff:

I was looking for information in the community for not ask again what was asked, but the invalid stops are being shown for me too, but... only for selling positions, very weird, since I only have to change the logical inverting it for selling, it's the only difference from buy.

It's giving this problem a lot of times only for sell, for buy it's ok.

Hi,

i can't see clearly your logic, but i have doubt about two needs:

first one:  if  trailingStop in any profit and starting from start of trade: 

  if(symbolSell == Symbol())
        if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)  
                if(m_position.StopLoss() > m_position.PriceCurrent() + (breakStep01*_Point)||!m_position.StopLoss())
                        trade.PositionModify(PositionGetTicket(bSell),m_position.PriceCurrent() + (breakStep01*_Point),m_position.TakeProfit());
  

else if  trailingStop in positiv profit and starting from 0 minimum:

  if(symbolSell == Symbol())
        if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)  
                if((m_position.StopLoss() > m_position.PriceCurrent() + (breakStep01*_Point)||!m_position.StopLoss())&&m_position.PriceCurrent() + (breakStep01*_Point)<m_position.PriceOpen())
                        trade.PositionModify(PositionGetTicket(bSell),m_position.PriceCurrent() + (breakStep01*_Point),m_position.TakeProfit());
  
 
Issam Kadhi:

Hi,

i can't see clearly your logic, but i have doubt about two needs:

first one:  if  trailingStop in any profit and starting from start of trade: 

else if  trailingStop in positiv profit and starting from 0 minimum:

I used something about Allowed freeze level and now it's ok, the weird is that no errors shown for EURUSD about it, but there are also spread errors, a lot, perhaps a bug or if it shows these errors they have to exist? Thanks for your help!

EDITED

The error still persists, but less, I checked a longer period, from more than 1 year, but few errors about breakeven.

 
Marcos Gomes Artischeff:

I used something about Allowed freeze level and now it's ok, the weird is that no errors shown for EURUSD about it, but there are also spread errors, a lot, perhaps a bug or if it shows these errors they have to exist? Thanks for your help!

EDITED

The error still persists, but less, I checked a longer period, from more than 1 year, but few errors about breakeven.

hi,

yes right, this depending on rules of your broker such as stoplevel...

 

you should synchronize it, my solution is only for asked problem not to solve all details.

thank you :)