Bollinger Bands BO Strategy Help #2

Created at 05 Dec 2016, 15:31
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!
JO

Joshuaparrishtrade

Joined 05.12.2016

Bollinger Bands BO Strategy Help #2
05 Dec 2016, 15:31


Hello sorry for the repost I would very much appreciate if someone could help me with the code of a bot ive been editing all credit goes to HJozan and [cyfer] im not very good with coding so im sorry if i get the wrong terminology,

im having trouble opening orders when the price closes above the BB's i would like to be able to open a trade with a set takeprofit and stoploss when the candle closes above the BB's for a short and when  it closes below for a long ive tried to use ExecuteMarketOrder(); and Trade.Type but neither work and with my limited coding knowledge im not sure of how to open a trade 

Thankyou very much in Advance !

 

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class BBREVERSALCODE : Indicator
    {

        private BollingerBands bbds;

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

        [Parameter("TP", DefaultValue = 1, MinValue = 1)]
        public int TP { get; set; }



        protected override void Initialize()
        {

            bbds = Indicators.BollingerBands(MarketSeries.Close, 15, 3, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {
            if (bbds.Top[index - 1] < MarketSeries.Close[index - 1])
            {

                ChartObjects.DrawText(index.ToString(), "▼", index - 1, MarketSeries.High[index - 1] + Symbol.PipSize, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Red);
                
            }
            if (bbds.Bottom[index - 1] > MarketSeries.Close[index - 1])
            {
                ChartObjects.DrawText(index.ToString(), "▲", index - 1, MarketSeries.Low[index - 1] - Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.Green);
            }
        }

 

 

 

 

 

 

 

?

 


@Joshuaparrishtrade