Scalextric free

by srm_bcn in category Trend at 31/08/2020
Description

Well, this time, exploring relations between open and close.

Have fun!

 

 

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 SmoothedOpenCloseOverlay : Indicator
    {
        [Parameter("Periods", DefaultValue = 20)]
        public int Periods { get; set; }

        [Output("Result1", LineColor = "Tomato")]
        public IndicatorDataSeries Result1 { get; set; }

        [Output("Result2", LineColor = "LightGreen")]
        public IndicatorDataSeries Result2 { get; set; }

        [Output("Result3", LineColor = "Red")]
        public IndicatorDataSeries Result3 { get; set; }

        [Output("Result4", LineColor = "Green")]
        public IndicatorDataSeries Result4 { get; set; }

        private double maxOpen, minOpen;
        private double maxClose, minClose;

        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {

            maxOpen = 0;
            minOpen = 0;
            maxClose = 0;
            minClose = 0;
            for (int i = 1; i <= Periods; i++)
            {
                maxOpen += Bars.OpenPrices.Maximum(i);
                minOpen += Bars.OpenPrices.Minimum(i);
                maxClose += Bars.ClosePrices.Maximum(i);
                minClose += Bars.ClosePrices.Minimum(i);
            }
            maxOpen = maxOpen / Periods;
            minOpen = minOpen / Periods;
            maxClose = maxClose / Periods;
            minClose = minClose / Periods;

            Result1[index] = maxOpen;
            Result2[index] = minOpen;
            Result3[index] = maxClose;
            Result4[index] = minClose;
        }
    }
}
Comments
0