Algorithms

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
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.
How to install
Alert levels
  4
  0
  2424
free  11 Apr 2015
Alert levels. Store events in MyDocuments folder to detect crossing from setup date. Functions: 1. Color alert. 2. Sound alert. To use sound alerts please plaсe Ring.wav into MyDocuments folder.  
Trading helper
  2
  0
  2181
free  11 Apr 2015
This cBot helps to manage positions. cBot functions: 1. Setup initial stop loss (this this function is not important because cTrader already can do it). 2. Setup breakeven 1 (calculates in appliance with amount of comissions) on level1 3. Close fraction of the position and setup SL in appliance with amount of comissions and remain part. 4. Setup breakeven 2. 5. Tralling position.
VWAP for every bar
  1
  5
  3333
free  25 Apr 2015
This is the VWAP (version 1.1), or volume weighted average price for every individual bar. For timeframes shorter than daily it uses minute data up to the current second and then continues the calculation seamlessly with realtime tick volume for an accurate realtime VWAP display. For longer timeframes it uses 10 minute data, with only slight inaccuracies. DO NOT copy & paste and then try to compile the code yourself! The forum software introduces garbage symbols that I have no control over. I don't post the source code myself. The forum software extracts the source code from the uploaded file and what you see is the actual code that was included and compiled. So you can safely download. Sometimes there are periods in the chart that can't be properly displayed and are subsequently filtered. These periods appear as blank periods. On my charts for example this happens every day between 21:45 - 22:15 UTC. This only affects the historical VWAP. The realtime calculation usually works out fine because the indicator counts its own volume.  Note that if the indicator's values are off, all you have to do is right-click on the chart and select refresh. This should work out any problem during the first start up of the indicator. If that doesn't work, you may switch to another timeframe and then back to your original timeframe. Indicator Options Volume down & up color: This controls the coloring of the VWAP depending on the relation of the current volume to the previous volume. If the volume is up compared to the previous period's volume then the VWAP is colored the up color. If the volume is down it gets the down volume color. Here is a list of valid color names: http://ctdn.com/api/reference/colors You have to write their full name out. Coloring based on real volume: As mentioned the indicator counts its own volume. All it does is it increments a counter with every incoming tick. This results in a significant overhead of 20%-70% compared to the platforms reported tick volume for that period because the platform does not use true tick volume in its data collection. Rather it counts ticks that have a price difference to the previous tick and discards prices that have the same value. Therefore the platforms volume is really just price change event volume, or up and down tick volume. However, in my experience most of the time the relative volume differences are the same. On some occasions however this might still effect the coloring of the VWAPs. Turn this option off to use the platforms reported volume and to prevent any disruption due to the higher volume levels after indicator startup. Or turn it on to discover hidden high volume turns more effectively. Marker type: The VWAPs are displayed as ASCII or unicode symbols (dashes) that I copied from various sites. You can change their appearance by selecting marker 1 through 6. Let me know if you have problems with the symbols. Lookback: Included for performance reasons you can control how far back you want to display the VWAPs. On my platform it goes back only 7 days due to the lack of minute data. Therefore it won't display anything before that. You can safely choose a high value without harm though. There seems to be no performance hit, neither on historical download nor realtime calculation and display.   This is version 1.1 V1.01: Re-enabled the 1 Minute timeframe. This seems to work for scalpers. V1.02: New menu point. Changed the underlying coloring method. Various text edits on this page. V1.1: For longer timeframes than intraday 10 minute data is now used for a longer data plot into the past. This is automatic once the user selects a timeframe equal to or higher than daily. Examples:
free  03 Apr 2015
Soy nuevo usuario... y estoy aprendiendo a realizar mis robots... lo siento si existen errores de programacion, para mi me trabajan y bien... se que se pueden optimizar... acepto sugerencias...   Cabe destacar, que no se nada de programacion, pero me he puedo a leer c# y con los ejemplos he realizado ya varios y soy trader de tiempo completo. using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, AccessRights = AccessRights.None)] public class VelaEspecial : Indicator { public IndicatorDataSeries _Open; public IndicatorDataSeries _Close; public double Open; public double Close; public double Low; public double High; [Parameter("Candle width", DefaultValue = 20)] public int CandleWidth { get; set; } [Parameter("Up color", DefaultValue = "Green")] public string UpColor { get; set; } [Parameter("Down color", DefaultValue = "Pink")] public string DownColor { get; set; } private Colors _upColor; private Colors _downColor; private bool _incorrectColors; private Random _random = new Random(); protected override void Initialize() { _Open = CreateDataSeries(); _Close = CreateDataSeries(); if (!Enum.TryParse(UpColor, out _upColor) || !Enum.TryParse(DownColor, out _downColor)) _incorrectColors = true; } public override void Calculate(int index) { if (_incorrectColors) { var errorColor = _random.Next(2) == 0 ? Colors.Red : Colors.White; ChartObjects.DrawText("Error", "Incorrect colors", StaticPosition.Center, errorColor); return; } if ((Server.Time.Minute == 4 || Server.Time.Minute == 9 || Server.Time.Minute == 14 || Server.Time.Minute == 19 || Server.Time.Minute == 24 || Server.Time.Minute == 29 || Server.Time.Minute == 34 || Server.Time.Minute == 39 || Server.Time.Minute == 44 || Server.Time.Minute == 49 || Server.Time.Minute == 54 || Server.Time.Minute == 59) && Server.Time.Second > 55) { var open = MarketSeries.Open[index]; var high = MarketSeries.High[index]; var low = MarketSeries.Low[index]; var close = MarketSeries.Close[index]; var open1 = MarketSeries.Open[index - 1]; var high1 = MarketSeries.High[index - 1]; var low1 = MarketSeries.Low[index - 1]; var close1 = MarketSeries.Close[index - 1]; var open2 = MarketSeries.Open[index - 2]; var high2 = MarketSeries.High[index - 2]; var low2 = MarketSeries.Low[index - 2]; var close2 = MarketSeries.Close[index - 2]; var open3 = MarketSeries.Open[index - 3]; var high3 = MarketSeries.High[index - 3]; var low3 = MarketSeries.Low[index - 3]; var close3 = MarketSeries.Close[index - 3]; var open4 = MarketSeries.Open[index - 4]; var high4 = MarketSeries.High[index - 4]; var low4 = MarketSeries.Low[index - 4]; var close4 = MarketSeries.Close[index - 4]; Close = close; double Open; if (index > 0) Open = open4; else Open = open4; High = Math.Max(Math.Max(Math.Max(Math.Max(high, high1), high2), high3), high4); Low = Math.Min(Math.Min(Math.Min(Math.Min(low, low1), low2), low3), low4); var color = Open > Close ? _downColor : _upColor; ChartObjects.DrawLine("candle" + index, index, Open, index, Close, color, CandleWidth, LineStyle.Solid); ChartObjects.DrawLine("line" + index, index, High, index, Low, color, 1, LineStyle.Solid); _Open[index] = Open; _Close[index] = Close; } } } } Cabe destacar, que las dibuja conforme pasa el tiempo, no se como hacer que las dibuje de un solo paso.
free  26 Mar 2015
3 EMA MTF (Multi-timeframe) using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)] public class EMAMTF : Indicator { [Parameter(DefaultValue = 14)] public int Periods { get; set; } [Parameter("EMA Timeframe1", DefaultValue = "Minute15")] public TimeFrame EMATimeframe1 { get; set; } [Parameter("EMA Timeframe2", DefaultValue = "Hour")] public TimeFrame EMATimeframe2 { get; set; } [Parameter("EMA Timeframe3", DefaultValue = "Hour4")] public TimeFrame EMATimeframe3 { get; set; } [Output("EMA1", Color = Colors.Blue)] public IndicatorDataSeries EMA1 { get; set; } [Output("EMA2", Color = Colors.Red)] public IndicatorDataSeries EMA2 { get; set; } [Output("EMA3", Color = Colors.Yellow)] public IndicatorDataSeries EMA3 { get; set; } private MarketSeries series1; private MarketSeries series2; private MarketSeries series3; private ExponentialMovingAverage Ema1; private ExponentialMovingAverage Ema2; private ExponentialMovingAverage Ema3; protected override void Initialize() { series1 = MarketData.GetSeries(EMATimeframe1); series2 = MarketData.GetSeries(EMATimeframe2); series3 = MarketData.GetSeries(EMATimeframe3); Ema1 = Indicators.ExponentialMovingAverage(series1.Close, Periods); Ema2 = Indicators.ExponentialMovingAverage(series2.Close, Periods); Ema3 = Indicators.ExponentialMovingAverage(series3.Close, Periods); } public override void Calculate(int index) { var index1 = GetIndexByDate(series1, MarketSeries.OpenTime[index]); if (index1 != -1) { EMA1[index] = Ema1.Result[index1]; } var index2 = GetIndexByDate(series2, MarketSeries.OpenTime[index]); if (index2 != -1) { EMA2[index] = Ema2.Result[index2]; } var index3 = GetIndexByDate(series3, MarketSeries.OpenTime[index]); if (index3 != -1) { EMA3[index] = Ema3.Result[index3]; } } private int GetIndexByDate(MarketSeries series, DateTime time) { for (int i = series.Close.Count - 1; i > 0; i--) { if (time == series.OpenTime[i]) return i; } return -1; } } }  
free  25 Mar 2015
Triple Exponential Moving Average, or TEMA with Multi-timeframe indicator used: /algos/indicators/show/15 using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)] public class TEMAMTF : Indicator { [Parameter(DefaultValue = 5)] public int PeriodFast { get; set; } [Parameter(DefaultValue = 21)] public int PeriodSlow { get; set; } [Parameter("TEMA Timeframe", DefaultValue = "Daily")] public TimeFrame TEMATimeframe { get; set; } [Output("TFast", Color = Colors.Blue)] public IndicatorDataSeries TFast { get; set; } [Output("TSlow", Color = Colors.Red)] public IndicatorDataSeries TSlow { get; set; } private MarketSeries series1D; private TEMA TemaFast; private TEMA TemaSlow; protected override void Initialize() { series1D = MarketData.GetSeries(TEMATimeframe); TemaFast = Indicators.GetIndicator(series1D.Close, PeriodFast); TemaSlow = Indicators.GetIndicator(series1D.Close, PeriodSlow); } public override void Calculate(int index) { var index1 = GetIndexByDate(series1D, MarketSeries.OpenTime[index]); if (index1 != -1) { TFast[index] = TemaFast.tema[index1]; TSlow[index] = TemaSlow.tema[index1]; } } private int GetIndexByDate(MarketSeries series, DateTime time) { for (int i = series.Close.Count - 1; i > 0; i--) { if (time == series.OpenTime[i]) return i; } return -1; } } }  
Break Out Candles
  15
  5
  5122
