Category Other  Published on 05/03/2023

UpperTimeFrameCandle

Description

For Better Analysis

 

Screenshot image


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class UpperTimeFrameCandle : Indicator
    {
        [Parameter("Set Opentime", Group = "Parameters",DefaultValue = "Daily")]
        public TimeFrame TimeFrame_ {get; set;}
        [Parameter("Since Last", Group = "Parameters",DefaultValue = 10)]
        public int SinceLast_ {get; set;}
        [Parameter("TimeFrame By Hourly Period", Group = "Parameters",DefaultValue = 24)]
        public int Perio_ {get; set;}
        
        [Parameter("Set Color", Group = "Parameters",DefaultValue = "Gray")]
        public string Colo1 {get; set;}
        [Parameter("Thickness", Group = "Parameters",DefaultValue = 3)]
        public int Thickness_ {get; set;}
               
        private Bars _tm;

        protected override void Initialize()
        {
         _tm = MarketData.GetBars(TimeFrame_);
         _openTime = _tm.OpenTimes.Last(SinceLast_);
        
        }

        private DateTime _openTime;

        public override void Calculate(int index)
        {
         
         
          string co = Colo1; 
         _closingTime = _openTime.AddHours(Perio_);
         
         
         if(Bars.OpenTimes.LastValue >= _closingTime)
         {
         
            _displayOpe = Bars.OpenTimes.LastValue;
            _displayClo = _displayOpe.AddHours(Perio_);
            _openTime = Bars.OpenTimes.LastValue;
            _hig = Bars.HighPrices.LastValue;
            _low = Bars.LowPrices.LastValue;
            _ope = Bars.OpenPrices.LastValue;
            
         }
         
          _clo = Bars.ClosePrices.LastValue;
         GetHighGetLow(ref _hig,ref _low);
         
            
         Chart.DrawRectangle("1" + _displayOpe,_displayOpe,_ope,_displayClo,_clo,co,thickness : Thickness_);
         
         var trendLineHour = _displayOpe.AddHours(Perio_ / 2);
         
         double opening = _clo;
         double closing = _ope;
         
         if(_ope > _clo)
          {
            opening = _ope;
            closing = _clo;
          }

         Chart.DrawTrendLine("frist" + _displayOpe,trendLineHour,_hig,trendLineHour,opening,co,thickness : Thickness_);
         Chart.DrawTrendLine("second" + _displayOpe,trendLineHour,_low,trendLineHour,closing,co,thickness : Thickness_);
          
        }
        
        private DateTime _displayClo;
        private DateTime _displayOpe;
        
        private DateTime _closingTime;
        private double _clo;
        private double _ope;
        private double _hig;
        private double _low;
        
        private void GetHighGetLow(ref double re1,ref double re2)
        {
          if(Bars.HighPrices.LastValue > re1)
             re1 = Bars.HighPrices.LastValue ;
          if(Bars.LowPrices.LastValue < re2)
             re2 = Bars.LowPrices.LastValue;
        }
        
    }
}

D.
d.deel

Joined on 06.01.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: UpperTimeFrameCandle.algo
  • Rating: 5
  • Installs: 1145
  • Modified: 05/03/2023 04:10
Comments
Log in to add a comment.
No comments found.