Description
Auto Draw Fibonacci on period of X Bar
v1 : Add custom colour
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Collections.Generic;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Autofibov1 : Indicator
{
[Parameter("Look Back Period ", DefaultValue = 100)]
public int lookback { get; set; }
[Parameter("Series Timeframe")]
public TimeFrame tf { get; set; }
[Parameter("Bullish Color", DefaultValue = "blue")]
public string bulcolor { get; set; }
[Parameter("Bearish Color", DefaultValue = "red")]
public string bercolor { get; set; }
private MarketSeries series1;
protected override void Initialize()
{
// Initialize and create nested indicators
series1 = MarketData.GetSeries(tf);
OnTimer();
Timer.Start(60);
}
protected override void OnTimer()
{
// Initialize and create nested indicators
//find index
var hidate = Time.Date;
var lodate = Time.Date;
var superhi = MarketSeries.Close.LastValue;
var superlo = MarketSeries.Close.LastValue;
var highval = series1.High;
var loval = series1.Low;
for (var i = 0; i < lookback; i++)
{
//find hi
if (highval.Last(i) > superhi)
{
superhi = highval.Last(i);
hidate = series1.OpenTime.Last(i);
}
//findlo
if (loval.Last(i) < superlo)
{
superlo = loval.Last(i);
lodate = series1.OpenTime.Last(i);
}
var bull = (hidate > lodate) ? true : false;
var datechosen = (bull) ? lodate : hidate;
//set value of line
List<double> level = new List<double>
{
0.0,
23.6,
38.0,
50.0,
61.8,
100
};
var now = MarketSeries.OpenTime.LastValue;
var distance = superhi - superlo;
//drawline
foreach (var lev in level)
{
var dev = lev / 100 * distance;
var val = (bull) ? superhi - dev : superlo + dev;
Chart.DrawTrendLine(lev + "%", datechosen, val, now, val, (bull) ? bercolor : bulcolor, 1, LineStyle.Solid);
Chart.DrawText(lev + "% text", lev + "%", MarketSeries.OpenTime.Count + 1, val + 0.5 * Symbol.PipSize, (bull) ? bercolor : bulcolor);
}
}
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] = ...
}
}
}

Fundspreader .com
Joined 30.01.2017
- Type: Free
- Language: C#
- Trading Platform: cTrader Automate
- Filename: Autofibo v1.algo
- Rating: 5
- Downloads: 6253
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.
Comments
Only logged in users can post a comment
LO
Jeepers your name suits you.
Thank you deeply!
YA
Olá, parabéns pelo seu trabalho...Por acaso teria algum de volume como weis wave...aqui não tem.rsrs abrações

@velu130486,
Thank you for your interest,
and apology for lack of response since I don't have any notification on the comments.
Yeah, the indicator can be used for Cbot.
you can contact me at rony.sitepu@gmail.com
if you want to develop something out of it.
Best regards
RKS

Thank you..meer987@gmail.com
ME
Absolutely amazing Autofibo indicator.
5 stars.
Kudos to the developer.
This is great ,could you please make v2 with more fibo lines and also with timeframe option .Thank you