Category Other  Published on 03/02/2021

cTrader Risk/Reward Management Indicator

Description

Download Link:

 

You have to do the risk and reward management for each trading, otherwise you will difficult to win and control your money in the market! You can set the stop-loss and take-profit in cTrader as below:

This is really better than MT4 & MT5, it will auto calculate the risk money by stop loss value, and you can also set the take profit amount! But this is still not convenient enough, I think if there is a visual operation for that will be great!

For example, you can drag & drop the stop-loss and take-profit line before you open order, and it will auto calculate the risk-reward rate or you can set the risk-reward for take-profit! That’s means you can easy to drag the stop loss to the support or resistance level, this will be very helpful for control and manage your money! Ok, I will let you know what an indicator can help you to do that!

I created an indicator for risk-reward management, you can easy to set the stop loss and take profit what you want, you also can drag the SL & TP line to set the value:

As you can see in the capture, the blue line is the entry price, green is the take profit price, and red is the stop-loss price. There are 4 order type buttons as below :

When you open a “Buy” or “Sell” order, you can drag the blue line, it will auto-update base on the Ask or Bid price, but if you want to open a “Buy Stop” or “Sell Stop” order, you can drag the blue line for your entry price level.

By default, all of the values will auto-update base on the current entry price, but if you want to change one of them, just edit it, and you will see an edit button change to green:

After you edit the value, click the green edit button, it will calculate other related values. For example, when you change the risk amount, it will also calculate the volumes to fulfill your amount, so that you can control how many amounts will you lose in this trade!

You can set to use the fix amount or percentage for the risk amount, if check “Use Percentage” button, it will base on your account balance to calculate the risk and update the volumes.

There are some parameters can be set:

Panel algnment: Set the default position of the panel

Style Settings: Set the stop-loss, take-profit and entry price line’s color

RS Management:

  1. Default Volumes: default volumes when open the indicator
  2. Risk Amount: default risk amount when open the indicator
  3. Default StopLoss: default stop-loss pips when open the indicator
  4. Default RS: default risk and reward rate when open the indicator

But this is still an indicator, so it can’t open order, if you want to open the order, you can take a look the cBot version.

In the end, this indicator is not free, I only want to charge a small fee so that I can create more better indicator or cBot in the future, but you can download it with 14 days free trial! So, if you like it, please purchase it, thanks for your support :)

Download Link:

 

 


