converting balance to lot
converting balance to lot
13 Mar 2023, 07:57
Hi
how can i convert Account.Balance to the lot ?
Replies
yaghouti
13 Mar 2023, 16:39
RE:
PanagiotisChar said:
Hi there,
Use Symbol.QuantityToVolumeInUnits method
Need help? Join us on Telegram
Need premium support? Trade with us
hi there
unfortunately not working:
public static double GetLotPerRisk(Symbol symbol, double riskPercentage, double accountBalance, double stopLossInPips)
{
return symbol.QuantityToVolumeInUnits( accountBalance);
}
for example if i have 170usd in account this function returns 17000000
@yaghouti
PanagiotisChar
13 Mar 2023, 16:47
Hi there,
Sorry, is the Symbol.VolumeToQuantity() you should be using. My typo.
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar
yaghouti
13 Mar 2023, 17:24
RE:
PanagiotisChar said:
Hi there,
Sorry, is the Symbol.VolumeToQuantity() you should be using. My typo.
thanks for your reply and help
unfortunately this one also not working, for example if account balance is 170usd this will return 0.0017,
i need a code that i give it usd amount, then it calculated maximum lot which use all the 170usd margine in order to manage the risk in next steps,
is leverage should consider manualy?
@yaghouti
PanagiotisChar
14 Mar 2023, 07:46
Hi there,
Well that's not what you asked for initially :) Here is an example
var volume = Symbol.NormalizeVolumeInUnits(Balance * Symbol.DynamicLeverage[0].Leverage / AssetConverter.Convert(1, Symbol.BaseAsset, Account.Asset));
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar
yaghouti
14 Mar 2023, 08:34
RE:
PanagiotisChar said:
Hi there,
Well that's not what you asked for initially :) Here is an example
var volume = Symbol.NormalizeVolumeInUnits(Balance * Symbol.DynamicLeverage[0].Leverage / AssetConverter.Convert(1, Symbol.BaseAsset, Account.Asset));
thank you very much
@yaghouti
yaghouti
14 Mar 2023, 09:03
RE:
PanagiotisChar said:
Hi there,
Well that's not what you asked for initially :) Here is an example
var volume = Symbol.NormalizeVolumeInUnits(Balance * Symbol.DynamicLeverage[0].Leverage / AssetConverter.Convert(1, Symbol.BaseAsset, Account.Asset));
hi there
Error CS0103 The name 'AssetConverter' does not exist in the current context
i have these includes:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
is there any package that i should add with Nuget?
@yaghouti
PanagiotisChar
14 Mar 2023, 09:11
Hi there,
You need to use cTrader 4.6. Else just ignore the conversion.
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar
PanagiotisChar
13 Mar 2023, 15:39
Hi there,
Use Symbol.QuantityToVolumeInUnits method
Aieden Technologies
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar