help plz
Created at 01 Aug 2019, 20:55
help plz
01 Aug 2019, 20:55
If i apply same cbot code at different 5 symbols at the same time
Is there a code i can use to read (total net profit of all positions) . And close it all if reached # amount of $. And start over.
For example, if i apply code on 5 different pairs, can i add code to close all positions at all symbols at the same time, ( maybe one pair loses and the other two gains some profit, i want that code to ignore net profit of each pair, but only counts on total profit for all positions and close it all when reach Specific value of profit.
Thank you.
Replies
PanagiotisCharalampous
02 Aug 2019, 14:51
Hi useretinv,
It is an expression for a selector. Read more here
Best Regards,
Panagiotis
@PanagiotisCharalampous
useretinv
02 Aug 2019, 19:20
@useretinv
PanagiotisCharalampous
05 Aug 2019, 09:27
Hi useretinv,
If you mean to filter the positions by symbol, here is an example below
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 NewcBot : Robot { [Parameter(DefaultValue = 1000)] public double Amount { get; set; } protected override void OnStart() { // Put your initialization logic here } protected override void OnTick() { if (Positions.Where(j => j.SymbolName == "EURUSD" || j.SymbolName == "EURGBP").Sum(x => x.NetProfit) > Amount) foreach (var position in Positions) position.Close(); } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
02 Aug 2019, 09:38
Hi useretinv,
See an example below
Best Regards,
Panagiotis
@PanagiotisCharalampous