fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    I really need help, How to make Break Even work on Bid if buy and on Ask if sell?

    Questions & Answers
    2
    2
    566
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      meky55 last edited by

      Hi,

      Please any body tell me how to make Break Even work on Bid if buy and on Ask for sell?

      Original code:
      void block35(int parent=0)
      {
      if (disabled[35] || FXD_BREAK) {return;}
      FXD_CURRENT_FUNCTION_ID=35;

      static string OnProfitMode = "fixed";
      double OnProfitPips = _externs::inp36_OnProfitPips;
      double OnProfitPercentSL = 50;
      double OnProfitPercentTP = 50;
      static string BEoffsetMode = "pips";
      double BEPoffsetPips = _externs::inp36_BEPoffsetPips;
      static string OrdersScope = "group";
      static string OrdersGroup = "";
      static string SymbolScope = "symbol";
      static string SYMBOL; SYMBOL = CurrentSymbol();
      static string BuysOrSells = "both";
      
      
      for (int pos=OrdersTotal()-1; pos>=0; pos--)
      {
      	if (!OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)) {continue;}
      
      	if (!FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {continue;}
      	
      	double PipsToSet=0;
      	SetSymbol(attrSymbol());
      	
      	if (OnProfitMode=="fixed")          {PipsToSet = OnProfitPips;}
      	else if (OnProfitMode=="percentSL") {PipsToSet = toPips(MathAbs(attrOpenPrice()-attrStopLoss()))*OnProfitPercentSL/100;}
      	else if (OnProfitMode=="percentTP") {PipsToSet = toPips(MathAbs(attrOpenPrice()-attrTakeProfit()))*OnProfitPercentTP/100;}
               
      	if (
      		(attrType()==OP_BUY && (SymbolAsk()-attrOpenPrice() > toDigits(PipsToSet)) && (attrStopLoss() < attrOpenPrice()))
      		||
      		(attrType()==OP_SELL && (attrOpenPrice()-SymbolBid() > toDigits(PipsToSet)) && ((attrStopLoss() > attrOpenPrice()) || attrStopLoss()==0))
      		)
      	{
      		double be_offset=0;
      		if (BEoffsetMode=="pips") {
      			be_offset=toDigits(BEPoffsetPips);
      			if (attrType()==OP_SELL ) {be_offset=be_offset*(-1);}
      		}
      		ModifyStops(attrTicket(),attrOpenPrice()+be_offset,attrTakeProfit());
      	}
      }
      

      Regards

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        Use the trailing stop block instead. Posting the source code doesn't help, because you can't change it from the EA builder. For the trailing stop try to set Step to 1000 (some huge number), Start to the profit that is needed and Stop... the same as Start

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post

        Online Users

        C
        E
        F
        D
        S
        J
        C

        15
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors