RickyMoney free

by ripupo88 in category Range at 08/09/2017
Description

You must try different parameters up to take profit. The main idea of this robot is put a smaller take profit and a bigger stop lost, always betting on the rebound after each new bar.

Range market: hight profits
Trend market: Very high losses

Risk: hight

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
// -------------------------------------------------------------------------------------------------
//
//    This code is a cAlgo API sample.
//
//    This cBot is intended to be used as a sample and does not guarantee any particular outcome or
//    profit of any kind. Use it at your own risk
//
//    The "Sample Martingale cBot" creates a random Sell or Buy order. If the Stop loss is hit, a new 
//    order of the same type (Buy / Sell) is created with double the Initial Volume amount. The cBot will 
//    continue to double the volume amount for  all orders created until one of them hits the take Profit. 
//    After a Take Profit is hit, a new random Buy or Sell order is created with the Initial Volume amount.
//
// -------------------------------------------------------------------------------------------------

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class RickyMoney : Robot
    {
        [Parameter("Initial Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
        public double InitialQuantity { get; set; }

        [Parameter("SL", DefaultValue = 20)]
        public int StopLoss { get; set; }

        [Parameter("TP", DefaultValue = 20)]
        public int TakeProfit { get; set; }
        int newprofit;

        private Random random = new Random();
        bool ganada;
        bool compra;
        bool permiso;

        protected override void OnStart()
        {
            Positions.Closed += OnPositionsClosed;
            newprofit = TakeProfit;

            ExecuteOrder(InitialQuantity, GetRandomTradeType(), StopLoss, TakeProfit);
        }

        private void ExecuteOrder(double quantity, TradeType tradeType, int stop, int take)
        {

            var volumeInUnits = Symbol.QuantityToVolume(quantity);
            var result = ExecuteMarketOrder(tradeType, Symbol, volumeInUnits, "Robot", stop, take);

            if (result.Error == ErrorCode.NoMoney)
                Stop();
        }

        private void OnPositionsClosed(PositionClosedEventArgs args)
        {
            permiso = true;
            Print("Closed");
            var position = args.Position;

            if (position.Label != "Robot" || position.SymbolCode != Symbol.Code)
                return;
            if (position.NetProfit > 0)
            {
                ganada = true;
                if (position.TradeType == TradeType.Buy)
                {
                    compra = true;
                }
                else
                {
                    compra = false;
                }
            }
            else
            {
                ganada = false;
                if (position.TradeType == TradeType.Buy)
                {
                    compra = true;
                }
                else
                {
                    compra = false;
                }
            }
        }

        protected override void OnBar()
        {
            if (permiso)
            {
                permiso = false;
                if (ganada)
                {
                    newprofit = TakeProfit;
                    if (compra)
                    {
                        ExecuteOrder(InitialQuantity, TradeType.Sell, StopLoss, TakeProfit);
                    }
                    else
                    {
                        ExecuteOrder(InitialQuantity, TradeType.Buy, StopLoss, TakeProfit);
                    }
                }
                else
                {
                    if (compra)
                    {

                        ExecuteOrder(InitialQuantity, TradeType.Buy, StopLoss / 1, newprofit);
                    }
                    else
                    {
                        ExecuteOrder(InitialQuantity, TradeType.Sell, StopLoss / 1, newprofit);
                    }
                }
            }
        }

        private TradeType GetRandomTradeType()
        {
            return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
        }
    }
}
Comments

memailmarketing2 - November 22, 2022 @ 16:31

Hi I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post check here.

memailmarketing7 - November 23, 2022 @ 13:39

You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. Check here how to host a retreat

memailmarketing1 - November 23, 2022 @ 14:47

Very fine write-up. I actually really came across a person’s blog site plus needed so that you can point out this I’ve actually loved browsing a person’s site plus content. eco chic hotel

memailmarketing3 - November 24, 2022 @ 13:57

I got what you intend, saved to bookmarks , very decent web site psilocybin

memailmarketing4 - November 26, 2022 @ 12:34

I got what you intend, saved to bookmarks , Check here very decent web site. 

0