However at the time of press trendprice is 0 and it activates whenever.
Below code is before OnBarUpdate
protected void Button9Click(object sender, RoutedEventArgs e) // Buy TLB { if (atmStrategy == null && wtrOrderEntryCommandsState == WTROrderEntryCommandsState.Awaiting) { if (atmStrategySelector.SelectedAtmStrategy != null) { // if ((trendDirection2==1 && Close[0] > trendPrice2) ) // { Print("test1" + Time[0]); // Print("OtrendDirection2" + trendDirection2); // Print("OcRising2" + cRising2); Print("trendPrice2"+trendPrice2); // Print("trendSignal2"+trendSignal2); wtrOrderEntryCommandsState = WTROrderEntryCommandsState.BuyTLB; account = accountSelector.SelectedAccount; account.OrderUpdate += OnOrderUpdate; account.ExecutionUpdate += OnExecutionUpdate; instr = atmStrategySelector.Instrument; atm = atmStrategySelector.SelectedAtmStrategy; cbxSelectedValue = cbx.SelectedValue.ToString(); numericStepperValue = numericStepper.Value; qudSelectorValue = qudSelector.Value; buttonsArray[8].Background = Brushes.DarkGray; buttonsArray[8].Foreground = Brushes.Black; Draw.TextFixed(this, "atmNotSelected", "TLB Buy...", TextPosition.BottomRight); ForceRefresh(); // } } else { Draw.TextFixed(this, "atmNotSelected", "ATM Not Selected!", TextPosition.BottomRight); ForceRefresh(); } } }
protected override void OnBarUpdate() { if (CurrentBar < 3) return; EMA[0] = ema[0]; close0 = Close[0]; ema0 = ema[0]; // trendDirection2 = trendDirection2; // trendPrice2 = trendPrice2; // trendSignal2 = trendSignal2; if (State != State.Realtime) return; int trendDirection = BTL.Direction; //1=TrendUp, -1=TrendDown, 0=New trend not yet determined double trendPrice = BTL.TrendPrice; //Tick value at rightmost bar of current trend line int trendSignal = BTL.Signal; //1=resistance break, -1=support break int trendDirection2 = BTL2.Direction; //1=TrendUp, -1=TrendDown, 0=New trend not yet determined double trendPrice2 = BTL2.TrendPrice; //Tick value at rightmost bar of current trend line int trendSignal2 = BTL2.Signal; //1=resistance break, -1=support break
Comment