Thank you for your reply.
This seems pretty straight forward, how many levels were going to be needed? The only extra automation I might be able to suggest here would be defining user inputs for the levels. For example if you wanted a max of 5 levels, you could make 5 user inputs where you type in 1, 6, 12, 16, 20,40, or whatever values you wanted. Otherwise if more levels through a range are required and this is making a large amount of syntax you could form a method of this.
private void CheckPrices(double priceOne, double priceTwo, double priceThree) { if (Close[0] >= priceOne && Close [0] <= priceTwo) SetStopLoss(CalculationMode.Price, priceThree); } protected override void OnBarUpdate() { CheckPrices(Position.AveragePrice + 45 * TickSize, Position.AveragePrice + 54 * TickSize, Position.AveragePrice + 20 * TickSize); }
For the trailing stop, you would essentially just need to make the last step like I had in the example I provided where there is no top limit and the Close price is used however you would want to use an Offset with this price for the trail distance:
else if (Close[0] > Position.AveragePrice + 75 * TickSize ) { SetStopLoss(CalculationMode.Price, Close[0] - 5 * TickSize); }
I look forward to being of further assistance.
Leave a comment: