Replies

tomopeov
05 Sep 2019, 17:53

RE:

 

Hi Panagiotis Charalampous,

Currently, I have this bot that can make a re-entry order when a trade is stopped out.

If I want it to make n+1 re-entry orders plus a reverse order when n trades are stopped out how do I do it?

For example, if I have 2 long 10k eurusd trades at 1.20 with stop loss 20 pips. When the price goes to 1.1980 both trades get stopped out and I want the bot to create 3 long 10k eurusd orders at 1.20 and 1 short 10k eurusd order at 1.20 as well with stop loss at 20 pips each. And vice versa

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

        private void Positions_Closed(PositionClosedEventArgs obj)
        {
            if (obj.Reason == PositionCloseReason.StopLoss)
                PlaceStopLimitOrder(obj.Position.TradeType, Symbol, obj.Position.VolumeInUnits, obj.Position.EntryPrice, stopLimitRangePips, "reEntry", StopLoss, TakeProfit);
        }
    }
}

Best Regards,

Tomo P

 


@tomopeov

tomopeov
23 May 2019, 06:35

RE:

Panagiotis Charalampous said:

Hi useretinv,

You can use the code below


            if (position.GrossProfit > 0)
            {
                ExecuteOrder(InitialQuantity, GetRandomTradeType());
            }
            else
            {
                if (position.TradeType == TradeType.Buy)
                    ExecuteOrder(position.Quantity * 2, TradeType.Sell);
                else
                    ExecuteOrder(position.Quantity * 2, TradeType.Buy);
            }

Best Regards,

Panagiotis

Hi Panagiotis,

What if I want to place an order instead of executing a trade? For example if a buy trade is closed at a take profit target I want to place a sell trade order with the same entry price, trade size and take profit limit in pips as the closed trade and vice versa?

Thank you


@tomopeov