Quantity -Position Size (Lots) step 0.01 = 0.10 Lots. Error?

Created at 18 Apr 2023, 10:57
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!

Quantity -Position Size (Lots) step 0.01 = 0.10 Lots. Error?
18 Apr 2023, 10:57


Hi

Is this my mistake or not?

The step for Quantity is not working like it should in the parameter window. I've got ''Step = 0.01'' in the code (I also tried with 0.001) but when I press the up or down button in the Parameter window it moves by 0.10 Lot not 0.01 Lot.

I'm used to it, but for the newbies and for the clients who use my bot for free this is a huge problem. They've got small account balance and when they try to move the Position size (Lots) they move it by accident by 0.10 Lot when they press the up button and then they blow their accounts.

 


@algorithmic.trading.eu_gmail.com
Replies

firemyst
18 Apr 2023, 14:56

I feel like it should work as you have it.

However, perhaps it's acting the way it does because with some brokers like IC Markets, users cannot trade in 0.01 lots. I believe their minimum is 0.1 lots. Maybe that's the issue?

I would try you code on two different brokers that allow for different sizes. For instance, Pepperstone allows for 0.01 lots, so try it with Pepperstone and then IC Markets and see what happens?


@firemyst

PanagiotisChar
18 Apr 2023, 14:59

Hi there,

Can you share some code so that we can try it too?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

algorithmic.trading.eu_gmail.com
18 Apr 2023, 23:09 ( Updated at: 18 Apr 2023, 23:28 )

RE:

firemyst said:

I feel like it should work as you have it.

However, perhaps it's acting the way it does because with some brokers like IC Markets, users cannot trade in 0.01 lots. I believe their minimum is 0.1 lots. Maybe that's the issue?

I would try you code on two different brokers that allow for different sizes. For instance, Pepperstone allows for 0.01 lots, so try it with Pepperstone and then IC Markets and see what happens?

IC Markets allows 0.01 Lot. I tried the bot on different brokers. The problem is the same.

I've found an already-built-in cBot by cTrader that uses Quantity. There is an error in 'Step = 0.01' '

Sample Breakout cBot (already build in cBot by cTrader)

// -------------------------------------------------------------------------------------------------
//
//    This code is a cTrader Automate API example.
//
//    This cBot is intended to be used as a sample and does not guarantee any particular outcome or
//    profit of any kind. Use it at your own risk.
//    
//    All changes to this file might be lost on the next application update.
//    If you are going to modify this file please make a copy using the "Duplicate" command.
//
//    The "Sample Breakout cBot" will check the difference in pips between the Upper Bollinger Band and the Lower Bollinger Band 
//    and compare it against the "Band Height" parameter specified by the user.  If the height  is lower than the number of pips 
//    specified, the market is considered to be consolidating, and the first candlestick to cross the upper or lower band will 
//    generate a buy or sell signal. The user can specify the number of periods that the market should be consolidating in the 
//    "Consolidation Periods" parameter. The position is closed by a Stop Loss or Take Profit.  
//
// -------------------------------------------------------------------------------------------------
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("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

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

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

        [Parameter("Source", Group = "Bollinger Bands")]
        public DataSeries Source { get; set; }

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

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

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

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

        [Parameter("Consolidation Periods", Group = "Bollinger Bands", 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.QuantityToVolumeInUnits(Quantity);
                if (Ask > top)
                {
                    ExecuteMarketOrder(TradeType.Buy, SymbolName, volumeInUnits, label, StopLossInPips, TakeProfitInPips);

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

                    consolidation = 0;
                }
            }
        }
    }
}


@algorithmic.trading.eu_gmail.com

algorithmic.trading.eu_gmail.com
18 Apr 2023, 23:15 ( Updated at: 18 Apr 2023, 23:33 )

RE:

PanagiotisChar said:

Hi there,

Can you share some code so that we can try it too?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Hi PanagiotisChar. I'm a big fan of yours. You helped cTrader become the best and most advanced platform there is. I have huge respect for you.

 

I've found an already-built-in cBot by cTrader that uses Quantity. There is an error in ''Step = 0.01''

 

Sample Breakout cBot

// -------------------------------------------------------------------------------------------------
//
//    This code is a cTrader Automate API example.
//
//    This cBot is intended to be used as a sample and does not guarantee any particular outcome or
//    profit of any kind. Use it at your own risk.
//    
//    All changes to this file might be lost on the next application update.
//    If you are going to modify this file please make a copy using the "Duplicate" command.
//
//    The "Sample Breakout cBot" will check the difference in pips between the Upper Bollinger Band and the Lower Bollinger Band 
//    and compare it against the "Band Height" parameter specified by the user.  If the height  is lower than the number of pips 
//    specified, the market is considered to be consolidating, and the first candlestick to cross the upper or lower band will 
//    generate a buy or sell signal. The user can specify the number of periods that the market should be consolidating in the 
//    "Consolidation Periods" parameter. The position is closed by a Stop Loss or Take Profit.  
//
// -------------------------------------------------------------------------------------------------
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("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

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

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

        [Parameter("Source", Group = "Bollinger Bands")]
        public DataSeries Source { get; set; }

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

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

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

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

        [Parameter("Consolidation Periods", Group = "Bollinger Bands", 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.QuantityToVolumeInUnits(Quantity);
                if (Ask > top)
                {
                    ExecuteMarketOrder(TradeType.Buy, SymbolName, volumeInUnits, label, StopLossInPips, TakeProfitInPips);

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

                    consolidation = 0;
                }
            }
        }
    }
}


@algorithmic.trading.eu_gmail.com

algorithmic.trading.eu_gmail.com
20 Apr 2023, 11:06

Just to be clear. Will this issue be resolved?

Have you tried the source code I gave you?

I would really like to see this working like it should be working:

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

 


@algorithmic.trading.eu_gmail.com