free  26 Mar 2015
Only break out candles have Green and Red color.  The other candles are by default LightGray for both up and down, but you can give them separate colors if you want.  A break out candle is defined as a candle that closes above the high or below the low of the previous candle.   These break out candles can be adjusted from 1 to 8 bars.  Thus if the setting is 4, then  the red and green candles appear only if they have closed above the high or below the low of the last 4 previous candles.   The default setting is set to 2 candles .  The pictures below show the setting for 2 and for 8. The only BO candle indicator that I have seen only used 1 candle. I usually use 2, 4 and 8,  but I thought I should just include all of the numbers up to 8.  So you can pick any number between 1 and 8. You will want to adjust your chart colors so that bull and bear outlines are the same color as your background.  That way you won't see any vestiges of the original candle underneath. BY THE WAY, you can can turn these into candles that only show the high and low without open and close by setting the wick thickness to equal the candle thickness. ALSO you can make them wickless by setting the wick thickness to zero.
free  23 Mar 2015
Normal candles with Heikin Ashi (HA) colors.  When HA would be green we have light and dark green candles (or whatever colors you want), when HA would be red we have light and dark red candles.   The idea is that HA candles hide the way the candles really look.  So here the HA color is preserved which is a trend signal, but the candle shape is preserved for purposes of price action analysis.  The code was adapted from the Heikin Ashi code at this site. You will want to adjust your chart colors so that bull and bear outlines are the same color as your background.  That way you won't see any vestiges of the original candle underneath.
Raghee's Wave Candles
  1
  5
  2834
