Topics
Replies
Jexodus
24 Apr 2023, 09:49
RE:
PanagiotisChar said:
Hi Jexodus,
You cannot modify positions using an indicator. You need to use a cBot.
Need help? Join us on Telegram
Need premium support? Trade with us
Thanks for the reply PanagiotisChar. I thought that might be the case. Is it not weird that the method is accessible from the indicator class though? Noting that it can't be used....
@Jexodus
Jexodus
20 Apr 2023, 06:21
( Updated at: 20 Apr 2023, 06:22 )
RE:
Here is a Windows panel example that firemyst was talking about... You can create multiple TextBlocks and add them as children to the panel as contained in the below code...
var riskText = new TextBlock
{
BackgroundColor = Color.LightGray,
ForegroundColor = Color.Black,
TextAlignment = TextAlignment.Center,
Text = <insert your variable string here>,
Padding = "8 4",
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Center,
Margin = 2,
Width = 80,
};
var topPanel = new StackPanel()
{
Orientation = Orientation.Vertical,
Width = 90,
Height = 100,
};
var topTitleDisplayBar = new StackPanel()
{
Orientation = Orientation.Horizontal,
BackgroundColor = Color.DarkSlateBlue
};
var topTitleDisplayLable = new TextBlock()
{
Text = "Automation",
Margin = "12 4",
HorizontalAlignment = HorizontalAlignment.Stretch,
FontWeight = FontWeight.Bold,
FontStyle = FontStyle.Italic
};
topTitleDisplayBar.AddChild(topTitleDisplayLable);
topPanel.AddChild(topTitleDisplayBar);
topPanel.AddChild(riskText);
var topPanelDisplayBorder = new Border()
{
Child = topPanel,
BorderColor = Color.DeepSkyBlue,
BorderThickness = 1,
Opacity = 0.8,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = 10
};
Chart.AddControl(topPanelDisplayBorder);
@Jexodus
Jexodus
18 Apr 2023, 11:21
RE:
Thanks for the confirmation about the cBot. I thought that would be the case.
I am quite certain that the value I', passing in for "position" is not null, as i am referencing the position object and drawing data off it for stop loss calculation.
public void AutoTradeManagement()
{
double stopLossLevel = double.NaN;
foreach (Position position in Positions)
{
SymbolData currentSymbol = DataManager.GetSymbolrecord(position.SymbolName);
switch (currentSymbol.AutoStops)
{
// Stop loss is calculated and returned here through calling relevant methods.
stopLossLevel = // stop loss calculation
}
Print($"Stop loss is: {stopLossLevel}");
position.ModifyStopLossPrice(stopLossLevel);
}
}
The other clue that the position object not null is that the automate log shows the following:
18/04/2023 15:55:06.349 | Modifying position PIDXXXXXXX (SL: 1.09389, TP: 1.09776)
I have remove the PID from the output. The take profit is not calculated by my code, so can only be accessed from the position object. As you can see, it also shows the calculated stop loss value, showing a suitable value has been parsed into the ModifyStopLossPrice method. This one really has me stumped...
@Jexodus
Jexodus
16 Apr 2023, 11:59
RE:
PanagiotisChar said:
Hi there,
This method is only available in v4.7.7. Make sure you are using the correct version.
Need help? Join us on Telegram
Need premium support? Trade with us
I knew it would be something simple. I was using my brokers version which has yet to be updated to 4.7.7. Works perfectly now. Thanks mate.
@Jexodus
Jexodus
13 Dec 2024, 01:58
I fully agree, this would be a very valuable feature to a lot of traders.
@Jexodus