Originally developed to have a button click and wait for an event, and cant do anything else. I added button12 to be able to show fib levels. it currently shows as expected for now, but i cant enter order with my other buy market button.
I need:
- 1. button12 click on - show fib, click off - remove fib object (Currently if button is pressed it draws Fib and i have to press custom cancel button for it to stop drawing and only then ablle to press other buttons)
- 2. if fib button is pressed or clicked, i can still enter market with other button
I already looked though other examples of chart traders and understand what they are doing but I need help with my script as it is different.
private enum WTROrderEntryCommandsState
{
Awaiting,
FibRetraceShow,
}
private WTROrderEntryCommandsState wtrOrderEntryCommandsState = WTROrderEntryCommandsState.Awaiting;
protected void Button13Click(object sender, RoutedEventArgs e) // Fib show
{
if (wtrOrderEntryCommandsState == WTROrderEntryCommandsState.Awaiting)
{
wtrOrderEntryCommandsState = WTROrderEntryCommandsState.FibRetraceShow;
buttonsArray[12].Background = Brushes.DarkGray;
buttonsArray[12].Foreground = Brushes.Black;
Draw.TextFixed(this, "atmNotSelected", "Fib...", TextPosition.BottomRight);
ForceRefresh();
}
}
if (atmStrategy == null && atmStrategy1 == null)
{
if(wtrOrderEntryCommandsState == WTROrderEntryCommandsState.FibRetraceShow)
{
Print("condition1");
Draw.FibonacciRetracements(this, "fib", true, 20, High[20], 2, Low[2]);
}
}
region FIB retrace
if (wtrOrderEntryCommandsState == WTROrderEntryCommandsState.FibRetraceShow)
{
Draw.FibonacciRetracements(this, "fib", true, CurrentBar-llDrawnbar, llPriceLevel , CurrentBar-hhDrawnbar, hhPriceLevel1);
fibpressed = true;
}
if(fibpressed){
}
#endregion
protected void CreateWPFControls()
{
chartTraderGrid = (chartWindow.FindFirst("ChartWindowChartTraderCont rol") as Gui.Chart.ChartTrader).Content as System.Windows.Controls.Grid;
chartTraderButtonsGrid = chartTraderGrid.Children[0] as System.Windows.Controls.Grid;
accountSelector = Window.GetWindow(ChartControl.Parent).FindFirst("C hartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector;
instrumentSelector = Window.GetWindow(ChartControl.Parent).FindFirst("C hartTraderControlInstrumentSelector") as System.Windows.Controls.ComboBox;
chartTrader = Window.GetWindow(ChartControl.Parent).FindFirst("C hartWindowChartTraderControl") as ChartTrader;
buyHighSellLowButtonsGrid1 = new System.Windows.Controls.Grid();
System.Windows.Controls.Grid.SetColumnSpan(buyHigh SellLowButtonsGrid1, 12);
buyHighSellLowButtonsGrid1.ColumnDefinitions.Add(n ew System.Windows.Controls.ColumnDefinition());
buyHighSellLowButtonsGrid1.ColumnDefinitions.Add(n ew System.Windows.Controls.ColumnDefinition() { Width = new GridLength((double)Application.Current.FindResourc e("MarginBase"))});
buyHighSellLowButtonsGrid1.ColumnDefinitions.Add(n ew System.Windows.Controls.ColumnDefinition());
buttonsArray = new System.Windows.Controls.Button[13];
buttonsArray[12] = new System.Windows.Controls.Button()
{
Content = "FIB",
Height = BuySellButtonsHeight,
Margin = new Thickness(0,0,0,0),
Padding = new Thickness(0,0,0,0),
Style = basicButtonStyle
};
buttonsArray[12].Background = Brushes.Red;
buttonsArray[12].Click += Button13Click;
System.Windows.Controls.Grid.SetColumn(buttonsArra y[12], 0);
buyHighSellLowButtonsGrid1.Children.Add(buttonsArr ay[12]);
public void DisposeWPFControls()
{
if (buttonsArray[12] != null)
buttonsArray[12].Click -= Button13Click;
RemoveWPFControls();
}
public void InsertWPFControls()
{
chartTraderButtonsGrid.RowDefinitions.Add(addedRow 10);
System.Windows.Controls.Grid.SetRow(buyHighSellLow ButtonsGrid1, (chartTraderButtonsGrid.RowDefinitions.Count - 1));
chartTraderButtonsGrid.Children.Add(buyHighSellLow ButtonsGrid1);
panelActive = true;
}
protected void RemoveWPFControls()
{
if (buyHighSellLowButtonsGrid1 != null)
{
chartTraderButtonsGrid.Children.Remove(buyHighSell LowButtonsGrid1);
chartTraderButtonsGrid.RowDefinitions.Remove(added Row10);
}
panelActive = false;
}
Comment