Trying to stream line some actions. Currently after a button is pressed, it takes the last drawn Risk Reward object and calculates certain data. The idea is to calculate the data as soon as the object is DONE drawing. Here's the code:
foreach (ChartScale cs in ChartControl.ChartPanels.SelectMany(cp => cp.Scales)) cs.ChartObjects.CollectionChanged += OnChartObjectsChanged; ... private void OnChartObjectsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { if (e.NewItems == null) return; dynamic rr = e.NewItems[0]; if (rr.ToString().Equals("NinjaTrader.NinjaScript.DrawingTools.RiskReward")) { Print("new risk reward"); if(rr.DrawingState == DrawingState.Building) { Print("Is Building"); ?LAUNCH EVENT TO RUN ONCE DONE BUILDING? } else if(rr.DrawingState == DrawingState.Normal) { Print("Not moving or building"); CalculatePositionSize(rr); } } } }
Solution 1: If the drawing state is building, launch another event listener to trigger once the drawing state property changes. Then calculate the data.
Solution 2: If the drawing state is building, launch another event listener to trigger on the next mouse down. Then calculate the data.
Solution 1 is a more accurate solution. How would solution 1 be implemented?
Best regards,
Ocean Trading Indicators
Comment