free  23 Mar 2015
Similar to MAcc (moving average color candles) these candles have 2 shades of green, blue and red each.  They are Raghee Horner's Wave candles. Also known as her Green Red and Blue (GRaB) candles.    The idea is that there is a 34EMA on the High, Low and Close.  Candles above the high are light and dark green.  Candles below the low are light and dark red.  And candles that close between those two are blue. The candles are posted elsewhere on this site as three separate indicators converted direct from the MT4.  But here there is only one indicator, and the EMA period and type is easily adjusted. You will want to adjust your chart colors so that bull and bear outlines are the same color as your background.  That way you won't see any vestiges of the original candle underneath.
free  23 Mar 2015
Light and dark green candles above the selected moving average, and light and dark red candles below.   Candles are adjustable in size for both the body and the wick of the candles.  Moving average type and period is also adjustable.  The code was adapted from the Heikin Ashi code at this site. You will want to adjust your chart colors so that bull and bear outlines are the same color as your background.  That way you won't see any vestiges of the original candle underneath.
free  28 Mar 2015
Here you have the HL barchart, without the open and close dashes of the standard OHLC appearance, that are in my opinion arbitrary and therefore useless. You have to switch to line chart and change the "Bear Outline" color to the same as your background color of the underlying chart to make the price series disappear. Currently there is no other way to hide the price series. With the "Volume Bars?" parameter switched to "yes" it turns into the SierraChart style high-low volume barchart, where the width of the bars is determined by the underlying volume. This can be controlled with the "Minimum Bar Thickness" and the "Max. Bar Thickness (Volume Bars)" parameter. Note that these are NOT tick or volume charts where the volume would be the same for every bar.  I wanted to create something that resembles what is sometimes called "equivolume charts" as close as possible. It is self adjusting to current volume levels. This can be controlled with the "Lookback" parameter that controls the window width of the volume analysis. It also features a current price marker (see red triangle at the end of the priceseries), for those who don't like the distractiveness and the cluttering of the platforms own bid-ask lines. Right now all the colors can only be chosen by typing in the name of the color.   Changes: V1.01: Corrected a minor flaw in the algorithm V1.02: Removed unnessessary lines of code and further optimized logic. Removed redundant variable declarations. V1.03: Speed increase up to 25% by removing redundant operations. Changed the categorization process to exclude current forming bar. V1.04 Corrected a problem were some bars would be wrongly categorized and appear too thin in the Volume Barchart.
Depth of market (dom)
  0
  0
  3438
free  20 Mar 2015
Indicator show depth of market on the chart. Bids = blue lines Asks = red lines Change len and thickness in parameters.