Hora Específica de la estrategia free
Description
cBot el cual tiene la funcion de asignarle un horario de inicio y un horario de fin a la estrategia.
Este es un ejemplo ilustrativo de la aperura de New York en Horario UTC
Es importante colocar el Horario UTC y si tu horario es diferente al Horario UTC tienes que adecuarlo
Este ejemplo es del Nasdaq en 1 minuto (1M)
Autor: Jorge Eduardo Arteaga Galicia
@arteagagalicia
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
/*cBot el cual tiene la funcion de asignarle un horario de inicio y un horario de fin a la estrategia. * Este es un ejemplo ilustrativo de la aperura de New York en Horario UTC * * Es importante colocar el Horario UTC y si tu horario es diferente al Horario UTC tienes que adecuarlo * * Este ejemplo es del Nasdaq en 1 minuto (1M) Autor: Jorge Eduardo Arteaga Galicia @arteagagalicia */ 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 cTrader_Hora_Especifica : Robot { [Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01, Group = "Lotaje")] public double Quantity { get; set; } [Parameter("Hora Inicio UTC", DefaultValue = 13, Group = "Horario")] //Definimos la hora de inicio public int HoraInicio { get; set; } [Parameter("Hora Fin UTC", DefaultValue = 14, Group = "Horario")] //Definimos la hora de inicio public int HoraFin { get; set; } [Parameter("Minuto Inicio UTC", DefaultValue = 30, Group = "Horario")] //Definimos el minuto de inicio public int MinutoInicio { get; set; } [Parameter("Minuto Fin UTC", DefaultValue = 59, Group = "Horario")] //Definimos el minuto de fin public int MinutoFin { get; set; } [Parameter("Take Profit", DefaultValue = 30, Group = "Riesgo-Beneficio")] //Definimos el minuto de fin public int TP { get; set; } [Parameter("Stop Loss", DefaultValue = 10, Group = "Riesgo-Beneficio")] //Definimos el minuto de fin public int SL { get; set; } bool status = false; private const string label = "Hora especifica"; protected override void OnStart() { // Put your initialization logic here } protected override void OnBar() { // Put your core logic here var currentHours = Server.Time.Hour; var currentMinutes = Server.Time.Minute; //Condicion para que el bot funcione en el tiempo establecido if (HoraInicio == HoraFin) { if (currentHours == HoraInicio && currentMinutes >= MinutoInicio) { status = true; } else if (currentHours == HoraFin && currentMinutes <= MinutoFin && currentMinutes >= MinutoInicio) { status = true; } else { status = false; } } else { if (currentHours == HoraInicio) { if (currentMinutes == MinutoInicio) { status = true; } } else if (currentHours == HoraFin) { if (currentMinutes == MinutoFin) { status = false; } } } var longPosition = Positions.Find(label, SymbolName, TradeType.Buy); if (status == true && longPosition == null) { Print("Entramos"); ExecuteMarketOrder(TradeType.Buy, Symbol, Quantity, label, SL, TP); } } protected override void OnStop() { // Put your deinitialization logic here } } }
Comments

Buen bot !!!

Any English version.

How is this useful to anyone?
All it does is place a buy order when a new bar opens. It never places sell orders. There is no logic whatsoever to determine trend direction.
The buy order will then wait for however long it takes to hit either SL or TP.