Category Other  Published on 20/09/2020

NNFX infos on chart - NEW VERSION

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

 


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;
        }
    }
}


xabbu's avatar
xabbu

Joined on 20.07.2020

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: NNFX Infos on chart V.2.algo
  • Rating: 5
  • Installs: 1454
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
xabbu's avatar
xabbu · 4 years ago

thank you for using and reporting - you can uncheck that referenced indicator (DOSC NNFX) under the tab "Manage References" in cTrader. In the next version I will correct it in the source...

oktaykaradeniz's avatar
oktaykaradeniz · 4 years ago

Hi Thx For all Shares,

But The fail code When rebuild:

Error : Project .\\DOSC (NNFX)\DOSC (NNFX)\DOSC (NNFX).csproj doesn't exist.

DR
drsamc · 4 years ago

fantastric add on! , i really hope VP made this .. or idk inspired by VPs principles