Category Other  Published on 20/03/2017

yrtyry

Description

yutttttttttttttiy


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 CCIReversal : Robot
    {
        [Parameter(DefaultValue = 26)]
        public int cciPeriod { get; set; }

        [Parameter(DefaultValue = 9)]
        public int maPeriod { get; set; }

        [Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

        [Parameter("Trading Side", DefaultValue = 2, MinValue = 0, MaxValue = 2, Step = 1)]
        public int tradeSize { get; set; }


        private CommodityChannelIndex cci;
        //private Position _position;
        private const string robotname = "CCIReversal";
        private int side;
        //private int magic;

        protected override void OnStart()
        {
            cci = Indicators.CommodityChannelIndex(cciPeriod);
            side = tradeSize;
        }

        protected override void OnBar()
        {

            var longPos = Positions.Find(robotname, Symbol, TradeType.Buy);
            var shortPos = Positions.Find(robotname, Symbol, TradeType.Sell);
            var pre_cci = cci.Result.Last(2);
            var cur_cci = cci.Result.Last(0);


            Print("CCI = " + cur_cci + " Pre CCI" + pre_cci);
            if ((cci.Result.HasCrossedAbove(-100.0, 1) && cur_cci > pre_cci) || (cci.Result.HasCrossedAbove(100.0, 1) && cur_cci > pre_cci))
            {
                if (shortPos != null)
                {
                    ClosePosition(shortPos);
                    if (side == 1 || side == 2)
                    {
                        ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, robotname);
                    }
                }
                else if (longPos == null)
                {
                    if (side == 1 || side == 2)
                    {
                        ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, robotname);
                    }
                }
                else if (longPos != null)
                {
                    /*if (side == 1 || side == 2)
                    {
                        ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, robotname);
                    }*/
                }                
                Print("con1");
            }
            else if ((cci.Result.HasCrossedBelow(-100.0, 1) && cur_cci < pre_cci) || (cci.Result.HasCrossedBelow(100, 1) && cur_cci < pre_cci))
            {

                if (longPos != null)
                {
                    ClosePosition(longPos);
                    if (side == 0 || side == 2)
                    {
                        ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, robotname);
                    }
                }
                else if (shortPos == null)
                {

                    if (side == 0 || side == 2)
                    {
                        ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, robotname);
                    }
                }
                else if (shortPos != null)
                {
                    /*if (side == 0 || side == 2)
                    {
                        ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, robotname);
                    }*/
                }                


                Print("con2");

            }
            Print("Long" + (longPos != null));
            Print("Short" + (shortPos != null));

        }

        private long VolumeInUnits
        {
            get { return Symbol.QuantityToVolume(Quantity); }
        }

        private void cci_reversal()
        {

        }
    }



}


YU
yuriykirienko10

Joined on 06.12.2016

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: CCI Reversal.algo
  • Rating: 0
  • Installs: 2014
Comments
Log in to add a comment.
BO
bojesim268 · 11 months ago

I’m a blog crazed person and i love to read cool blog like yours.*:,::egr and dpf delete kits

VI
visapoy421 · 1 year ago

An impressive share, I merely given this onto a colleague who was doing a little analysis for this. Anf the husband in truth bought me breakfast simply because I found it for him.. smile. So i want to reword that: Thnx for your treat! But yeah Thnkx for spending plenty of time to talk about this, I feel strongly regarding this and really like reading regarding this topic. If it is possible, as you grow expertise, can you mind updating your blog site with a lot more details? It’s highly useful for me. Huge thumb up with this writing!An impressive share, I merely given this onto a colleague who was doing a little analysis for this. Anf the husband in truth bought me breakfast simply because I found it for him.. smile. So i want to reword that: Thnx for your treat! But yeah Thnkx for spending plenty of time to talk about this, I feel strongly regarding this and really like reading regarding this topic. If it is possible, as you grow expertise, can you mind updating your blog site with a lot more details? It’s highly useful for me. Huge thumb up with this writing!liftmaster gate repair

JS
json73758 · 1 year ago
[url=https://www.googl.com/]Google[/url] [abc] https://www.google.com Google [Google](https://www.google.com)
JS
json73758 · 1 year ago

Trading is the best option for people to get luck on the platforms available at Google. Most of the people getting paid from here and some are using it for their investments. 

ZU
zubairkhatri101 · 1 year ago

of fighters to grace the Manny Pacquiao vs Shane Mosley Pay Per View event scheduled todaytours in Riga

HA
hamzaseo4433 · 1 year ago

I have to say this post was certainly informationrmative and contains useful content for enthusiastic visitors. I will definitely bookmark this site for future reference and further viewing. cheers a bunch for sharing this with us! 비아마켓

GI
gijeci2531 · 1 year ago

Professional Best House cleaning Sydney We provide trusted and professional House cleaner near me services across Sydney at Affordable Prices.