How to set TrailingStop On and Off as Parameter?

Created at 16 Feb 2021, 10:07
IN

intelligence21119

Joined 30.01.2021

How to set TrailingStop On and Off as Parameter?
16 Feb 2021, 10:07


Dear cTrader and all Experts,

How can I implement Trailing Stop as a Parameter in PlaceStopOrder, where I can choose whether to activate it or not.

I have tried:

PlaceStopOrder(TradeType.Buy, Symbol, Vol, Symbol.Bid + 10 * Symbol.PipSize, "Label", StopLoss, TakeProfit, null, "Comment01", true);

and I know TrailingStop is engaged every time.

And I have set:

[Parameter("TrailingStop", DefaultValue = true)]
public bool TrailingStop { get; set; }

But just did not work.

Thanks anyone who can help.


@intelligence21119
Replies

PanagiotisCharalampous
16 Feb 2021, 10:16

Hi intelligence21119,

You don't seem to be using the parameter in the method call. See below

PlaceStopOrder(TradeType.Buy, Symbol, Vol, Symbol.Bid + 10 * Symbol.PipSize, "Label", StopLoss, TakeProfit, null, "Comment01", true);

You should be using this instead

PlaceStopOrder(TradeType.Buy, Symbol, Vol, Symbol.Bid + 10 * Symbol.PipSize, "Label", StopLoss, TakeProfit, null, "Comment01", TrailingStop);

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous