Topics
29 May 2015, 11:52
 3125
 3
Replies

9607367
31 May 2015, 20:41

RE: RE:

Thank you very much tradermatrix! I will test

9607367 said:

I want to reduce "Take Profit" if the loss.

Please tell me how it will look this condition:

 

If a loss then "Take Profit" / 2

hello
 like that;

 
        [Parameter(DefaultValue = 20)]
        public double TakeProfit1 { get; set; }

       [Parameter(DefaultValue = 10)]
        public double TakeProfit2 { get; set; }

       

  protected override void OnStart()
        {
          
            Positions.Closed += OnPositionsClosed;
        }

  private void OnPositionsClosed(PositionClosedEventArgs args)
        {


            if (takeprofit2 == true)
            {

                Print("Closed");

                var position = args.Position;

                if (position.Label != label || position.SymbolCode != Symbol.Code)
                    return;




                if (position.GrossProfit < 0)
                {




                    ExecuteMarketOrder(position.TradeType, Symbol, Volume , label, StopLoss, TakeProfit2);
                }

            }
        }

if you want the operation is only performed just once;
we must add label2.

exemple;

 private const string label1 = "Sample Trend cBot";

private const string label2 = "TakeProfit 2";

      ExecuteMarketOrder(position.TradeType, Symbol, Volume , label2, StopLoss, TakeProfit2);

 

 


 if you have a problem, write your code I would correct you.


 cordially

 


@9607367