Lots vs Volume vs Quantity guidance please

Created at 22 Dec 2017, 09:23
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!
GU

gunning.ernie

Joined 18.12.2017

Lots vs Volume vs Quantity guidance please
22 Dec 2017, 09:23


Hi Guys, 

I'm used to MT4 and 5 style of opening a trade via specifying the lots size when opening a trade. I see with ExecuteMarketOrder i need to give volume as a parameter? I think I have a puzzle missing here as I used the volume in my pipvalue calculation in past,

leaverage account size : 100
Contract Volume : 100 000
pipsise for USD with 5 decimals = (100 000/100) * 0.00001 (decimals for USD)
finish the calculation in brackets=  1000 * 0.00001
1 pip is 1 $ cent                       = 0.01c

I'm showig this calculation to ilistrate what volumne means to me. I feel im missing something with cAlgo... what is volume? cant be 100 000?

Also, browsing the PendingOrder class we have a Quatity Property with comments linking it to the lot size. So im quite confuised what i need to specify in the volumne parameter and how to calculate it... is the some articale to describe this?

 

namespace cAlgo.API
{
    //
    // Summary:
    //     Provides access to properties of pending orders
    public interface PendingOrder
    {
        //
        // Summary:
        //     User assigned Order Comment
        string Comment { get; }
        //
        // Summary:
        //     The order Expiration time The Timezone used is set in the Robot attribute
        DateTime? ExpirationTime { get; }
        //
        // Summary:
        //     Unique order Id.
        int Id { get; }
        //
        // Summary:
        //     User assigned identifier for the order.
        string Label { get; }
        //
        // Summary:
        //     Specifies whether this order is Stop or Limit.
        PendingOrderType OrderType { get; }
        //
        // Summary:
        //     Quantity (lots) of this order
        double Quantity { get; }
        //
        // Summary:
        //     The order stop loss in price
        double? StopLoss { get; }
        //
        // Summary:
        //     The order stop loss in pips
        double? StopLossPips { get; }
        //
        // Summary:
        //     Symbol code of the order
        string SymbolCode { get; }
        //
        // Summary:
        //     The order take profit in price
        double? TakeProfit { get; }
        //
        // Summary:
        //     The order take profit in pips
        double? TakeProfitPips { get; }
        //
        // Summary:
        //     The order target price.
        double TargetPrice { get; }
        //
        // Summary:
        //     Specifies whether this order is to buy or sell.
        TradeType TradeType { get; }
        //
        // Summary:
        //     Volume of this order.
        long Volume { get; }
    }
}

 


@gunning.ernie
Replies

PanagiotisCharalampous
22 Dec 2017, 10:26

Hi gunning.ernie,

Volume is just the amount of base currency you would like to invest in your position e.g. 100000 in EURUSD means a position of €100.000. Regarding your calculation, leverage in not related to pip size. Leverage is related to your account's margin. Pip size is only related to position size. The result of your calculation should be $1. In reality, the pip value of EURUSD is $10 since the the pip position is on the fourth decimal place.

Let me know if my explanation makes things clearer to you.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous

gunning.ernie
22 Dec 2017, 10:52

RE:

Panagiotis Charalampous said:

Hi gunning.ernie,

Volume is just the amount of base currency you would like to invest in your position e.g. 100000 in EURUSD means a position of €100.000. Regarding your calculation, leverage in not related to pip size. Leverage is related to your account's margin. Pip size is only related to position size. The result of your calculation should be $1. In reality, the pip value of EURUSD is $10 since the the pip position is on the fourth decimal place.

Let me know if my explanation makes things clearer to you.

Best Regards,

Panagiotis

 

Thanks Panagoitis,

Let me try a example, if I have a 1:100 leaveraged account  with a balance of $1000 and I want to risk $100 (10%) in my next trade. Do I just put 100 in the volume?


@gunning.ernie

PanagiotisCharalampous
22 Dec 2017, 11:05

Hi gunning.ernie,

The percentage of your risk depends on where you will put your stop loss, not only on the volume. In leveraged accounts you can risk your entire account balance if you do not use a stop loss. The higher the volume, the less pips needed to reach your risk threshold. For example, if you open a position of $100.000 and you want to risk only $100, you need to place your stop loss at 10 pips since each pip is $10.

The leverage does not change the amount of risk. It is the size of the position itself that determines your risk. Leverage just defines the minimum margin required by the broker to open a position i.e. with a leverage of 1:100 the maximum position you can open with $1000 is $100.000.

I hope this helps.

Best Regards,

Panagiotis


@PanagiotisCharalampous

gunning.ernie
23 Dec 2017, 08:21 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Panagiotis Charalampous said:

Hi gunning.ernie,

