Topics
Replies
mgpublic
11 Nov 2020, 17:59
RE:
PanagiotisCharalampous said:
Hi mgpublic,
You can use conditions in your Count() method like below
if (Positions.Count(x => x.SymbolName == "AUDUSD") < 5) { // Do something }
Best Regards,
Panagiotis
Hi again Panagiotis,
Sorry but I don't get it to work as I want. For example I want max 10 positions and max 5 EURUSD and 5 GBPUSD.
I'm using the code below and it only opens 5 positions, either EURUSD or GBPUSD. What i'm I doing wrong?
protected override void OnTick()
{
if (Positions.Count < MaxPositions)
if (Positions.Count(x => x.SymbolName == "EURUSD") < 5)
if (Positions.Count(x => x.SymbolName == "GBPUSD") < 5)
//mgpublic
@mgpublic
mgpublic
10 Nov 2020, 12:51
RE:
PanagiotisCharalampous said:
Hi mgpublic,
If you write your execution code inside the if statement, it should work as you expect it to work.
Best Regards,
Panagiotis
Hi again Panagiotis,
I need more help. Can you help with the code how to maximize for example 50 positions but max 1 of a kind? (See the code above early in this conversation)
For example I want max 50 positions total but only five position of AUDUSD at a time? I want to use multiple instances and dont want for example the bot to open 50 AUDUSD only.
Thanks again!
@mgpublic
mgpublic
06 Nov 2020, 20:15
RE:
PanagiotisCharalampous said:
Hi mgpublic,
Can you be more specific. Do you want the order to execute when XXXXX is false?
Best Regards,
Panagiotis
Hi,
Thx for help! I'm searching for a code to limit max open positions and I found the one below. I want help to make the code to work. Can you help me with the code to not execute a new order if max positions is open. Thx again'!
[Parameter(DefaultValue = 1, MinValue = 1)]
public int MaxPositions { get; set; }
protected override void OnTick()
{
if (Positions.Count < MaxPositions)
{
// Do somehting
}
}
protected override void OnStop()
{
}
@mgpublic
mgpublic
18 Nov 2020, 01:08
RE: RE:
mparama said:
Thx for reply and help.
How do I code so that it finds and closes the position with SymbolName "USDJPY" either if its posBuy or posSell. In the example above its only posBuy.
@mgpublic