ive been trying to get it to calculate the most recent bar but it always goes to the furthest one back. idk what to do.
#region Button Click Events
#region Buy High Button 1
protected void BuyHighButtonClick(object sender, RoutedEventArgs e)
{
ForceRefresh();
double closePrice = Close[0]; // Get the close of the last closed bar
Print($"Placing Buy Limit order at {closePrice}");
EnterLongLimit(0, true, 1, closePrice, "Buy Limit @C");
}
#endregion
#region Sell Low Button 2
protected void SellLowButtonClick(object sender, RoutedEventArgs e)
{
ForceRefresh();
double closePrice = Close[0]; // Get the close of the last closed bar
Print($"Placing Sell Limit order at {closePrice}");
EnterShortLimit(0, true, 1, closePrice, "Sell Limit @C");
}
#endregion
#region Buy Market Button 3
protected void BuyMarketButtonClick(object sender, RoutedEventArgs e)
{
ForceRefresh();
double highPrice = High[0] + TickSize; // Get the high of the last closed bar + 1 tick
Print($"Placing Buy Stop Market order at {highPrice}");
EnterLongStopMarket(0, true, 1, highPrice, "Buy Stop +1T");
}
#endregion
#region Sell Market Button 4
protected void SellMarketButtonClick(object sender, RoutedEventArgs e)
{
ForceRefresh();
double lowPrice = Low[0] - TickSize; // Get the low of the last closed bar - 1 tick
Print($"Placing Sell Stop Market order at {lowPrice}");
EnterShortStopMarket(0, true, 1, lowPrice, "Sell Stop -1T");
}
#endregion

Comment