Volume is just the amount of base currency you would like to invest in your position e.g. 100000 in EURUSD means a position of €100.000. Regarding your calculation, leverage in not related to pip size. Leverage is related to your account's margin. Pip size is only related to position size. The result of your calculation should be $1. In reality, the pip value of EURUSD is $10 since the the pip position is on the fourth decimal place.

Let me know if my explanation makes things clearer to you.

Best Regards,

Panagiotis

 

Hi Panagiotis, Thanks for you posts and I do appreciate you responses. I must admit that I just couldnt grasp out of all your post what I should populate Volume with. I have spent some time and I beliwve I know now AND I would like you to confim this in my LAST post. I'm stepping one step back and responding to you post inn a quote by quote mater that confused me. This might cause out conversation to spawn in multple conversations BUT if there something to learn here I would like us t try and keep track as I see my self as still a learner although I have been a while in this. Here we go:

"Volume is just the amount of base currency you would like to invest in your position e.g. 100000 in EURUSD means a position of €100.000"
I do understand from this sentance where we I missed your conversation. 100 0000 (1 lot) was my volume. It is not the volume for cAlgo. I will explain in my last post for clarity on guys comming from mt4 and 5 (please inspect my answer)

leverage in not related to pip size
Agreed, I was talking about pip value in my first post

Leverage is related to your account's margin. Pip size is only related to position size.
Agree

The result of your calculation should be $1. In reality, the pip value of EURUSD is $10 since the the pip position is on the fourth decimal place.
I Think we might missing each other here. Your statement on "In reality" are you saying reality without leaverage? then I can agree, but my formula is correct except for the 5 decimal places used as you mentioned it should use 4 decimal places (lol i only read this now...i figured this out after  some trail and error ouch). So the result is $0.10c in above formula in my first post and this alligns with what cTrades is saying, see image below:

