NNFX infos on chart - NEW VERSION free

by xabbu in category Other at 20/09/2020
Description

cTrader NNFX Infos on chart - new and enhanced version - cheers to VP (Patrick Victor) the creator of No Nonsense Forex

screenshot of NNFX infos on chart V.2

 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NNFXInfosonchartV2 : Indicator
    {
        [Parameter("Risk Percentage", Group = "Risk", DefaultValue = 2, MinValue = 0.5, MaxValue = 2, Step = 0.25)]
        public double _initialRisk { get; set; }

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

        public double _riskAmount;
        public double _pipValue;
        public double _riskUnits;
        public double _initialTakeProfit;
        public double _initialStopLoss;
        public double _initialTradeVolume;

        public IndicatorDataSeries Result;
        private AverageTrueRange _atr;



        protected override void Initialize()
        {
            _atr = Indicators.AverageTrueRange(20, MovingAverageType.Exponential);
            Result = CreateDataSeries();
        }



        public override void Calculate(int index)
        {

            _riskAmount = Math.Round((Account.Equity * _initialRisk) / 100, 0);
            _pipValue = Math.Round(_riskAmount / (getATRPips() * 1.5), 2);
            _riskUnits = _riskAmount / (1.5 * getATRPips() * Symbol.PipValue);

            _initialTradeVolume = Symbol.NormalizeVolumeInUnits(_riskUnits / 2, RoundingMode.Down);
            _initialTakeProfit = Math.Round(getATRPips(), 0);
            _initialStopLoss = Math.Round(getATRPips() * 1.5, 0);


            string Text = "(ATR) " + _initialTakeProfit + " - ";
            Text += "(SL) " + _initialStopLoss + " - ";
            Text += "(Equity) " + Math.Round(Account.Equity, 0) + "$ - ";
            Text += "(PipVal) " + _pipValue + "$ - ";
            Text += "(Risk) " + _initialRisk + "% - ";
            Text += "(Risk$) " + Math.Round(_riskAmount, 0) + "$ - ";
            Text += "(Units) " + _initialTradeVolume * 2 + " - go, GET it !";
            ;




            Chart.DrawStaticText("Symbols", Text, VerticalAlignment.Top, HorizontalAlignment.Left, Color.Silver);

            if (IsBacktesting && _accountInfo)
            {
                Chart.DrawStaticText("Dashboard1", "Backtest " + Account.PreciseLeverage + ":1 " + Account.Currency, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Green);
            }
            if (Account.IsLive && _accountInfo)
            {
                Chart.DrawStaticText("Dashboard1", "RealMoney " + Account.PreciseLeverage + ":1 " + Account.Currency, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Red);
            }
            if (!Account.IsLive && !IsBacktesting && _accountInfo)
            {
                Chart.DrawStaticText("Dashboard1", "Forward " + Account.PreciseLeverage + ":1 " + Account.Currency, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Yellow);
            }

        }

        private double getATRPips()
        {

            return _atr.Result.LastValue / Symbol.PipSize;
        }
    }
}
Comments