Information

Username: ctraderbeta
Member since: 11 Feb 2020
Last login: 21 Jul 2023
Status: Active

Activity

Where Created Comments
Algorithms 0 5
Forum Topics 1 0
Jobs 0 0

Last Algorithm Comments

CT
ctraderbeta · 1 year ago

@Ryosuke 
I had the same problem.  This does not work for non USA date systems (dd-MM-yyyy vs MM-dd-yyyy) 

If you look in the log tab will have a crashed error

“21/07/2023 04:47:59.020 | Crashed in Initialize with FormatException: String was not recognized as a valid DateTime.”

 

Line 139 needs to be changed from 

var pstTime = System.TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(Datetime2), TimeZone);
 

to:

 

var pstTime = System.TimeZoneInfo.ConvertTimeFromUtc(DateTime.ParseExact(Datetime, "MM-dd-yyyy h:mmtt", CultureInfo.InvariantCulture), TimeZone); 

 

CT
ctraderbeta · 3 years ago

@tgjobscv To fix the buy issue.

When there are no buy trades the FindLowestPositionPrice is zero. The ask is never going to be less than zero.so the first buy trade will never happen

Add an || FindLowestPositionPrice == 0 to add the first buy
Change

 

// send buy orders

            if (direction == 1)
            {
                if (Math.Round(Symbol.Ask, Symbol.Digits) < Math.Round(FindLowestPositionPrice(TradeType.Buy) - PipStep * Symbol.PipSize, Symbol.Digits) || (FindLowestPositionPrice(TradeType.Buy) == 0 )

CT
ctraderbeta · 4 years ago

Hi,
I am trying to get this to work on multiple time frames.  But it only seems to work on the current time frame.
Any help would be appreciated 

 

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class UTBOTMT : Indicator
    {
        [Parameter("Key", DefaultValue = 1)]
        public double Keyvalue { get; set; }
        [Parameter("ATR Period", DefaultValue = 10)]
        public int Atrperiod { get; set; }

        [Parameter("Atr TimeFrame")]
        public TimeFrame AtrTimeFrame { get; set; }

        private AverageTrueRange xATR;

        [Output("Continuos", PlotType = PlotType.DiscontinuousLine, LineColor = "Yellow")]
        public IndicatorDataSeries XATRTrailingStop { get; set; }
        [Output("UpTrend", PlotType = PlotType.DiscontinuousLine, LineColor = "Green")]
        public IndicatorDataSeries XATRTrailingStopGreen { get; set; }
        [Output("DownTrend", PlotType = PlotType.DiscontinuousLine, LineColor = "Red")]
        public IndicatorDataSeries XATRTrailingStopRed { get; set; }


        protected override void Initialize()
        {
            xATR = Indicators.AverageTrueRange(MarketData.GetBars(AtrTimeFrame), Atrperiod, MovingAverageType.Exponential);
        }

        public override void Calculate(int index)
        {
            double nLoss = Keyvalue * xATR.Result[index];

            XATRTrailingStop[index] = (MarketData.GetBars(AtrTimeFrame).ClosePrices[index] > XATRTrailingStop[index - 1] && MarketData.GetBars(AtrTimeFrame).ClosePrices[index - 1] > XATRTrailingStop[index - 1]) ? Math.Max(XATRTrailingStop[index - 1], MarketData.GetBars(AtrTimeFrame).ClosePrices[index] - nLoss) : (MarketData.GetBars(AtrTimeFrame).ClosePrices[index] < XATRTrailingStop[index - 1] && MarketData.GetBars(AtrTimeFrame).ClosePrices[index - 1] < XATRTrailingStop[index - 1]) ? Math.Min(XATRTrailingStop[index - 1], MarketData.GetBars(AtrTimeFrame).ClosePrices[index] + nLoss) : (MarketData.GetBars(AtrTimeFrame).ClosePrices[index] > XATRTrailingStop[index - 1]) ? MarketData.GetBars(AtrTimeFrame).ClosePrices[index] - nLoss : MarketData.GetBars(AtrTimeFrame).ClosePrices[index] + nLoss;

            XATRTrailingStopGreen[index] = XATRTrailingStop[index] < MarketData.GetBars(AtrTimeFrame).ClosePrices[index] ? XATRTrailingStop[index] : double.NaN;
            XATRTrailingStopRed[index] = XATRTrailingStop[index] > MarketData.GetBars(AtrTimeFrame).ClosePrices[index] ? XATRTrailingStop[index] : double.NaN;

        }
    }
}
 

CT
ctraderbeta · 4 years ago

Fix detail here 

https://ctrader.com/forum/third-party-products/22853

My OnStart() now as follows 

 

protected override void OnStart()
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // If you didn't set a channel, then find channels by looking at the updates
            if (string.IsNullOrEmpty(ChannelId))
            {
                _telegramChannels = ParseChannels(GetBotUpdates());
            }
            else
            {
                _telegramChannels.Add(ChannelId);
            }
            SendMessageToAllChannels("Hellow world.. ");

        }

CT
ctraderbeta · 4 years ago

I have having the same issue.

Crashed in OnStart with WebException: The request was aborted: Could not create SSL/TLS secure channel.

When I run this is Visual studio with dubug it does not trap any error