hassan yaghouti
hassan yaghouti's avatar


Name:hassan yaghouti
Member since: 19 Dec 2019


Forex Trader



Last Algorithm Comments

@Simple Trading Panel:  16 Jul 2021, 09:06

Hi how could we change and refresh the information on textbox and checkboxes?

Last Forum Posts

@inserting commission in risk calculation:  04 Aug 2021, 09:17


i use this code for calculating the volume per risk:

/// <summary>
/// Returns the amount of volume based on your provided risk percentage and stop loss
/// </summary>
/// <param name="symbol">The symbol</param>
/// <param name="riskPercentage">Risk percentage amount</param>
/// <param name="accountBalance">The account balance</param>
/// <param name="stopLossInPips">Stop loss amount in Pips</param>
/// <returns>double</returns>
public static double GetVolume(this Symbol symbol, double riskPercentage, double accountBalance, double stopLossInPips)
return symbol.NormalizeVolumeInUnits(riskPercentage / (Math.Abs(stopLossInPips) * symbol.PipValue / accountBalance * 100));

how is it possible to consider symbol commission inside this?

after opening position we can get the commission with position.Commissions but before entering the position how could we get it to insert this formula?

the second point is above code do not consider spread, how could we consider spread in this volume calculation?

@Opening Position directly from indicator?:  29 Jul 2021, 17:12


I make some buttons inside indicator to show inside chart to open position quickly, is it possible to open or close a position directly from indicator class not from robot class?

@trendline stoploss:  23 Jul 2021, 17:25

Hi again

just one more problem.

i try to use this linePriceValue in for my stoploss:

position.ModifyStopLossPrice(Math.Round(DefaultSTL,Symbol.Digits)); or position.ModifyStopLossPrice(DefaultSTL);

but unfortunately i get the error:

23/07/2021 18:50:48.947 | → Modifying position PID17057357 (SL: 1.17751257895653, TP: 1.17541361298747) FAILED with error "InvalidStopLossTakeProfit", Position PID17057357

i print the linePriceValue and the printed value is OK but when i try to assign it to my position stoploss i get the error.

amusleh said:


You can draw an interactive chart trend line and then whenever the user changed it you can use the chart objects updated event.

@trendline stoploss:  23 Jul 2021, 15:56

Hi Ahmad
thank you VERY MUCH, it works now

thanks for code.

amusleh said:


You can draw an interactive chart trend line and then whenever the user changed it you can use the chart objects updated event.

@trendline stoploss:  23 Jul 2021, 14:18


thanks for reply

i just need one line, which could be change by user on the chart, and in the bot side, we can get it's Y and compare with price, the most important point is that user can click and change the position or angle of the line

amusleh said:


You can use a chart trend line CalculateY method to check if the price is touched or not, this sample might help you:

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

namespace cAlgo
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class LineAlert : Indicator
        #region Parameters

        [Parameter("Single Alert", DefaultValue = true, Group = "General")]
        public bool SingleAlert { get; set; }

        [Parameter("Trend/Ray", DefaultValue = true, Group = "Line Types")]
        public bool TrendLine { get; set; }

        [Parameter("Horizontal", DefaultValue = true, Group = "Line Types")]
        public bool HorizontalLine { get; set; }

        [Parameter("Vertical", DefaultValue = true, Group = "Line Types")]
        public bool VerticalLine { get; set; }

        [Parameter("Show Comment", DefaultValue = true, Group = "Comment")]
        public bool ShowComment { get; set; }

        [Parameter("Comment Suffix", Group = "Comment")]
        public string CommentSuffix { get; set; }

        #endregion Parameters

        #region Overridden methods

        protected override void Initialize()

        public override void Calculate(int index)
            foreach (var chartObject in Chart.Objects)
                if (!string.IsNullOrEmpty(CommentSuffix) && !chartObject.Comment.EndsWith(CommentSuffix, StringComparison.InvariantCultureIgnoreCase))

				var isAlert = false;
                if (chartObject.ObjectType == ChartObjectType.TrendLine || chartObject.ObjectType == ChartObjectType.HorizontalLine)
                    var linePriceValue = double.NaN;

                    if (TrendLine && chartObject.ObjectType == ChartObjectType.TrendLine)
                        var chartTrendLine = chartObject as ChartTrendLine;

                        if (chartTrendLine != null) linePriceValue = chartTrendLine.CalculateY(index);
                    else if (HorizontalLine && chartObject.ObjectType == ChartObjectType.HorizontalLine)
                        var chartHorizontalLine = chartObject as ChartHorizontalLine;

                        if (chartHorizontalLine != null) linePriceValue = chartHorizontalLine.Y;

                    if (Bars.ClosePrices[index] >= linePriceValue && Bars.ClosePrices[index - 1] < linePriceValue)
                        isAlert = true;

                    if (Bars.ClosePrices[index] <= linePriceValue && Bars.ClosePrices[index - 1] > linePriceValue)
                        isAlert = true;
                else if (VerticalLine && chartObject.ObjectType == ChartObjectType.VerticalLine)
                    var chartVerticalLine = chartObject as ChartVerticalLine;

                    if (chartVerticalLine != null 
                        && Bars.OpenTimes[index] >= chartVerticalLine.Time 
                        && Bars.OpenTimes[index - 1] < chartVerticalLine.Time)
                        isAlert = true;

                if (isAlert)
                    // The code for alert goes here

        #endregion Overridden methods

@trendline stoploss:  23 Jul 2021, 13:23


how can i draw a trend line on the chart and make it as stop loss (or sometimes as target) , so when price cross it position close.

both trend line and horizontal line is needed.

it would be appreciated if anybody have a sample code to help us.

the most important point is that user can change the position of the line manually on the chart by clicking the line (similar to cTrader native stoploss line (horizontal or trendline)


@partial stoploss with cBot:  16 Jul 2021, 11:36

Hi Panagiotis 
thanks for reply
i exactly do the same it works in swing trades but my problem is that in scalp trades when we reach the target usually not execute at the point and close in next ticks which maybe lower prices. is there any trick to close position exactly at the trigger tick?


PanagiotisCharalampous said:

Hi yaghouti,

You can use ModifyVolume method to change the position's volume and partially close it at any stage of the execution. So if you want to close 50% of the position, just modify the volume to be half of the initial quantity.

Best Regards,


Join us on Telegram and Facebook

@partial stoploss with cBot:  13 Jul 2021, 11:47


how can i make a partial stoploss with cBot?

for example i want to close 50% of the total volume  in partial stoploss and 50% remain in the original stoploss

@Partial Stoploss:  13 Jul 2021, 11:26

Hi everybody

anybody could help me with making partial stoploss with cbot.

i want to trail partial stoploss so if it hit just 50% close with profit and the rest stoploss remain at the start point.

@Drawing change in position when using Range candles problem report:  17 Dec 2020, 13:11


When I draw a trend line in Ra (1.....) after some candles I realise that the line position changed a little and I have to adjust the lines again and again.

I don't know if its the same in regular time candles or not.


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.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.