Can help me to code simple stuff ?

Created at 22 Mar 2017, 15:24
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
HA

handiphangceo@gmail.com

Joined 22.03.2017

Can help me to code simple stuff ?
22 Mar 2017, 15:24


hellow :) i need some help from coders

 

i want to close position when the price now cross the Kijun Line. Thanks ^^

 

     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MidasIndex : Robot
    {
        [Parameter(DefaultValue = 9)]
        public int periodFast { get; set; }

        [Parameter(DefaultValue = 26)]
        public int periodMedium { get; set; }

        [Parameter(DefaultValue = 52)]
        public int periodSlow { get; set; }

        [Parameter(DefaultValue = 1000)]
        public int Volume { get; set; }

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

        [Parameter("Take Profit", DefaultValue = 25)]
        public int TakeProfitPips { get; set; }

        IchimokuKinkoHyo ichimoku;

        protected override void OnStart()
        {
            ichimoku = Indicators.IchimokuKinkoHyo(periodFast, periodMedium, periodSlow);
        }

        protected override void OnBar()
        {
            var positionsBuy = Positions.FindAll("Buy");
            var positionsSell = Positions.FindAll("Sell");

            var distanceFromUpKumo = (Symbol.Bid - ichimoku.SenkouSpanA.Last(26)) / Symbol.PipSize;
            var distanceFromDownKumo = (ichimoku.SenkouSpanA.Last(26) - Symbol.Ask) / Symbol.PipSize;
            var distanceFromKijun = ichimoku.KijunSen;


            if (positionsBuy.Length == 0 && positionsSell.Length == 0)
            {
                if (MarketSeries.Open.Last(1) <= ichimoku.SenkouSpanA.Last(27) && MarketSeries.Open.Last(1) > ichimoku.SenkouSpanB.Last(27))
                {
                    if (MarketSeries.Close.Last(1) > ichimoku.SenkouSpanA.Last(27))
                    {
                        if (distanceFromUpKumo <= 30)
                        {
                            ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Buy", StopLossPips, TakeProfitPips);
                        }
                    }
                }

                if (MarketSeries.Open.Last(1) >= ichimoku.SenkouSpanA.Last(27) && MarketSeries.Open.Last(1) < ichimoku.SenkouSpanB.Last(27))
                {
                    if (MarketSeries.Close.Last(1) < ichimoku.SenkouSpanA.Last(27))
                    {
                        if (distanceFromDownKumo <= 30)
                        {
                            ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "Sell", StopLossPips, TakeProfitPips);
                        }
                    }
                }

            }
        }
    }
}


@handiphangceo@gmail.com
Replies

handiphangceo@gmail.com
23 Mar 2017, 05:48

help pleaseee > . <


@handiphangceo@gmail.com

brunoamancio.ti
13 Apr 2017, 21:20

You should practice more programming first. Try refactoring your code so that it is easier to read it and understand it. Nobody will help you with that spaghetti.


@brunoamancio.ti