change in method

Created at 11 Nov 2014, 11:55
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!
TR

tradermatrix

Joined 24.07.2012

change in method
11 Nov 2014, 11:55


hello
 I have need your help to improve my robots.
 I am using a method of time to space trades.
 look at this example on this sample, the robot rule 1 minute.
 spacing trades = 1440 bars is 1440 minutes. Only after this time a trade can be opened.
 but it is possible that even after a long time space open trades have almost identical prices.
 c is why I want to replace this method with another.
 can you help me with my shopping space in pips (> + or - 30 pips).
 for example if the last trade Buy euro is 1.2500, the indicator accept the trade buy> 1.2530 ... <1.2470.
 I promise to post a profitable robot.
 kind regards

EURO/USD 1 Minute.

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class BB : Robot
    {
        const string Label = "BB";

        [Parameter(DefaultValue = 30)]
        public int Period { get; set; }

        [Parameter(DefaultValue = 2.5)]
        public double StandardDeviation { get; set; }

        [Parameter(DefaultValue = MovingAverageType.TimeSeries)]
        public MovingAverageType MAType { get; set; }

        [Parameter("Spacing Trades (X bars)", DefaultValue = 1440, MinValue = 0)]
        public int SpacingTrades { get; set; }

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

        [Parameter(DefaultValue = 80)]
        public int StopLoss { get; set; }

        [Parameter(DefaultValue = 80)]
        public int TakeProfit { get; set; }

        //////////////////////////////////////////////////////////////////////////////////////

        private TradeType _lastTradeType;
        private BollingerBands bb;
        private int Count = 0;

        protected override void OnStart()
        {

            bb = Indicators.BollingerBands(MarketSeries.High, Period, StandardDeviation, MAType);

        }


        protected override void OnBar()
        {

            Count++;
            var index = MarketSeries.Close.Count - 2;
            var position = Positions.Find(Label);

            if (Count > SpacingTrades && MarketSeries.Close[index] > bb.Top[index] && MarketSeries.Close[index - 1] <= bb.Top[index - 1] && _lastTradeType != TradeType.Sell)
            {

                ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, Label, StopLoss, TakeProfit);

                _lastTradeType = TradeType.Sell;

                Count = 0;
            }
            if (Count > SpacingTrades && MarketSeries.Close[index] < bb.Bottom[index] && MarketSeries.Close[index - 1] <= bb.Bottom[index - 1] && _lastTradeType != TradeType.Buy)
            {

                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, Label, StopLoss, TakeProfit);

                _lastTradeType = TradeType.Buy;

                Count = 0;
            }
        }
    }
}


@tradermatrix
Replies

tradermatrix
14 Nov 2014, 15:34

RE:

tradermatrix said:

no solution?

hello
 I have need your help to improve my robots.
 I am using a method of time to space trades.
 look at this example on this sample, the robot rule 1 minute.
 spacing trades = 1440 bars is 1440 minutes. Only after this time a trade can be opened.
 but it is possible that even after a long time space open trades have almost identical prices.
 c is why I want to replace this method with another.
 can you help me with my shopping space in pips (> + or - 30 pips).
 for example if the last trade Buy euro is 1.2500, the indicator accept the trade buy> 1.2530 ... <1.2470.
 I promise to post a profitable robot.
 kind regards

EURO/USD 1 Minute.

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class BB : Robot
    {
        const string Label = "BB";

        [Parameter(DefaultValue = 30)]
        public int Period { get; set; }

        [Parameter(DefaultValue = 2.5)]
        public double StandardDeviation { get; set; }

        [Parameter(DefaultValue = MovingAverageType.TimeSeries)]
        public MovingAverageType MAType { get; set; }

        [Parameter("Spacing Trades (X bars)", DefaultValue = 1440, MinValue = 0)]
        public int SpacingTrades { get; set; }

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

        [Parameter(DefaultValue = 80)]
        public int StopLoss { get; set; }

        [Parameter(DefaultValue = 80)]
        public int TakeProfit { get; set; }

        //////////////////////////////////////////////////////////////////////////////////////

        private TradeType _lastTradeType;
        private BollingerBands bb;
        private int Count = 0;

        protected override void OnStart()
        {

            bb = Indicators.BollingerBands(MarketSeries.High, Period, StandardDeviation, MAType);

        }


        protected override void OnBar()
        {

            Count++;
            var index = MarketSeries.Close.Count - 2;
            var position = Positions.Find(Label);

            if (Count > SpacingTrades && MarketSeries.Close[index] > bb.Top[index] && MarketSeries.Close[index - 1] <= bb.Top[index - 1] && _lastTradeType != TradeType.Sell)
            {

                ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, Label, StopLoss, TakeProfit);

                _lastTradeType = TradeType.Sell;

                Count = 0;
            }
            if (Count > SpacingTrades && MarketSeries.Close[index] < bb.Bottom[index] && MarketSeries.Close[index - 1] <= bb.Bottom[index - 1] && _lastTradeType != TradeType.Buy)
            {

                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, Label, StopLoss, TakeProfit);

                _lastTradeType = TradeType.Buy;

                Count = 0;
            }
        }
    }
}

 


@tradermatrix

Spotware
14 Nov 2014, 17:46

We can recommend you to contact one of our Partners or post a job in Development Jobs section.


@Spotware