total profit buy or sell
total profit buy or sell
21 Apr 2015, 13:30
hello
for a robot I use this method to cut my positions (a total gains):
[Parameter(DefaultValue = 30)]
public double totalgains { get; set; }
var netProfit = 0.0;
foreach (var openedPosition in Positions)
{
netProfit += openedPosition.NetProfit + openedPosition.Commissions;
}
if (Math.Abs(netProfit) >= totalgains)
if (netProfit >= totalgains && totalgains != 0)
{
foreach (var openedPosition in Positions)
{
ClosePosition(openedPosition);
}
/////////////////////////////////////////////////////////////////////
in this method it cut all the buy and sell positions.
I would like a method that separately cut a total buy and sell total.
[Parameter(DefaultValue = 30)]
public double totalBuy { get; set; }
[Parameter(DefaultValue = 30)]
public double totalSell { get; set; }
thank you for your help
cordially
Replies
tradermatrix
21 Apr 2015, 15:47
RE: RE:
mindbreaker said:
tradermatrix said:
hello
for a robot I use this method to cut my positions (a total gains):
[Parameter(DefaultValue = 30)]
public double totalgains { get; set; }var netProfit = 0.0;
foreach (var openedPosition in Positions)
{
netProfit += openedPosition.NetProfit + openedPosition.Commissions;
}
if (Math.Abs(netProfit) >= totalgains)
if (netProfit >= totalgains && totalgains != 0)
{
foreach (var openedPosition in Positions)
{
ClosePosition(openedPosition);
}/////////////////////////////////////////////////////////////////////
in this method it cut all the buy and sell positions.
I would like a method that separately cut a total buy and sell total.[Parameter(DefaultValue = 30)]
public double totalBuy { get; set; }[Parameter(DefaultValue = 30)]
public double totalSell { get; set; }
thank you for your help
cordially
Hi,
if(openedPosition.TradeType.Buy){
// todo with buy positions
}else{
// todo with sell positions
}
Bye.
thank you
You can develop your idea by using my example because malgres your explanation I have a hard time implementing it.
cordially.
@tradermatrix
mindbreaker
21 Apr 2015, 14:20
RE:
tradermatrix said:
Hi,
if(openedPosition.TradeType.Buy){
// todo with buy positions
}else{
// todo with sell positions
}
Bye.
@mindbreaker