Risk to reward info

Created at 29 Apr 2016, 13:13
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!
AB

ABR170173

Joined 16.03.2015

Risk to reward info
29 Apr 2016, 13:13


Is it possible to implement indicator to platform, which will show current risk to reward based on current SL and TP?

Or maybe someone can create this simple indi?


@ABR170173
Replies

whis.gg
29 Apr 2016, 15:48

Hi, just a sample. Edit the code according to your needs.

using System;
using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class RRR : Indicator
    {
        public override void Calculate(int index)
        {
            if (Positions.Count == 0)
                return;

            Position position = Positions[Positions.Count - 1];
            double TakeProfitPips = Math.Abs((double)position.EntryPrice - (double)position.TakeProfit) * Symbol.PipSize;
            double StopLossPips = Math.Abs((double)position.EntryPrice - (double)position.StopLoss) * Symbol.PipSize;
            string text;
            if (TakeProfitPips >= StopLossPips)
                text = string.Format("1:{0}", Math.Round(TakeProfitPips / StopLossPips, 1));
            else
                text = string.Format("{0}:1", Math.Round(StopLossPips / TakeProfitPips, 1));

            ChartObjects.DrawText("RRR", text, StaticPosition.TopRight, Colors.Red);
        }
    }
}

 


@whis.gg