hold trendlines after restart bot

Created at 04 Feb 2023
R.

r.stipriaan

Joined 05.02.2021

Status

Closed


Budget

30.00 EUR


Payment Method

Direct Payment

Job Description

Hi, does anyone know if it is possible to keep chart drawings after restarting a bot?

When I start a bot it automatically draws a trendline right through the chrart until it gets drawn. if I stop the bot and start it again, the trendlines disappear and they are all across the chart again.

this problem does not happen in backtest.

Thank you in advance!

If you think you can solve my problem contact me on telegram @robinrvs

For example:

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class RS : Robot
    {


        private ChartTrendLine _trendLine1;


        protected override void OnStart()
        {

            
         _trendLine1 = Chart.DrawTrendLine("High1", Chart.FirstVisibleBarIndex, Chart.BottomY, Chart.LastVisibleBarIndex, Chart.TopY, Color.Red);

                                 
        }

        protected override void OnBar()
        {
        }


        protected override void OnTick()
        {
         
            _trendLine1.IsInteractive = true;
                   
            
            if (Bars.Last(0).High > Bars.Last(1).High & Bars.Last(1).High > Bars.Last(2).High )

            {
                DateTime x2 = Bars.Last(0).OpenTime;
                DateTime x1 = Bars.Last(10).OpenTime;
                double y1 = Bars.Last(0).High;
                double y2 = Bars.Last(0).High;

                Chart.DrawTrendLine("High1", x1, y1, x2, y2, Color.Red);
                

                
             }
            
        }
    }
}

 

Comments
No comments found.