using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CoderBlogIndicator : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }



        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        Border MainBorder;

        protected override void Initialize()
        {
            // Initialize and create nested indicators
            Init();
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...
        }

        private void Init()
        {
            StackPanel mainPanel = new StackPanel();


            #region Header
            var headerBorder = new Border 
            {
                BorderThickness = "0 0 0 1",
                Style = Styles.CreateCommonBorderStyle()
            };
            var headerGrid = new Grid(1, 2);
            headerGrid.Columns[1].SetWidthInPixels(60);

            var title = new TextBlock 
            {
                Text = "RS Management Indicator (by Winson)",
                Margin = "10 7",
                FontSize = 12,
                Style = Styles.CreateHeaderStyle()
            };
            headerGrid.AddChild(title, 0, 0);

            var closeBtn = new ToggleButton 
            {
                Text = "✖",
                Width = 55,
                Height = 20,
                FontSize = 8,
                Margin = new Thickness(0, 5, 5, 5)
            };
            closeBtn.Click += CloseBtn_Click;
            headerGrid.AddChild(closeBtn, 0, 1);

            headerBorder.Child = headerGrid;

            mainPanel.AddChild(headerBorder);
            #endregion


            #region Content Panel
            var contentBorder = new Border 
            {
                BorderThickness = "0 0 0 1",
                //Height = 340,
                Style = Styles.CreateCommonBorderStyle()
            };
            //var contentGrid = new Grid(1, 2);
            StackPanel contentPanel = new StackPanel();
            contentPanel.Orientation = Orientation.Vertical;
            #endregion


            #region Info Row
            StackPanel InfoRow = new StackPanel();
            InfoRow.Orientation = Orientation.Horizontal;
            InfoRow.VerticalAlignment = VerticalAlignment.Center;
            //InfoRow.HorizontalAlignment = HorizontalAlignment.Center;
            var lbDesc = new TextBlock 
            {
                Text = "It is not possible to download the cBot from the cTrader website. \r\n\r\nPlease go to visit us at \r\n\r\nhttps://www.coderblog.in/rs-indicator",
                Margin = "10 7",
                Padding = "10",
                FontSize = 14,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Style = Styles.CreateHeaderStyle()
            };
            InfoRow.AddChild(lbDesc);

            contentPanel.AddChild(InfoRow);
            #endregion

            #region Button Row
            StackPanel buttonRow = new StackPanel();
            buttonRow.Orientation = Orientation.Horizontal;
            buttonRow.HorizontalAlignment = HorizontalAlignment.Center;
            buttonRow.HorizontalAlignment = HorizontalAlignment.Center;
            var btn = new Button 
            {
                Text = "OK",
                Height = 20,
                Width = 200,
                FontSize = 12,
                //Margin = new Thickness(80, 10, 50, 10),
                Style = Styles.CreateButtonStyle(Color.FromHex("#009345"), Color.FromHex("#10A651"))
            };
            btn.Click += Btn_Click;
            buttonRow.AddChild(btn);

            contentPanel.AddChild(buttonRow);
            #endregion


            contentBorder.Child = contentPanel;
            mainPanel.AddChild(contentBorder);


            MainBorder = new Border 
            {
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Style = Styles.CreatePanelBackgroundStyle(),
                //Margin = "20 40 20 20",
                Margin = new Thickness(20, 40, 20, 20),
                Width = 430,
                Height = 200,
                Child = mainPanel
            };


            Chart.AddControl(MainBorder);
        }

        private void CloseBtn_Click(ToggleButtonEventArgs obj)
        {
            MainBorder.IsVisible = false;
        }

        private void Btn_Click(ButtonClickEventArgs obj)
        {
            MainBorder.IsVisible = false;
        }
    }

    public static class Styles
    {
        public static Style CreatePanelBackgroundStyle()
        {
            var style = new Style();
            style.Set(ControlProperty.CornerRadius, 3);
            style.Set(ControlProperty.BackgroundColor, GetColorWithOpacity(Color.FromHex("#292929"), 0.85m), ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, GetColorWithOpacity(Color.FromHex("#FFFFFF"), 0.85m), ControlState.LightTheme);
            style.Set(ControlProperty.BorderColor, Color.FromHex("#3C3C3C"), ControlState.DarkTheme);
            style.Set(ControlProperty.BorderColor, Color.FromHex("#C3C3C3"), ControlState.LightTheme);
            style.Set(ControlProperty.BorderThickness, new Thickness(1));

            return style;
        }

        public static Style CreateCommonBorderStyle()
        {
            var style = new Style();
            style.Set(ControlProperty.BorderColor, GetColorWithOpacity(Color.FromHex("#FFFFFF"), 0.12m), ControlState.DarkTheme);
            style.Set(ControlProperty.BorderColor, GetColorWithOpacity(Color.FromHex("#000000"), 0.12m), ControlState.LightTheme);
            return style;
        }

        public static Style CreateHeaderStyle()
        {
            var style = new Style();
            style.Set(ControlProperty.ForegroundColor, GetColorWithOpacity("#FFFFFF", 0.70m), ControlState.DarkTheme);
            style.Set(ControlProperty.ForegroundColor, GetColorWithOpacity("#000000", 0.65m), ControlState.LightTheme);
            return style;
        }

        public static Style CreateInputStyle()
        {
            var style = new Style(DefaultStyles.TextBoxStyle);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#1A1A1A"), ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#111111"), ControlState.DarkTheme | ControlState.Hover);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#E7EBED"), ControlState.LightTheme);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#D6DADC"), ControlState.LightTheme | ControlState.Hover);
            style.Set(ControlProperty.CornerRadius, 3);
            return style;
        }

        public static Style CreateBuyButtonStyle()
        {
            return CreateButtonStyle(Color.FromHex("#009345"), Color.FromHex("#10A651"));
        }

        public static Style CreateSellButtonStyle()
        {
            return CreateButtonStyle(Color.FromHex("#F05824"), Color.FromHex("#FF6C36"));
        }

        public static Style CreateCloseButtonStyle()
        {
            return CreateButtonStyle(Color.FromHex("#F05824"), Color.FromHex("#FF6C36"));
        }

        public static Style CreateButtonStyle(Color color, Color hoverColor)
        {
            var style = new Style(DefaultStyles.ButtonStyle);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.LightTheme);
            style.Set(ControlProperty.BackgroundColor, hoverColor, ControlState.DarkTheme | ControlState.Hover);
            style.Set(ControlProperty.BackgroundColor, hoverColor, ControlState.LightTheme | ControlState.Hover);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.DarkTheme);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.LightTheme);
            return style;
        }


        public static Style CreateToggleButtonStyle(Color color, Color checkedColor)
        {
            var style = new Style(DefaultStyles.ToggleButtonStyle);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.LightTheme);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.DarkTheme | ControlState.Checked);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.LightTheme | ControlState.Checked);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.DarkTheme | ControlState.Hover);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.LightTheme | ControlState.Hover);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.DarkTheme);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.LightTheme);
            return style;
        }

        private static Color GetColorWithOpacity(Color baseColor, decimal opacity)
        {
            var alpha = (int)Math.Round(byte.MaxValue * opacity, MidpointRounding.AwayFromZero);
            return Color.FromArgb(alpha, baseColor);
        }
    }
}


WI
winsonet

Joined on 03.01.2021

  • Distribution: Paid
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: CoderBlog Indicator.algo
  • Rating: 2.5
  • Installs: 1672
  • Modified: 13/10/2021 09:55
Comments
Log in to add a comment.
No comments found.