Category Other  Published on 05/07/2017

1SK - Display Info over PosLines onChart

Description

Hi,

This indicator displays the Position info on the Chart over the Position Line.  Kind of visual.  (Courtesy : Charles Layton)

Thank you.

///S.Khan

 


 

////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
///                                                                                  ///
///         REV. DATE   : TUE-14-OCT-16                                              ///
///         MADE BY     : ///S.KHAN                                                  ///
///         CONTACT ON  : skhan.projects@gmail.com                                   ///
///         DESCRIPTION :                                                            ///
///             (*THIS INDICATOR WILL DISPLAY THE AMOUNT AND PIPS ,                  ///
///               INFO ON THE CHARTS OVER THE POSITION LINE                          ///
///               only.*)                                                            ///
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////


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 SK_Pips_on_Trade_Entry_Line : Indicator
    {
        /////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////

        [Parameter(DefaultValue = 10)]
        public int Offset_1 { get; set; }

        ////////////////////////////////////////////////////////////////////////////////
        ///                         GLOBAL VARIABLES                                 ///
        ////////////////////////////////////////////////////////////////////////////////

        int p_Index = 0;

        ////////////////////////////////////////////////////////////////////////////////
        ///                         INITIALIZE                                       ///
        ////////////////////////////////////////////////////////////////////////////////
        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }
        //END Initialize


        ////////////////////////////////////////////////////////////////////////////////
        ///                         CALCULATE                                        ///
        ////////////////////////////////////////////////////////////////////////////////
        public override void Calculate(int index)
        {
            if (!IsLastBar)
            {
                return;
            }
            else
            {
                Update_01();
            }
            //END IF ELSE

            p_Index = index;

            //ChartObjects.RemoveAllObjects();
        }
        //END Calculate

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////           Update_01 FUNCTION        ///////////////////////////////////////////////////////////////////
        ///////////////////////////////                                     ///////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public void Update_01()
        {
            double Pos_EntryPrice = 0, Pos_Net_Pips = 0, Pos_Net_Amount;
            double History_Pos_EntryPrice = 0;
            string str_01 = "", str_02 = "", str_03 = "", str_04 = "", str_05 = "", str_06 = "";

            ///////////////////////////////////////////////////////////////////////////////
            //FIND RUNNING POSITIONS
            foreach (Position p in Positions)
            {
                if (p.SymbolCode != Symbol.Code)
                {
                    continue;
                }
                //END IF

                Pos_EntryPrice = p.EntryPrice;
                Pos_Net_Pips = p.Pips;
                Pos_Net_Amount = p.NetProfit;

                str_01 = Pos_EntryPrice.ToString();
                str_02 = Pos_Net_Pips.ToString() + " p";

                str_04 = Pos_EntryPrice.ToString() + "1";
                str_05 = "$ " + Pos_Net_Amount.ToString() + ", ";


                ChartObjects.DrawText(str_04, str_05, (p_Index - (Offset_1 + 12)), Pos_EntryPrice, VerticalAlignment.Top, HorizontalAlignment.Left, Colors.LimeGreen);
                ChartObjects.DrawText(str_01, str_02, (p_Index - Offset_1), Pos_EntryPrice, VerticalAlignment.Top, HorizontalAlignment.Left, Colors.LimeGreen);
            }
            //END FOREACH
            /////////////////////////////////////////////////////////////////////////////// 
            // REMOVE THE TEXT OF CLOSED POSITIONS
            foreach (var Cl_Pos in History)
            {
                if (Cl_Pos.SymbolCode != Symbol.Code)
                {
                    continue;
                }
                //ENDIF

                History_Pos_EntryPrice = Cl_Pos.EntryPrice;
                str_03 = History_Pos_EntryPrice.ToString();
                str_06 = str_03 + "1";

                ChartObjects.RemoveObject(str_03);
                ChartObjects.RemoveObject(str_06);

            }
            //END FOR EACH
            /////////////////////////////////////////////////////////////////////////////// 

        }
        //END Update_01


    }
    //END CLASS
}
//END cALGO


GoldnOil750's avatar
GoldnOil750

Joined on 07.04.2015

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: 1SK - Pips on Trade Entry Line.algo
  • Rating: 5
  • Installs: 3155
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.