Set price with Trailing Stop

Created at 04 Aug 2013, 17:58
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Forex19's avatar

Forex19

Joined 13.06.2013

Set price with Trailing Stop
04 Aug 2013, 17:58


Hi, in this topic:

 

/forum/calgo-reference-samples/613

 

is shown  the modified version of the API cAlgo samples.

I wanted to ask how I can edit this robot for adding another parameter that allows me to set the price buy/sell at which to initiate the order.


@Forex19
Replies

cAlgo_Fanatic
05 Aug 2013, 12:49

The parameter would be a type double property:

[Parameter]
public double Price { get; set; }

Then use this parameter in the methods that create the limit order requests instead of the calculation of the price based on the TakeProfitPips.

var request = new LimitOrderRequest(tradeType, Volume, Price)


It is recomended that you validate this input.


@cAlgo_Fanatic

Forex19
06 Aug 2013, 17:55

RE:

cAlgo_Fanatic said:

The parameter would be a type double property:

[Parameter]
public double Price { get; set; }

Then use this parameter in the methods that create the limit order requests instead of the calculation of the price based on the TakeProfitPips.

var request = new LimitOrderRequest(tradeType, Volume, Price)


It is recomended that you validate this input.

I changed that and it seems to work:

  private void RequestLimitSell()

        {
            double targetPrice = Price;
            // double targetPrice = Symbol.Bid + TargetPricePips * Symbol.PipSize; (old line)
            var request = new LimitOrderRequest(TradeType.Sell, Volume, Price)
            // var request = new LimitOrderRequest(TradeType.Sell, Volume, targetPrice) (old line)

and

        private void RequestLimitBuy()
        {
            double targetPrice = Price;
            // double targetPrice = Symbol.Ask - TargetPricePips * Symbol.PipSize; (old line)
            var request = new LimitOrderRequest(TradeType.Buy, Volume, Price)
            // var request = new LimitOrderRequest(TradeType.Buy, Volume, targetPrice) (old line)
 


@Forex19