khoshroomahdi's avatar
Mahdi
Mahdi 's avatar

Info

Username:khoshroomahdi
Name:Mahdi
Member since: 17 Jun 2021

About

None

Signature

None

Last Algorithm Comments

@AW Moving Cloud:  12 Dec 2021, 22:44


@opit78 how could we have sepeate color for cloud and moving average? for example: different color for fast ema and up cloud.

@AW Moving Cloud:  12 Dec 2021, 22:43


@opit78 May i Use your code to update this indicator?

@Pattern Drawing:  22 Jun 2021, 20:12


why you didin't add this code to internal ctrader tools.? ex: Draw Traingle and fork is better than default tools

@Draw Spread:  18 Jun 2021, 16:54


Please add color parameter. enable $disable label, position on chart parameter

Last Forum Posts

@Add color input parameter in ctrader api:  13 Jan 2022, 09:32


please add this fucntion to api.

ex: i made an indicator that show text on chart. trader have to write name of color. it should be select color like output.

@Lock Charts When zooming in timeframes:  13 Jan 2022, 09:29


it's great

now i made an indicator ( aw vline). you could use that.

but it would be great if ctrader implement it as an internal feature

@add balance graph to statment export:  13 Jan 2022, 09:21


it would be great it when we export statment have graph based on trade not based on time like analyse in ctrader. metatrader is great for this option.

@add duration time to statement:  13 Jan 2022, 09:13


please add duration time column to statement.

trader should know how trade take time.

@ichimoku code:  28 Dec 2021, 10:22


i need deault ichimoku code for ctrader indicator

@macd signal line cross alert:  23 Dec 2021, 21:07


amusleh said:

Hi,

What do you mean by: "i dont' know how to add signal line cross histogram to it?"

Can you show this on a chart screenshot?

Not sure about the exact size of library but if you use the newer version library the size might reduce.

You don't need that library to show a popup alert or play a sound alert.

cTrader automate API has the email and sound alert itself under Notifications: cAlgo API Reference - INotifications Interface (ctrader.com)

i make it. thanks for your amazing library.

it is 10 megabyte with source and i couldn't upload in algorithms.

