namespace NinjaTrader.NinjaScript.Strategies { public class OptimusStrategy : Strategy { private Optimus Optimus1; //private ADX ADX1; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Strategy here."; Name = "Optimus"; Calculate = Calculate.OnBarClose; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = true; ExitOnSessionCloseSeconds = 30; IsFillLimitOnTouch = false; MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix; OrderFillResolution = OrderFillResolution.Standard; Slippage = 0; StartBehavior = StartBehavior.WaitUntilFlat; TimeInForce = TimeInForce.Gtc; TraceOrders = false; RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose; StopTargetHandling = StopTargetHandling.PerEntryExecution; BarsRequiredToTrade = 20; // Disable this property for performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = true; } else if (State == State.Configure) { //AddChartIndicator(Optimus(Close, true, false, true, false, false, false, true, true, true, 0, true, true, true, true, true, true, true, false, false, false, @"[email protected]", false, 160, 80, false, 40)); Optimus1 = Optimus(Close, true, false, true, false, false, false, true, true, true, 0, true, false, true, true, true, true, true, false, false, false, @"[email protected]", false, 160, 80, false, 40); int OldCount = 0; } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) return; /* //TEMP REMOVING THE TIME REQUREMENT TO TEST TOMORROW AM // TRADING TIMES ALLOWED if ( // 3pm to 4:30pm ((Times[0][0].TimeOfDay >= new TimeSpan(15, 10, 0)) && (Times[0][0].TimeOfDay <= new TimeSpan(16, 30, 0))) // 6pm to 12am || ((Times[0][0].TimeOfDay >= new TimeSpan(18, 0, 0)) && (Times[0][0].TimeOfDay <= new TimeSpan(23, 30, 0)))) { */ /* // Set 1 if ((Optimus1.mStandardBuy[0] ) && (Position.MarketPosition == MarketPosition.Flat)) { EnterLong(Convert.ToInt32(DefaultQuantity), @"OptimusBuy"); } // Set 2 if ((Optimus1.mStandardSell[0] )&& (Position.MarketPosition == MarketPosition.Flat)) { EnterShort(Convert.ToInt32(DefaultQuantity), @"OptimusSell"); } */ if(OldCount != DrawObjects.Count) { OldCount = DrawObjects.Count;
also as a side q.. how can I convert
foreach (DrawingTool draw in DrawObjects.ToList())) { if (draw is DrawingTools.TriangleUp) { Print ("Tag name: "+draw.Tag); DrawingTools.TriangleUp temp = draw as DrawingTools.TriangleUp; ... {
for( int x = DrawObjects.Count; if x >= 0; x-- ) // this is how I would code this in MQL4 if (draw is DrawingTools.TriangleUp) { Print ("Tag name: "+draw.Tag); DrawingTools.TriangleUp temp = draw as DrawingTools.TriangleUp; ....
- the reason I ask is I would like to find the last drawn object not loop thru each and every one of then
thanks again for both of these!!
Comment