Don't execute order
Don't execute order
06 Nov 2020, 01:58
Hello,
I want help with code to not execute order if something occurs.
What is the opposite of the code below when I dont want to execute order.
if (XXXXXX)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, volumeInUnits, label, StopLossInPips, TakeProfitInPips);
consolidation = 0;
Thx for help!
Replies
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
PanagiotisCharalampous
09 Nov 2020, 08:31
Hi mgpublic,
If you write your execution code inside the if statement, it should work as you expect it to work.
Best Regards,
Panagiotis
@PanagiotisCharalampous
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
PanagiotisCharalampous
10 Nov 2020, 14:15
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
@PanagiotisCharalampous
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
PanagiotisCharalampous
13 Nov 2020, 14:56
Hi mgpublic,
The code snippet does not help me understand the problem. You need to provide to complete cBot code.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
06 Nov 2020, 08:26
Hi mgpublic,
Can you be more specific. Do you want the order to execute when XXXXX is false?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous