using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Money_Management { public partial class FMain : Form { public FMain() { InitializeComponent(); } private void Btn_money_management_Click(object sender, EventArgs e) { string SoldeDuCompte = Text_Solde_Du_Compte.Text.Trim().ToString(); string PositionAchat = Text_Position_Achat.Text.Trim().ToString(); string PositionVente = Text_Stop_Loss.Text.Trim().ToString(); string StopLoss = Text_Position_Achat.Text.Trim().ToString(); string Risk = Text_Risk.Text.Trim().ToString(); if (!string.IsNullOrEmpty(SoldeDuCompte) && !string.IsNullOrEmpty(PositionAchat) && !string.IsNullOrEmpty(PositionVente) && !string.IsNullOrEmpty(StopLoss) && !string.IsNullOrEmpty(Risk)) { double DoubleSoldeDuCompte; double DoublePositionAchat; double DoublePositionVente; double DoubleStopLoss; double DoubleRisk; if (Double.TryParse(SoldeDuCompte, out DoubleSoldeDuCompte) && Double.TryParse(PositionAchat, out DoublePositionAchat) && Double.TryParse(PositionVente, out DoublePositionVente) && Double.TryParse(StopLoss, out DoubleStopLoss) && Double.TryParse(Risk, out DoubleRisk)) { Double slpercent = (DoubleStopLoss - DoublePositionAchat) / DoublePositionAchat; Double risk = DoubleRisk / 100; Double ratio = risk / slpercent; Double DoubleTaillePosition = DoubleSoldeDuCompte * ratio; Label_Taille_Position.Text = " " + DoubleTaillePosition.ToString("#,#0.00 $"); } } } } }
Double.TryParse
if
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)