Description
Follow my cTrader Telegram group at https://t.me/cTraderCommunity; it's a new community but it will grow fast, plus everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp
This is a simple indicator requested from a user of the Telegram group; it shows supply and demand areas based on fractals and it's multi timeframe.
For any bug report or suggestion contact me by joining the telegram group linked above or by commenting below
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 SupplyandDemand : Indicator
{
[Parameter("Period", DefaultValue = 5)]
public int per { get; set; }
[Parameter("TimeFrame")]
public TimeFrame tf { get; set; }
[Parameter("Suplly Color", DefaultValue = "Red")]
public string sColor { get; set; }
[Parameter("Demand Color", DefaultValue = "Lime")]
public string dColor { get; set; }
[Parameter("Opacity %", DefaultValue = 20)]
public int opt { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
private MarketSeries series;
private List<Supply> sList = new List<Supply>();
private List<Demand> dList = new List<Demand>();
private Color AsColor, AdColor;
protected override void Initialize()
{
series = MarketData.GetSeries(tf);
AsColor = Color.FromArgb((int)(255 * 0.01 * opt), Color.FromName(sColor).R, Color.FromName(sColor).G, Color.FromName(sColor).B);
AdColor = Color.FromArgb((int)(255 * 0.01 * opt), Color.FromName(dColor).R, Color.FromName(dColor).G, Color.FromName(dColor).B);
}
public override void Calculate(int index)
{
var index2 = series.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]);
var index3 = MarketSeries.OpenTime.GetIndexByExactTime(series.OpenTime[index2 - per]);
bool s = true;
bool t = true;
//SUPPLY
for (int i = 1; i < per; i++)
{
if (series.High[index2 - per + i] > series.High[index2 - per] && s == true)
{
s = false;
}
}
for (int i = 1; i < per; i++)
{
if (series.High[index2 - per - i] > series.High[index2 - per] && s == true)
{
s = false;
}
}
if (s == true)
{
sList.Add(new Supply(index3, series.High[index2 - per]));
}
//DEMAND
for (int i = 1; i < per; i++)
{
if (series.Low[index2 - per + i] < series.Low[index2 - per] && t == true)
{
t = false;
}
}
for (int i = 1; i < per; i++)
{
if (series.Low[index2 - per - i] < series.Low[index2 - per] && t == true)
{
t = false;
}
}
if (t == true)
{
dList.Add(new Demand(index3, series.Low[index2 - per]));
}
if (!IsLastBar)
return;
//DRAWING
foreach (var zone in sList)
{
for (int i = zone.index; i < index; i++)
{
if (MarketSeries.High[i] > zone.high)
{
int fIndex = series.OpenTime.GetIndexByTime(MarketSeries.OpenTime[zone.index]);
Chart.DrawRectangle("supply" + zone.index + " " + i, zone.index, Math.Max(series.Close[fIndex], series.Open[fIndex]), i, zone.high, AsColor, 1).IsFilled = true;
break;
}
}
}
foreach (var zone in dList)
{
for (int i = zone.index; i < index; i++)
{
if (MarketSeries.Low[i] < zone.low)
{
int fIndex = series.OpenTime.GetIndexByTime(MarketSeries.OpenTime[zone.index]);
Chart.DrawRectangle("demand" + zone.index + " " + i, zone.index, Math.Min(series.Close[fIndex], series.Open[fIndex]), i, zone.low, AdColor, 1).IsFilled = true;
break;
}
}
}
}
}
public class Supply
{
public int index;
public double high;
public Supply(int index, double high)
{
this.index = index;
this.high = high;
}
}
public class Demand
{
public int index;
public double low;
public Demand(int index, double low)
{
this.index = index;
this.low = low;
}
}
}
cysecsbin.01
Joined on 10.11.2018 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Supply and Demand.algo
- Rating: 0
- Installs: 8013
- Modified: 13/10/2021 09:54
Comments
I just downloaded this indicator, its like the zones are only painted if they have been consumed. It doesn't paint them forward, is it something wrong with my settings or?
1v1 lol is an important procedure for people who have had a previous implant device removed or replaced.
The organizations that win at word of mouth, owe customer acquisition cost for apps to their customers. They translate great experiences into stories which, in turn, create the desire for others to have the same experience. This simple formula works well because it uses design as a bridge building tool to connect the emotions of people with the rational delivery abilities of a business.