Category Other  Published on 13/05/2018

NEOBOT

Description

HEY GUYS I GREATE MY FIRST CBOT AND I WOULD IF YOU ALL CAN CHECK IT AND TELL IF IS GOOD OR IF IT'S NEEDS ANY MORE WORK THANK YOU ALL I AM WAITING FOR ALL YOU COMMENTS


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

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.FullAccess)]
    public class neobot : Robot
    {
        [Parameter("x1", DefaultValue = 281)]
        public int x1 { get; set; }

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

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

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

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

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

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

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

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

        [Parameter("Order Multiplier", DefaultValue = 2)]
        public int _OrderMultiplier { get; set; }

        [Parameter("Take Profits (pips)", DefaultValue = 10)]
        public int _TP { get; set; }

        private MacdHistogram macd;
        private Position pos;
        private bool IsPosOpen = false;
        private double sl;
        protected override void OnStart()
        {
            macd = Indicators.MacdHistogram(SlowMA, FastMA, 3);
        }
        [Parameter("MA Type")]
        public MovingAverageType MAType { get; set; }

        protected override void OnTick()
        {
            int last = MarketSeries.Close.Count - 1;
            if (!(MarketSeries.Open[last] == MarketSeries.High[last] && MarketSeries.Open[last] == MarketSeries.Low[last]))
                return;
            double per = percertron();
            if (!IsPosOpen)
            {
                if (per > 0)
                {
                    Trade.CreateBuyMarketOrder(Symbol, Volume);
                    IsPosOpen = true;
                }
                if (per < 0)
                {
                    Trade.CreateSellMarketOrder(Symbol, Volume);
                    IsPosOpen = true;
                }
            }
            else
            {
                if (pos.TradeType == TradeType.Buy && per < 0)
                {
                    Trade.Close(pos);
                    Trade.CreateSellMarketOrder(Symbol, Volume);
                    return;
                }
                else
                {
                    if (Symbol.Ask > sl + StopLoss * 2 * Symbol.PointSize)
                        Trade.ModifyPosition(pos, Symbol.Ask - StopLoss * Symbol.PointSize, 0);
                }
                if (pos.TradeType == TradeType.Sell && per > 0)
                {
                    Trade.Close(pos);
                    Trade.CreateBuyMarketOrder(Symbol, Volume);
                }
                else
                {
                    if (Symbol.Bid < sl - StopLoss * 2 * Symbol.PointSize)
                        Trade.ModifyPosition(pos, Symbol.Bid + StopLoss * Symbol.PointSize, 0);
                }
            }
        }


        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }

        protected override void OnPositionOpened(Position openedPosition)
        {
            pos = openedPosition;
            if (openedPosition.TradeType == TradeType.Buy)
            {
                sl = Symbol.Ask - StopLoss * Symbol.PointSize;
                Trade.ModifyPosition(openedPosition, sl, 0);
            }
            if (openedPosition.TradeType == TradeType.Sell)
            {
                sl = Symbol.Bid + StopLoss * Symbol.PointSize;
                Trade.ModifyPosition(openedPosition, sl, 0);
            }
        }

        private double percertron()
        {
            int last = MarketSeries.Close.Count - 1;
            double w1 = x1 - 100;
            double w2 = x2 - 100;
            double w3 = x3 - 100;
            double w4 = x4 - 100;
            double a1 = macd.Histogram[last - 1];
            double a2 = macd.Histogram[last - 1 - Step];
            double a3 = macd.Histogram[last - 1 - Step * 2];
            double a4 = macd.Histogram[last - 1 - Step * 3];
            return w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4;
        }
    }
}


NE
neoklis357

Joined on 13.05.2018

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: neobot.algo
  • Rating: 5
  • Installs: 2099
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
NE
neoklis357 · 6 years ago

Astroke and how i can add all the above you suggest?

AS
Astroke · 6 years ago

he's ok not the grail just ok. maybe you need to add some money management like lots size ajusted in risk % or add x lots per loose something like that. 

NE
neoklis357 · 6 years ago
NE
neoklis357 · 6 years ago

@ASTROKE

 

NE
neoklis357 · 6 years ago

YES ONLY ON MACD

DO YOU HAVE ANY SUGGESTIONS TO MAKE ?

DID YOU BACKTEST IT ? WHAT YOU THINK IS GOOD?

I AM THINKING TO ADD ALSO SOMETHING LIKE A NEWS CHECK UP AND IF IM ABLE TO COMBINE MACD WITH THAT WHAT YOU THINK?

AS
Astroke · 6 years ago

we need more info. he's only based on MACD? 

NE
neoklis357 · 6 years ago
So what you think guys? Is it good you backtest it?