using cAlgo.API;
using cAlgo.API.Alert;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class MacdHistogramAlert : Indicator
    {
        #region Fields

        private MacdHistogram _macdHistogram;

        private int _barIndex;

        #endregion Fields

        #region Parameters

        [Parameter()]
        public DataSeries Source { get; set; }

        [Parameter("Long Cycle", DefaultValue = 26)]
        public int LongCycle { get; set; }

        [Parameter("Short Cycle", DefaultValue = 12)]
        public int ShortCycle { get; set; }

        [Parameter("Signal Periods", DefaultValue = 9)]
        public int Periods { get; set; }

        [Parameter("Histogram Alert", DefaultValue = true)]
        public bool macdh { get; set; }

        [Parameter("Signal Alert", DefaultValue = true)]
        public bool macds { get; set; }
        #endregion Parameters

        #region Outputs

        [Output("Macd Up", LineColor = "Green", PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries HistogramPositive { get; set; }

        [Output("Macd Down", LineColor = "Red", PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries HistogramNegative { get; set; }

        [Output("Signal", LineColor = "Blue", LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries Signal { get; set; }

        #endregion Outputs

        #region Methods

        protected override void Initialize()
        {
            _macdHistogram = Indicators.MacdHistogram(Source, LongCycle, ShortCycle, Periods);
        }

        public override void Calculate(int index)
        {
            if (_macdHistogram.Histogram[index] > _macdHistogram.Signal[index])
            {
                HistogramPositive[index] = _macdHistogram.Histogram[index];
            }

            if (_macdHistogram.Histogram[index] < _macdHistogram.Signal[index])
            {
                HistogramNegative[index] = _macdHistogram.Histogram[index];
            }

            Signal[index] = _macdHistogram.Signal[index];

            if (macdh)
            {

                if (_macdHistogram.Histogram[index - 2] <= 0 && _macdHistogram.Histogram[index - 1] > 0)
                {
                    TriggerAlert(TradeType.Buy, index);
                }
                else if (_macdHistogram.Histogram[index - 2] >= 0 && _macdHistogram.Histogram[index - 1] < 0)
                {
                    TriggerAlert(TradeType.Sell, index);
                }
            }

            if (macds)
            {

                if (_macdHistogram.Histogram[index - 2] <= _macdHistogram.Signal[index - 2] && _macdHistogram.Histogram[index - 1] > _macdHistogram.Signal[index - 1])
                {
                    TriggerAlert2(TradeType.Buy, index);
                }
                else if (_macdHistogram.Histogram[index - 2] >= _macdHistogram.Signal[index - 2] && _macdHistogram.Histogram[index - 1] < _macdHistogram.Signal[index - 1])
                {
                    TriggerAlert2(TradeType.Sell, index);
                }
            }

        }

        private void TriggerAlert(TradeType tradeType, int index)
        {
            if (_barIndex != index && IsLastBar)
            {
                _barIndex = index;

                string comment = tradeType == TradeType.Buy ? "Histogram is above 0" : "Histogram is below 0";
                Notifications.ShowPopup(TimeFrame, Symbol, tradeType, "MACD Alert", Bars.ClosePrices[index], comment);
            }

        }

        private void TriggerAlert2(TradeType tradeType, int index)
        {
            if (_barIndex != index && IsLastBar)
            {
                _barIndex = index;

                string comment = tradeType == TradeType.Buy ? "Histogram is above signal" : "Histogram is below signal";
                Notifications.ShowPopup(TimeFrame, Symbol, tradeType, "MACD Alert", Bars.ClosePrices[index], comment);
            }

        }

        #endregion Methods
    }
}

@macd signal line cross alert:  22 Dec 2021, 21:33


i find this code for macd alert.

cTDN Forum - Adding a Crossover alert (ctrader.com)

i dont' know how to add signal line cross histogram to it?

other problem is about this library. i add it to indicator and now it has 10 megabyte. is there any way to reduce size of this indicator? i just need pop up alert without telegram and email.

how can i add sound to alert?

using cAlgo.API;
using cAlgo.API.Alert;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class MacdHistogramAlert : Indicator
    {
        #region Fields

        private MacdHistogram _macdHistogram;

        private int _lastAlertBarIndex;

        #endregion Fields

        #region Parameters

        [Parameter()]
        public DataSeries Source { get; set; }

        [Parameter("Long Cycle", DefaultValue = 26)]
        public int LongCycle { get; set; }

        [Parameter("Short Cycle", DefaultValue = 12)]
        public int ShortCycle { get; set; }

        [Parameter("Signal Periods", DefaultValue = 9)]
        public int Periods { get; set; }

        #endregion Parameters

        #region Outputs

        [Output("Histogram > 0", PlotType = PlotType.Histogram, Color = Colors.Green, Thickness = 2)]
        public IndicatorDataSeries HistogramPositive { get; set; }

        [Output("Histogram < 0", PlotType = PlotType.Histogram, Color = Colors.Red, Thickness = 2)]
        public IndicatorDataSeries HistogramNegative { get; set; }

        [Output("Signal", Color = Colors.Purple, LineStyle = LineStyle.Lines)]
        public IndicatorDataSeries Signal { get; set; }

        #endregion Outputs

        #region Methods

        protected override void Initialize()
        {
            _macdHistogram = Indicators.MacdHistogram(Source, LongCycle, ShortCycle, Periods);
        }

        public override void Calculate(int index)
        {
            if (_macdHistogram.Histogram[index] > 0)
            {
                HistogramPositive[index] = _macdHistogram.Histogram[index];
            }

            if (_macdHistogram.Histogram[index] < 0)
            {
                HistogramNegative[index] = _macdHistogram.Histogram[index];
            }

            Signal[index] = _macdHistogram.Signal[index];

            if (_macdHistogram.Histogram[index - 2] <= 0 && _macdHistogram.Histogram[index - 1] > 0)
            {
                TriggerAlert(TradeType.Buy, index);
            }
            else if (_macdHistogram.Histogram[index - 2] >= 0 && _macdHistogram.Histogram[index - 1] < 0)
            {
                TriggerAlert(TradeType.Sell, index);
            }
        }

        private void TriggerAlert(TradeType tradeType, int index)
        {
            if (index == _lastAlertBarIndex || !IsLastBar)
            {
                return;
            }

            string comment = tradeType == TradeType.Buy ? "Histogram is above 0" : "Histogram is below 0";

            Notifications.ShowPopup(TimeFrame, Symbol, MarketSeries.Close[index], "MACD Histogram Alert", tradeType, comment);
        }

        #endregion Methods
    }
}

@horizontal line y:  22 Dec 2021, 14:24


thanks

amusleh said:

Hi,

Please read API references and check the examples there before asking a question: cAlgo API Reference - ChartHorizontalLine Interface (ctrader.com)

Try this:

using System;
using System.Linq;
using cAlgo.API;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWCPDaily : Robot
    {
        private TextBlock tb = new TextBlock();
        private ChartHorizontalLine sll;

        [Parameter("Take Profit", DefaultValue = 100)]
        public double tp { get; set; }

        [Parameter("Stop Profit", DefaultValue = 90)]
        public double sl { get; set; }

        [Parameter("FontSize", DefaultValue = 16, Group = "Text")]
        public int FontSize { get; set; }

        [Parameter("Space to Corner", DefaultValue = 10, Group = "Text")]
        public int Margin { get; set; }

        [Parameter("Horizental Alignment", DefaultValue = HorizontalAlignment.Left, Group = "Text")]
        public HorizontalAlignment HAlignment { get; set; }

        [Parameter("Vertical Alignment", DefaultValue = VerticalAlignment.Top, Group = "Text")]
        public VerticalAlignment VAlignment { get; set; }

        [Parameter("Color", DefaultValue = "Red", Group = "Text")]
        public string Color1 { get; set; }

        [Parameter("Opacity", DefaultValue = 0.7, MinValue = 0.1, MaxValue = 1, Group = "Text")]
        public double Opacity { get; set; }

        [Parameter("Text Alignment", DefaultValue = TextAlignment.Center, Group = "Text")]
        public TextAlignment Alignment { get; set; }

        protected override void OnStart()
        {
            var y = Chart.BottomY + ((Chart.TopY - Chart.BottomY) / 2);

            sll = Chart.DrawHorizontalLine("horizontal", y, Color.Red);

            sll.IsInteractive = true;

            Chart.AddControl(tb);
            tb.Text = "sl : " + sl.ToString() + ", " + "tp : " + tp.ToString() + "\n EQ: " + Account.Equity + ", ML%: " + Account.MarginLevel + "\nVP: " + Account.Margin / Account.Balance + "V: " + sll.Y;
            tb.FontSize = FontSize;
            tb.ForegroundColor = Color1.TrimEnd();
            tb.HorizontalAlignment = HAlignment;
            tb.VerticalAlignment = VAlignment;
            tb.TextAlignment = Alignment;
            tb.Margin = Margin;
            tb.Opacity = Opacity;
        }

        protected override void OnTick()
        {
            foreach (var position in Positions)
            {
                if (Account.Equity > tp || Account.Equity < sl)
                {
                    ClosePositionAsync(position);
                }
            }

            foreach (var order in PendingOrders)
            {
                if (Account.Equity > tp || Account.Equity < sl)
                {
                    CancelPendingOrder(order);
                }
            }
        }
    }
}

You have to set a chart object IsInteractive property to true, then you will be able to change it on the chart.

@horizontal line y:  21 Dec 2021, 15:16


i have cbot manager bot. i want this bot add a horizontal line to my chart and user could change that line.

i want my robot show me volume based my stop lost. and this horizontal line is stop lost that user could modify and move it.

i make that but code doesn't move. and i dont know how could i set y index while robot running in center of chart..

i tried with chart.drawhorionalline but i couldn't access y inedes in my code. and user could'nt move line?

other question: could we have access volume in one click trading in code?

using System;
using System.Linq;
using cAlgo.API;


namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWCPDaily : Robot
    {

        TextBlock tb = new TextBlock();
        Chart.DrawHorizontalLine sll;

        [Parameter("Take Profit", DefaultValue = 100)]
        public double tp { get; set; }
        [Parameter("Stop Profit", DefaultValue = 90)]
        public double sl { get; set; }
        [Parameter("FontSize", DefaultValue = 16, Group = "Text")]
        public int FontSize { get; set; }
        [Parameter("Space to Corner", DefaultValue = 10, Group = "Text")]
        public int Margin { get; set; }
        [Parameter("Horizental Alignment", DefaultValue = HorizontalAlignment.Left, Group = "Text")]
        public HorizontalAlignment HAlignment { get; set; }
        [Parameter("Vertical Alignment", DefaultValue = VerticalAlignment.Top, Group = "Text")]
        public VerticalAlignment VAlignment { get; set; }
        [Parameter("Color", DefaultValue = "Red", Group = "Text")]
        public string Color1 { get; set; }
        [Parameter("Opacity", DefaultValue = 0.7, MinValue = 0.1, MaxValue = 1, Group = "Text")]
        public double Opacity { get; set; }
        [Parameter("Text Alignment", DefaultValue = TextAlignment.Center, Group = "Text")]
        public TextAlignment Alignment { get; set; }
        protected override void OnStart()
        {
            Chart.AddControl(sll);


            Chart.AddControl(tb);
            tb.Text = "sl : " + sl.ToString() + ", " + "tp : " + tp.ToString() + "\n EQ: " + Account.Equity + ", ML%: " + Account.MarginLevel + "\nVP: " + Account.Margin / Account.Balance + "V: " + sll.y;
            tb.FontSize = FontSize;
            tb.ForegroundColor = Color1.TrimEnd();
            tb.HorizontalAlignment = HAlignment;
            tb.VerticalAlignment = VAlignment;
            tb.TextAlignment = Alignment;
            tb.Margin = Margin;
            tb.Opacity = Opacity;
        }

        protected override void OnTick()
        {


            foreach (var position in Positions)
            {
                if (Account.Equity > tp || Account.Equity < sl)
                {
                    ClosePositionAsync(position);
                }

            }

            foreach (var order in PendingOrders)
            {
                if (Account.Equity > tp || Account.Equity < sl)
                {
                    CancelPendingOrder(order);
                }
            }

        }

    }


}

@How could i add Slowing to this code?:  15 Dec 2021, 22:37


how could i add slowing to this code?

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

namespace cAlgo
{
    [Levels(1)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWStochasticLimitless : Indicator
    {

        private double UpperResult1;
        private double LowerResult1;

        [Parameter("K% periods 1", DefaultValue = 5)]
        public int inpKPeriods1 { get; set; }

        [Parameter("K% Slowing", DefaultValue = 1)]
        public int inpKSlowing { get; set; }

        [Output("K% 1", LineColor = "Black", LineStyle = LineStyle.Dots, Thickness = 2)]
        public IndicatorDataSeries k1 { get; set; }


        protected override void Initialize()
        {

        }


        public override void Calculate(int index)
        {

            UpperResult1 = Bars.HighPrices.Maximum(inpKPeriods1);
            LowerResult1 = Bars.LowPrices.Minimum(inpKPeriods1);
            k1[index] = (Bars.ClosePrices[index]) / ((UpperResult1 + LowerResult1) / 2);


        }

    }

}
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.
AW Ichimoku
  1
  0
  336
free  28 Dec 2021
it's defualt ichimoku but you could use differnet color for kumo and span A and span B.
AW Box Live
  1
  0
  303
free  15 Dec 2021
this indicator add rectangle to your chart from last bar. update: add Mid Line.  
AW Moving Cloud
  8
  0
  656
free  28 Dec 2021
 moving average cloud. you could change cloud color. to disable cloud just set color as transparent.  
AW Macd Color
  1
  0
  735
free  14 Dec 2021
MACD Default Color like AWESOME OSCILLATOR (AO)   update: I add signal line to this indicator.    
AW Coral
  1
  0
  686
free  16 Jul 2021
Coral indicator
AW Multi Data
  1
  5
  534
free  09 Sep 2021
show symbol and time fram, daily net profit percent, daily net profit, and spread ln your chart. consider that timezone set to utc to show daily proift correctly.      
AW Spread
  0
  0
  923
free  15 Jul 2021
show spread on chart    
AW Moving MTF
  1
  0
  611
free  15 Jul 2021
multi time frame moving averge. you could choose different type of price like median ,high and ... and differnt type of moving average. you could shift moving in this indicator.    
AW Moving Average
  0
  0
  859
free  28 Jun 2021
 this moving include everything that a trader needs from Moving Average. PriceType: Open,Close,High,Low, Median,Typical,Weighted Support all moving average type.      
AW Vline
  0
  0
  788
free  25 Jun 2021
don't move to the end of chart after timeframe changing. it should be better to use for near history. for long history this have delay.
Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
AW CP Step
  1
  0
  538
free  20 Aug 2021
this bot close all position and cancel all order after get step profit percent. step calculate by ((equity/balance)-1)*100
AW CP Daily
  1
  0
  588
free  20 Aug 2021
AW Close Position. this bot close all position and cancel all order after get daily profit percent.