mrlukesprague
mrlukesprague's avatar

Info

Username:mrlukesprague
Name:mrlukesprague
Member since: 17 Sep 2021

About

None

Signature

None

Last Forum Posts

@Supertrend bot:  25 Jan 2023, 17:34


Hey gang, 

Seeking some wisdom on this bot. 

using the Supertrend indicator it should open and reverse trades in line with the UpTrend or DownTrend properties  - but when i go to backtest it just doesn't open a position - any help appreciated 

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SupertrendSample : Robot
    {
        private double _volumeInUnits;

        private Supertrend _supertrend;

        [Parameter("Volume (Lots)", DefaultValue = 0.01)]
        public double VolumeInLots { get; set; }

        [Parameter("Label", DefaultValue = "Sample")]
        public string Label { get; set; }

        [Parameter("Period", DefaultValue = 10)]
        public int Period { get; set; }

        [Parameter("Multiplier", DefaultValue = 3)]
        public double Multiplier { get; set; }

        protected override void OnStart()
        {
            _volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
            _supertrend = Indicators.Supertrend(Period, Multiplier);
        }

        protected override void OnBar()
        {
            var position = Positions.Find(Label);
            if (position != null)
            {
                if ((position.TradeType == TradeType.Buy && _supertrend.Trend.Last(1) == -1) ||
                    (position.TradeType == TradeType.Sell && _supertrend.Trend.Last(1) == 1))
                {
                    ReversePosition(position);
                }
            }
            else
            {
                if (_supertrend.Trend.Last(1) == 1)
                {
                    ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label, null, null);
                }
                else if (_supertrend.Trend.Last(1) == -1)
                {
                    ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label, null, null);
                }
            }
        }
    }
}
 

@Price/EMA crossover cBot:  10 Nov 2022, 13:58


im tying to build a bot that reversed an open trade once a 9 and 18 ema cross can anyone help?

nguyendan81985 said:

matt_graham_92@hotmail.com said:

Does anyone know where I can download a cbot for instance #2 mentioned above.. price close above ema, auto(bot) long, till price close below ema, auto(bot) close long, and then takes the short?

just copy and paste. hihi

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.