Description
AW Close Position.
this bot close all position and cancel all order after get daily profit percent.
support us for more free indicator and bot by sign up in LiteFinance broker from this link
update: NET 6
using System;
using System.Linq;
using cAlgo.API;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class AWCPDaily : Robot
{
[Parameter("Take Profit Percent", DefaultValue = 3.1)]
public double tpPercent { get; set; }
protected override void OnStart()
{
}
protected override void OnTick()
{
double DailyNet1 = Positions.Sum(p => p.NetProfit);
double DailyNet2 = History.Where(x => x.ClosingTime.Date == Time.Date).Sum(x => x.NetProfit);
double DailyNet = Math.Round(DailyNet1 + DailyNet2, 2);
// get Starting Balance
var oldTrades = History.Where(x => x.ClosingTime.Date != Time.Date).OrderBy(x => x.ClosingTime).ToArray();
double StartingBalance;
if (oldTrades.Length == 0)
{
StartingBalance = History.Count == 0 ? Account.Balance : History.OrderBy(x => x.ClosingTime).First().Balance;
}
else
{
StartingBalance = oldTrades.Last().Balance;
}
//calc Daily Percent Profit
double DailyPercent = DailyNet / StartingBalance * 100;
foreach (var position in Positions)
{
if (DailyPercent > tpPercent)
{
ClosePositionAsync(position);
}
}
foreach (var order in PendingOrders)
{
if (DailyPercent > tpPercent)
{
CancelPendingOrder(order);
}
}
}
}
}
IR
IRCtrader
Joined on 17.06.2021
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: AW CP Daily.algo
- Rating: 0
- Installs: 1629
- Modified: 08/07/2022 06:32
Warning! Running cBots downloaded from this section may lead to financial losses. Use them at your own risk.
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.