Category Trend  Published on 27/04/2024

Bakshul Scalper

An update for this algorithm is currently pending moderation. Please revisit this page shortly to access the algorithm's latest version.
Description

using cAlgo.API;
using cAlgo.API.Indicators;
using System;

namespace cAlgo
{
   [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class UTBotAlerts : Indicator
   {
       // Indicator Parameters
       [Parameter("Key Value. This changes the sensitivity", DefaultValue = 1)]
       public double A { get; set; }

       [Parameter("ATR Period", DefaultValue = 10)]
       public int AtrPeriod { get; set; }

       [Parameter("Signals from Heikin Ashi Candles", DefaultValue = false)]
       public bool UseHeikinAshi { get; set; }

       private AverageTrueRange _atr;
       private double _nLoss;
       private double _xATRTrailingStop;
       private int _position;

       protected override void Initialize()
       {
           _atr = Indicators.AverageTrueRange(AtrPeriod);

           _nLoss = A * _atr.Result.Last(0);

           _position = 0;
       }

       public override void Calculate(int index)
       {
           double close = MarketSeries.Close[index];

           double src = UseHeikinAshi ? MarketSeries.GetHeikinAshi(index).Close : close;

           if (index > 0)
           {
               _xATRTrailingStop = src > _xATRTrailingStop && MarketSeries.Close[index - 1] > _xATRTrailingStop
                   ? Math.Max(_xATRTrailingStop, src - _nLoss)
                   : src < _xATRTrailingStop && MarketSeries.Close[index - 1] < _xATRTrailingStop
                       ? Math.Min(_xATRTrailingStop, src + _nLoss)
                       : src > _xATRTrailingStop
                           ? src - _nLoss
                           : src + _nLoss;

               _position = src < _xATRTrailingStop && MarketSeries.Close[index - 1] > _xATRTrailingStop
                   ? 1
                   : src > _xATRTrailingStop && MarketSeries.Close[index - 1] < _xATRTrailingStop
                       ? -1
                       : _position;
           }

           Color xColor = _position == -1 ? Color.Red : _position == 1 ? Color.Green : Color.Blue;

           if (index > 0)
           {
               double ema = Indicators.ExponentialMovingAverage(src, 1);

               bool above = ema > _xATRTrailingStop;
               bool below = _xATRTrailingStop > ema;

               bool buy = src > _xATRTrailingStop && above;
               bool sell = src < _xATRTrailingStop && below;

               ChartObjects.DrawText("Buy", "Buy", StaticPosition.BottomOfBar, xColor);
               ChartObjects.DrawText("Sell", "Sell", StaticPosition.AboveBar, xColor);

               ChartObjects.DrawLine("barbuy", index, src, _xATRTrailingStop, xColor);
               ChartObjects.DrawLine("barsell", index, src, _xATRTrailingStop, xColor);

               if (buy)
                   Notifications.Alert("UT Long");

               if (sell)
                   Notifications.Alert("UT Short");
           }
       }
   }
}
 


The author decided to hide the source code.
HU
hunter577btc

Joined on 27.04.2024

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Algo Builder.algo
  • Rating: 0
  • Installs: 393
  • Modified: 27/04/2024 20:57
Comments
Log in to add a comment.
No comments found.