Topics
21 Oct 2019, 11:45
 1080
 3
19 Aug 2017, 15:08
 1
 996
 1
Replies

NyanHtet
12 May 2020, 17:14

wonder on number 5 at execute order?

what is the last 5 means?

 

ExecuteMarketOrder(TradeType.Buy, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);

 

ExecuteMarketOrder(TradeType.Sell, Symbol, volume, "korakodmy", StopLoss, TakeProfit, 5);

 

regards,

Nyan


@NyanHtet

NyanHtet
21 Oct 2019, 12:07

it seem like i fixed it. 

added another loop inside.

testing now.

 

 

  if (distance >= BreakEvenPips * Symbol.PipSize)
                {
                    if (position.TradeType == TradeType.Buy)
                    {
                        if (position.StopLoss <= position.EntryPrice + (Symbol.PipSize * breakevenextrapips) || position.StopLoss == null)
                        {

                            //Fixed _21oct19
                            if (position.StopLoss == position.EntryPrice + (Symbol.PipSize * breakevenextrapips))
                            {
                                break;
                            }

                            else
                            {
                                ModifyPosition(position, position.EntryPrice + (Symbol.PipSize * breakevenextrapips), position.TakeProfit);
                                Print("Stop Loss to Break Even set for BUY position {0}", position.Id);
                            }

                        }
                    }


@NyanHtet

NyanHtet
25 Sep 2019, 20:56

Should i Add this code at the bottom or at the top?

 

for example.

this is the break out Cbot code.

where should i add it?

 

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 SampleBreakoutcBot : Robot
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("Band Height (pips)", DefaultValue = 40.0, MinValue = 0)]
        public double BandHeightPips { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 1)]
        public int StopLossInPips { get; set; }

        [Parameter("Take Profit (pips)", DefaultValue = 40, MinValue = 1)]
        public int TakeProfitInPips { get; set; }

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

        [Parameter("Bollinger Bands Deviations", DefaultValue = 2)]
        public double Deviations { get; set; }

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

        [Parameter("Bollinger Bands MA Type")]
        public MovingAverageType MAType { get; set; }

        [Parameter("Consolidation Periods", DefaultValue = 2)]
        public int ConsolidationPeriods { get; set; }

        BollingerBands bollingerBands;
        string label = "Sample Breakout cBot";
        int consolidation;

        protected override void OnStart()
        {
            bollingerBands = Indicators.BollingerBands(Source, Periods, Deviations, MAType);
        }

        protected override void OnBar()
        {

            var top = bollingerBands.Top.Last(1);
            var bottom = bollingerBands.Bottom.Last(1);

            if (top - bottom <= BandHeightPips * Symbol.PipSize)
            {
                consolidation = consolidation + 1;
            }
            else
            {
                consolidation = 0;
            }

            if (consolidation >= ConsolidationPeriods)
            {
                var volumeInUnits = Symbol.QuantityToVolume(Quantity);
                if (Symbol.Ask > top)
                {
                    ExecuteMarketOrder(TradeType.Buy, Symbol, volumeInUnits, label, StopLossInPips, TakeProfitInPips);

                    consolidation = 0;
                }
                else if (Symbol.Bid < bottom)
                {
                    ExecuteMarketOrder(TradeType.Sell, Symbol, volumeInUnits, label, StopLossInPips, TakeProfitInPips);

                    consolidation = 0;
                }
            }
        }
    }
}


@NyanHtet