(100 000(lot)/100(leaverage) = 1000.

1000 x 0.0001 (pipsize 4 decimal) = $0.10c

 

Please let me know if I clearly explained myself?


@gunning.ernie

gunning.ernie
23 Dec 2017, 08:42

RE:

Panagiotis Charalampous said:

Hi gunning.ernie,

The percentage of your risk depends on where you will put your stop loss, not only on the volume. In leveraged accounts you can risk your entire account balance if you do not use a stop loss. The higher the volume, the less pips needed to reach your risk threshold. For example, if you open a position of $100.000 and you want to risk only $100, you need to place your stop loss at 10 pips since each pip is $10.

The leverage does not change the amount of risk. It is the size of the position itself that determines your risk. Leverage just defines the minimum margin required by the broker to open a position i.e. with a leverage of 1:100 the maximum position you can open with $1000 is $100.000.

I hope this helps.

Best Regards,

Panagiotis

 

"The percentage of your risk depends on where you will put your stop loss, not only on the volume."

I agree, I feel there is 2 types of risk in a trading bot strategy. Your trading risk (stoploss position - risk is with time in the market here) and your finacial risk (money management strategy - how much you risk finacially based on volume). They are seperate risk elements as they independantly can yield very diffrent results. 

"In leveraged accounts you can risk your entire account balance if you do not use a stop loss. The higher the volume, the less pips needed to reach your risk threshold."

Agreed, I finaly can understand when you talk volume here. In my MetaTrader days i talked lot sizes. This is were I was confused as I know lots which van be fractional (0.01) to place an trade. In cTrade Volume cant be fractional...

"The leverage does not change the amount of risk. It is the size of the position itself that determines your risk"
Agreed.

 

Hope i clearly explain myself?


@gunning.ernie

gunning.ernie
23 Dec 2017, 11:43

Thanks Panagoitis again for your effort and time to assist,

To conclude and get back to the question I asked around "what i need to specify in the volumne parameter and how to calculate it?"

cAlgo uses volume(long) to open trades and MT uses lot (decimal)

For clarity sake I will use above parameters from the first post as example

Metatrader used Lot size and was calculated as follows:

Full Lot : 100 000
Leaverage: 100
Currency pip size: 0.0001 (in MetaTrader it was 5 decimals, but to keep thinks same i wil use 4)

micro lot (0.01lot) value: (100 000/100) * 0.0001 = 0.10 c
NB: I cant tie the 0.01 lot to something. if I multiply it with a full lot (100 000) the formulate is broken with leaverage. So i dont know how or where 0.01 lot came from?

micro lot (0.01) = $0.10c

so you would use 0.01 lot as parameter to opren trade.

 

CAlgo uses Volume and gets calculated as follows:

Lot : 100 000
Leaverage: 100
Currency pip size: 0.0001

Volume Step =  (100 000/100) = 1000

a Volume step has a pip value of : 1000 * 0.0001 = $0.10c

so when opening a trade you need to specify 1000 as the volume for 0.10c pip value. YOU should increase the Volume by units of the volume step to increase your pip value. For example, you cannot specify 1500 of 4300. it should be devidable by the step (1000). So correct values are 1000, 2000,3000...100 0000.

@Panagoitis, please can you verify my section above?

 

If everything is correct above then I assumes that Quantity (double) in the PendingOrder class is the amount of units of volume you want to trade thus you can use the QuantityToVolume function that will multiply Quantity with Volume.

 

Some aditional notes:

Formula :

((Full Lot) / (Leaverage) ) x (pip size) = pip value in bank account currency

100 000  /      100          x 0.0001    = 0.10

This formula scales nicely down in pipvalue when you increase the leaverage...as it should.

 

I tried bringing the micro lot (0.01) into the equation and it screwed things up and didnt scale...so im confused as to why i traded in lot in MT4 and 5...? 


@gunning.ernie

PanagiotisCharalampous
27 Dec 2017, 14:50

Hi gunning.ernie,

so when opening a trade you need to specify 1000 as the volume for 0.10c pip value. YOU should increase the Volume by units of the volume step to increase your pip value. For example, you cannot specify 1500 of 4300. it should be devidable by the step (1000). So correct values are 1000, 2000,3000...100 0000.

Correct.

 If everything is correct above then I assumes that Quantity (double) in the PendingOrder class is the amount of units of volume you want to trade thus you can use the QuantityToVolume function that will multiply Quantity with Volume.

No, QuantityToVolume is used to covert lots to volume. You pass lots and you get volume as a results e.g. 1 lot  = 100000 for EURUSD. 

I still do not understand why you include leverage in your pip calculation. It is not related. To calculate pip value you just need to calculate the following formula

Volume * 10^(-PipPosition) = PipSize.

Leverage is not needed anywhere

A lot just represents a number of units of currency to be traded e.g. 1 lot = 100000€, 2 lots = 200000€ etc. Volume is the units themselves.

Best Regards,

Panagiotis


@PanagiotisCharalampous

trend_meanreversion
14 Oct 2019, 05:19

RE:

 

Hi Panagiotis,

Can you confirm if QuantityToVolume/ VolumeInUnitsToQuantity is working for Index CFDs ? They seem to work fine for FX products but not for index CFDs. I used below code and can see the results don't make any sense for US30 Index CFD (for example).  I am using ICMarkets cTrader

US30 Index CFD:

250 3 250   -> I would have expected 9 , 80000 , 9  ( I am assuming ~26800 USD notional for 1 Index US30 CFDs )

EURUSD

257000 300000 2.57  ( which makes sense )

Can you please advise ?

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TestVolumeTuQuantity : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            // Put your initialization logic here
            Print(Symbol.NormalizeVolumeInUnits(257010), " ", Symbol.QuantityToVolumeInUnits(3), " ", Symbol.VolumeInUnitsToQuantity(Symbol.NormalizeVolumeInUnits(257010)));

        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 


@trend_meanreversion

PanagiotisCharalampous
14 Oct 2019, 09:47

Hi trend_meanreversion,

It seems you are misundestanding what Volume in Units means. Volume in Units is expressed in units of the base asset, not in units of the quoted asset. So 1 unit of US30  = 1 contract. Also, most brokers set 1 Lot = 1 Contract for most indices. So 1 Lot of US30 = 1 contract.

So the expected values for your code should be

257010 3 257010

But because most brokers cap the number of contracts to be traded to 1000, you will probably get

1000 3 1000

Let me know if this helps.

Best Regards,

Panagiotis


@PanagiotisCharalampous

trend_meanreversion
15 Oct 2019, 01:23

RE:

Panagiotis Charalampous said:

Hi trend_meanreversion,

It seems you are misundestanding what Volume in Units means. Volume in Units is expressed in units of the base asset, not in units of the quoted asset. So 1 unit of US30  = 1 contract. Also, most brokers set 1 Lot = 1 Contract for most indices. So 1 Lot of US30 = 1 contract.

So the expected values for your code should be

257010 3 257010

But because most brokers cap the number of contracts to be traded to 1000, you will probably get

1000 3 1000

Let me know if this helps.

Best Regards,

Panagiotis

Thanks Panagiotis. I suspected that might be the explanation. So essentially there is no way to know the notional risk is base currency/asset currency carried by 1 lot of US30 in this case.

I essentially want to know how much notional risk in base asset I am exposed to if I trade 'X' quantity/units of Index CFDs in cAlgo/cTrader. I assume that info must be somewhere as margin is calculated based on notional / leverage.

I would like to know if it can achieved via your Automate API. 1 US30 Index CFD = (approx) 26860 USD notional risk.

 


@trend_meanreversion

PanagiotisCharalampous
15 Oct 2019, 08:42

Hi trend_meanreversion,

If you want to know the risk in the base asset then use the volume. If you want to know the risk in quote currency then use the volume multiplied by the quote price. To get the risk in balance currency you need to make the relevant conversions to convert between the quote currency and the balance currency.

Best Regards,

Panagiotis


@PanagiotisCharalampous