Topics
20 Oct 2020, 11:30
 835
 4
Replies

charitydv
20 Oct 2020, 17:38

RE:

PanagiotisCharalampous said:

Hi charitydv,

You need to use the complete reference for the indicator. Post the code and I will fix it for you.

Best Regards,

Panagiotis 

Join us on Telegram

 Okay thank you so much. It is the first bot I write so maybe there it went wrong :)  Here it is :

 

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

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

        [Parameter("Fractal Period", DefaultValue = 10, MinValue = 10, MaxValue = 100, Step = 10)]
        public int param_fractal_period { get; set; }

        [Parameter("Fractal diff", DefaultValue = 0, MinValue = 0, MaxValue = 10, Step = 1)]
        public int param_fractal_diff { get; set; }

        [Parameter("Include Trailing Stop", Group = "Trailing Stop", DefaultValue = false)]
        public bool IncludeTrailingStop { get; set; }

        [Parameter("Trailing Stop Trigger (pips)", Group = "Trailing Stop", DefaultValue = 5)]
        public int TrailingStopTrigger { get; set; }

        [Parameter("Trailing Stop Step (pips)", Group = "Trailing Stop", DefaultValue = 1)]
        public int TrailingStopStep { get; set; }

        [Parameter("Min TP", DefaultValue = 30, MinValue = 5, MaxValue = 50, Step = 5)]
        public int param_min_take_profit { get; set; }

        [Parameter("Max TP", DefaultValue = 50, MinValue = 30, MaxValue = 50, Step = 1)]
        public int param_max_take_profit { get; set; }

        [Parameter("Volume Units", DefaultValue = 100000, MinValue = 1000, MaxValue = 1000000, Step = 1000)]
        public int volume_units { get; set; }

        private Fractals i_fractal;

        protected override void OnStart()
        {
            _fractal = Indicators.GetIndicator<Fractals>(_period);
        }

        protected override void OnBar()
        {
            var _fractaldown = Math.Round(_fractal.UpFractal.LastValue, Symbol.Digits);
            var _fractalup = Math.Round(_fractal.DownFractal.LastValue, Symbol.Digits);

            var position = ExecuteMarketOrder(TradeType.Buy, Symbol, 1000).Position;
            position.ModifyTakeProfitPrice(_fractaldown);
            position.ModifyStopLossPrice(_fractalup);
        }
    }
}


@charitydv