Category Trend  Published on 29/06/2023

IR Calc Volume

Description

this indicator calculate your olume based on your risk percent and stop(pip).

support us for more free indicator and bot by sign up in LiteFinance broker from this link

LiteFinance Signup


using cAlgo.API;
using System;
using Microsoft.Win32;
namespace cAlgo
{
    // This sample indicator shows how to add a text box control on your chart
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class IRCalcVolume : Indicator
    {

        double risk;
        double pip;
        TextBox textBox3 = new TextBox();



        [Parameter("Horizontal Alignment ", DefaultValue = HorizontalAlignment.Left)]
        public HorizontalAlignment HAlignment { get; set; }

        [Parameter("Vertical Alignment", DefaultValue = VerticalAlignment.Top)]
        public VerticalAlignment VAlignment { get; set; }

        [Parameter("Orientation", DefaultValue = Orientation.Horizontal)]
        public Orientation Orientation1 { get; set; }

        [Parameter("Color", DefaultValue = "Red")]
        public Color color { get; set; }


        protected override void Initialize()
        {
            var mainStackPanel = new StackPanel 
            {
                HorizontalAlignment = HAlignment,
                VerticalAlignment = VAlignment,
                Orientation = Orientation1
            };
            var StackPanel1 = new StackPanel 
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Orientation = Orientation.Vertical
            };
            var StackPanel2 = new StackPanel 
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Orientation = Orientation.Vertical,
                Margin = 3
            };
            var StackPanel3 = new StackPanel 
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Orientation = Orientation.Vertical
            };
            var textBlock1 = new TextBlock 
            {
                ForegroundColor = color,
                HorizontalAlignment = HorizontalAlignment.Center,
                Text = "Risk%"
            };

            var textBox1 = new TextBox 
            {
                ForegroundColor = color,
                HorizontalAlignment = HorizontalAlignment.Center,
                Width = 50,
                BorderThickness = 2,
                BorderColor = color,
                TextAlignment = TextAlignment.Center,
                Text="3"
               
            };
            var textBlock2 = new TextBlock 
            {
                ForegroundColor = color,
                HorizontalAlignment = HorizontalAlignment.Center,
                Text = "SL(pips)"
            };
            var textBox2 = new TextBox 
            {
                ForegroundColor = color,
                HorizontalAlignment = HorizontalAlignment.Center,
                Width = 50,
                BorderThickness = 2,
                BorderColor = color,
                TextAlignment = TextAlignment.Center,
                Text="10"
            };


            var textBlock3 = new TextBlock 
            {

                ForegroundColor = color,
                HorizontalAlignment = HorizontalAlignment.Center,
                Text = "Volume"
            };


            risk = Convert.ToDouble(textBox1.Text);
            pip = Convert.ToDouble(textBox2.Text);

            textBox3.ForegroundColor = color;
            textBox3.HorizontalAlignment = HorizontalAlignment.Center;
            textBox3.Width = 50;
            textBox3.BorderThickness = 2;
            textBox3.BorderColor = color;
            textBox3.IsEnabled = false;
            textBlock3.TextAlignment = TextAlignment.Center;



            textBox1.TextChanged += TextBox1_TextChanged;
            textBox2.TextChanged += TextBox2_TextChanged;


            StackPanel1.AddChild(textBlock1);
            StackPanel1.AddChild(textBox1);

            StackPanel2.AddChild(textBlock2);
            StackPanel2.AddChild(textBox2);

            StackPanel3.AddChild(textBlock3);
            StackPanel3.AddChild(textBox3);

            mainStackPanel.AddChild(StackPanel1);
            mainStackPanel.AddChild(StackPanel2);
            mainStackPanel.AddChild(StackPanel3);

            Chart.AddControl(mainStackPanel);
        }
        private void TextBox1_TextChanged(TextChangedEventArgs obj)
        {
            risk = Convert.ToDouble(obj.TextBox.Text);
        }
        private void TextBox2_TextChanged(TextChangedEventArgs obj)
        {
            pip = Convert.ToDouble(obj.TextBox.Text);
        }
        public override void Calculate(int index)
        {
            textBox3.Text = CalcVolume(risk, pip);

        }

        public string CalcVolume(double r, double p)
        {

            return Math.Round(Symbol.VolumeInUnitsToQuantity(Account.Balance * r / 100 / (pip * Symbol.PipValue)), 2).ToString();


        }
    }
}


IR
IRCtrader

Joined on 17.06.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: IR Calc Volume.algo
  • Rating: 0
  • Installs: 272
  • Modified: 14/01/2024 13:10
Comments
Log in to add a comment.
CI
ciararoisin37 · 2 years ago

It is the best website that let me make my own website (Ireland CV) with perfect coding. It has been 5 years since I have been coding but still, there are a lot of things that I still need to learn.

RO
robertmayy19 · 2 years ago

Calculating the amount and risk will reduce the unwanted. canuckle