Max open trades - Code not working
Max open trades - Code not working
29 Nov 2022, 00:50
At the moment I have a code working perfectly but the code only opens one trade at a time. Even if the pattern is recognized after a trade is open, it will not take the trade because of the open trade, and I would like the bot to open those trades as well...
I have a pseudo code but I do not know how to implement it in my code.
IF TradesOpen > x
Open New Trade
ELSE
Do Nothing
I believe this part of my code is making it open only one trade though
protected override void OnPositionOpened(Position openedPosition)
{
position = openedPosition;
counter = 1;
Trade.ModifyPosition(openedPosition, GetAbsoluteStopLoss(openedPosition, StopLoss), GetAbsoluteTakeProfit(openedPosition, TakeProfit));
}
protected override void OnPositionClosed(Position position)
{
counter=0;
}
private double GetAbsoluteStopLoss(Position position, int stopLossInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice - Symbol.PipSize * stopLossInPips
: position.EntryPrice + Symbol.PipSize * stopLossInPips;
}
private double GetAbsoluteTakeProfit(Position position, int takeProfitInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice + Symbol.PipSize * takeProfitInPips
: position.EntryPrice - Symbol.PipSize * takeProfitInPips;
}
PanagiotisChar
29 Nov 2022, 09:02
Hi there,
The code you posted does not handle any position opening logic.
Aieden Technologies
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar