ButtontoHotkey

 avatar
unknown
csharp
3 years ago
1.8 kB
5
Indexable
		protected void ChartControl_PreviewKeyDown(object sender, KeyEventArgs e)
        {
			TriggerCustomEvent(o =>
			{
				Order buyMktOrder = null;

				if (Keyboard.IsKeyDown(Key.NumPad7))
				{
					buyMktOrder  = account.CreateOrder(
									Instrument, 
									OrderAction.Buy, 
									OrderType.Market, 
									OrderEntry.Manual, 
									TimeInForce.Day, 
									1, 
									0, 
									0, 
									"", 
									"buyMktOrder"+DateTime.Now.ToString(), 
									DateTime.MaxValue, 
									null);
				}
				
				account.Submit(new[] { buyMktOrder });
			}, null);
			e.Handled = true;
			
			
			TriggerCustomEvent(p =>
			{
				Order sellMktOrder = null;
				
				if (Keyboard.IsKeyDown(Key.NumPad8))
				{
					sellMktOrder = account.CreateOrder(
									Instrument, 
									OrderAction.Sell, 
									OrderType.Market, 
									OrderEntry.Manual, 
									TimeInForce.Day, 
									1, 
									0, 
									0, 
									"", 
									"sellMktOrder"+DateTime.Now.ToString(), 
									DateTime.MaxValue, 
									null);
				}
				
				account.Submit(new[] { sellMktOrder });
			}, null);
			e.Handled = true;
			
			
			TriggerCustomEvent(q =>
			{
				Order stopLoss = null;
				string signalName = null;
				Instrument instrument = null;
				OrderAction orderAction = 0;
				OrderEntry orderEntry = 0;
				int quantity = 0;
				double price = 0;
				
				if (Keyboard.IsKeyDown(Key.NumPad9))
				{
					myTickHunter objstopLoss = new myTickHunter();
					
					objstopLoss.CreatePositionStopLoss(signalName, instrument, orderAction, orderEntry, quantity, price);
					stopLoss = objstopLoss;
				}
				
				account.Submit(new[] { stopLoss });
			}, null);
			e.Handled = true;
			
			
        }
Editor is loading...