ONBAR SELL free

by cristianalejandropj2275 in category Other at 24/04/2022
Description

vende en cada vela segun su periodo de tiempo 

whatsapp   3218280967

correo cristianalejandropj@gmail.com

 

Warning! Executing the following cBot may result in loss of funds. Use it at your own risk.
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.
Formula / Source Code
Language: C#
Trading Platform: cAlgo
´╗┐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 ONBARDSELL : Robot
    {
        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.001, Step = 111)]
        public double Quantity { get; set; }

        [Parameter("Enable TakeProfit?", Group = "TakeProfit", DefaultValue = true)]
        public bool useTakeProfit { get; set; }

        [Parameter("Take Profit", Group = "TakeProfit", DefaultValue = 6.6, MinValue = 0.1, Step = 0.1)]
        public double takeProfit { get; set; }

        [Parameter("Enable Stop Loss?", Group = "StopLoss", DefaultValue = true)]
        public bool useStopLoss { get; set; }

        [Parameter("Stop Loss", Group = "StopLoss", DefaultValue = 0.1, MinValue = 0.1, Step = 0.1)]
        public double stopLoss { get; set; }

        private MovingAverage tenMinimum;
        private MovingAverage tenMaximum;

        private double volumeInUnits;

        protected override void OnStart()
        {
            volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);
            tenMaximum = Indicators.MovingAverage(Bars.LowPrices, 2, MovingAverageType.Simple);
            tenMinimum = Indicators.MovingAverage(Bars.HighPrices, 1, MovingAverageType.Simple);
        }

        protected override void OnBar()
        {
            if (Positions.Count() < 2)
            {
                if (Bars.LastBar.High <= tenMaximum.Result.LastValue && !useTakeProfit)
                {
                    foreach (var position in Positions)
                    {
                        ClosePosition(position);
                    }
                }
            }

            if (Bars.LastBar.Close <= tenMinimum.Result.LastValue)
            {
                ExecuteMarketOrder(TradeType.Sell, SymbolName, volumeInUnits, "TenMov", (useStopLoss ? stopLoss : double.MaxValue), (useTakeProfit ? takeProfit : double.MaxValue));

            }


        }
    }
}
Comments
0