MaxMin Bands free

by qualitiedx2 in category Other at 16/05/2012
Description

This indicator is used to visualize the lowest Low and the Highest High for the last X bars. You can use it effectively to calculate the value of the Trailing Stop of your orders.

MaxMin Bands

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.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        [Parameter(DefaultValue = 5)]
        public int period { get; set; }

        [Output("Maxband" , Color = Colors.Blue)]
        public IndicatorDataSeries maxband { get; set; }
        
        [Output("Minband", Color = Colors.Red)]
        public IndicatorDataSeries minband { get; set; }
        
		double lower;
		double higher;

        public override void Calculate(int index)
        {
			lower = MarketSeries.Low[index];
			higher = MarketSeries.High[index];
			
			for (int i=0;i<period;i++)
			{
				if(MarketSeries.Low[index-i]<lower)
				{
					lower = MarketSeries.Low[index-i];
				}
				if(MarketSeries.High[index-i]>higher)
				{
					higher = MarketSeries.High[index-i];
				}
				minband[index]=lower;
				maxband[index]=higher;
			}
        }
    }
}
Comments

hermoso - July 23, 2012 @ 18:42

Hello, tks a lot for this code. I having a problem here. How do i call custom indicators inside my robot? I dont know hot to initialize this. tks
5