Experts: Stop Loss Take Profit

 

Stop Loss Take Profit:

If a trade is closed by Stop loss, the volume is doubled; if by Take profit the minimum volume is used. OnTradeTransaction is used to determine whether a trade was performed after the activation of Stop loss or Take profit.

      if(deal_symbol==m_symbol.Name() && deal_magic==m_magic)
         if(deal_entry==DEAL_ENTRY_OUT)
           {
            if(deal_reason==DEAL_REASON_SL)
               ExtLot*=2.0;
            else if(deal_reason==DEAL_REASON_TP)
               ExtLot=m_symbol.LotsMin();
           }

Author: Vladimir Karputov

 

Since build 1632 theDEAL_REASON property works in the tester!

 
Please help to change the EA:
If closing on Stop loss - do not trade (wait for the next signal)
If closing on Take profit - then open another "buy" onthe next tick. Further, if closed in +, open another "buy" trade.
 
dsfsf333:
Please help to change the EA:
If closing on Stop loss - do not trade (wait for the next signal)
If closing on Take profit - then open another "buy" onthe next tick. Further, if closed in +, open another "buy" trade
What signal are we waiting for?
 
Vladimir Karputov:
What signal are we waiting for?

000111111

 
dsfsf333:

000111111 (candles)

There are no "signals" in this Expert Advisor. The direction of the position is determined randomly:

      if(math_rand%1==0 && math_rand%2==0)
        {
         double sl=(InpStopLoss==0)?0.0:m_symbol.Bid()+ExtStopLoss;
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Bid()-ExtTakeProfit;
         OpenSell(ExtLot,sl,tp);
        }
      else
        {
         double sl=(InpStopLoss==0)?0.0:m_symbol.Ask()-ExtStopLoss;
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Ask()+ExtTakeProfit;
         OpenBuy(ExtLot,sl,tp);
        }
 
dsfsf333:
Please help to change the EA:
If closing on Stop loss - do not trade (wait for the next signal)
If closing on Take profit - then open another "buy" onthe next tick. Further, if it closed in +, open another "buy" trade.

Thank you all, got it all figured out)

 

Hi.


I see that the stop loss and take profit are set automatically. :)


But the expert executes positions automatically on live data. This is not what I want to achieve however. I like that the stop loss and take profit are set automatically on the execution of the position, but I want to execute positions manually. There are not such experts for MetaTrader 5 unfortunately. :( If you can add sub-pips to the code, I would be really happy ( 100 sub-pips = 10 pips ). After the manually execution of a position, nothing happens to the levels of stop loss and take profit.


I'm willing to pay you $100 if you can make this code for me. :)


I don't know which way is best to pay with, but I'm sure you can give me a solution. :D




Best regards,

Johannes Hillestad Baumann

 

Ohh!


I forgot to mention that the expert has to work on all charts that are loaded. There is only the need to insert one expert. This is important.


Thanks.




Best regards,

Johannes Hillestad Baumann