MIT/LIT anyone with good working example code? - NinjaTrader Programming | futures io social day trading
futures io futures trading


MIT/LIT anyone with good working example code?
Updated: Views / Replies:1,923 / 9
Created: by Trader.Jon Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

MIT/LIT anyone with good working example code?

  #1 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

MIT/LIT anyone with good working example code?

Greets!

NT doesnt have a supported option for Market/Limit If Touched orders, and looking at the threads online I did find little to go on. Basically I am trying to get the same fill I get with market orders, but at a price that is closer to targets I would use in limit orders.

 
Code
		protected override void OnMarketData(MarketDataEventArgs e)
		
			if (e.MarketDataType == MarketDataType.Ask)

{

if ( e.Price >= touch_price )

    {

        EnterLimit ( ) ;

    }

}
.. and thats all ..TraderWerks 2009 May

This is a work in progress== I am trying to shift the order entry from OnBarUpdate to OnMarketData but am not sure if I am interpreting the intent/use correctly.

Guru response definitely appreciated,
Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received


The intent is that you look at the price every tick, with OnMarketData. So you are constantly looking at the price so that it gives you a lot of flexibility in order management.

Math. A gateway drug to reality.
Reply With Quote
 
  #4 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

Hazy Concepterons


traderwerks View Post
The intent is that you look at the price every tick, with OnMarketData. So you are constantly looking at the price so that it gives you a lot of flexibility in order management.

Hi traderwerks!

Thanks.. I do appreciate the response.

I am, I think, so ingrained in 'OnBarUpdate' mindset that I am having a conceptual challenge on how that will integrate together (with OnMarketData) to manage the trade.

For example, this is typically what my strategy orders from
 
Code
 {	if ( (Position.MarketPosition == MarketPosition.Flat) && (timeSeries[0] >= 1)  )
             // Try to go LONG
	{   if (	WatchToGoLong == 1 )	
	//
		{  if   ( BarsInProgress == 0 )
                   		 {	
		tVars.vLow = Close[0];
		tVars.vHigh = Close[0];
		tVars.cStopLossTicks = iStopLossTicks;
	SetStopLoss(CalculationMode.Ticks, tVars.cStopLossTicks * vTickMult);					
DrawTriangleUp(CurrentBar.ToString() + "sl", true, 0, Close[0] - tVars.cStopLossTicks * TickSize * vTickMult, Color.DarkGreen);
	// Enter Long
		if ((iOrderL1 == null && iQuantity1 != 0)
	iOrderL1 = EnterLongLimit(0, true, iQuantity1, Closes[0][0] + 2*TickSize, sENTRY1L);
and I am starting to think in this fashion to move the ordering into

 
Code
		protected override void OnMarketData(MarketDataEventArgs e)
		
			if (e.MarketDataType == MarketDataType.Ask)

{

if ( e.Price >= touch_price )

   {	
		tVars.vLow = Close[0];
		tVars.vHigh = Close[0];
		tVars.cStopLossTicks = iStopLossTicks;
	SetStopLoss(CalculationMode.Ticks, tVars.cStopLossTicks * vTickMult);					
DrawTriangleUp(CurrentBar.ToString() + "sl", true, 0, Close[0] - tVars.cStopLossTicks * TickSize * vTickMult, Color.DarkGreen);
	// Enter Long
		if ((iOrderL1 == null && iQuantity1 != 0)
	iOrderL1 = EnterLongLimit(0, true, iQuantity1, Closes[0][0] + 2*TickSize, sENTRY1L);
} 
}
with the OnBarUpdate just manages the indicators and conditions that go along with that
...

 
Code
{	if ( (Position.MarketPosition == MarketPosition.Flat) && (timeSeries[0] >= 1)  )
             // Try to go LONG
	{   if (	WatchToGoLong == 1 )	
	//
		{  if   ( BarsInProgress == 0 )
                   		 {  touch_price = Closes[0][0]  }
}
}
}
but my gut says that this is too simplistic and I am missing an element to have it function correctly. Input from your experience is definitely appreciated.

Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
  #5 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received


Trader.Jon View Post
 
Code
		tVars.vLow = Close[0];
		tVars.vHigh = Close[0];
		tVars.cStopLossTicks = iStopLossTicks;
	SetStopLoss(CalculationMode.Ticks, tVars.cStopLossTicks * vTickMult);					
DrawTriangleUp(CurrentBar.ToString() + "sl", true, 0, Close[0] - tVars.cStopLossTicks * TickSize * vTickMult, Color.DarkGreen);

but my gut says that this is too simplistic and I am missing an element to have it function correctly. Input from your experience is definitely appreciated.

Jon

It is a good start but I would leave the above code for BarUpdate. You just need the parts that need to be in OnMarketData as small as possible. ( And it doesn't need to be there ).

OnBarUpdate DOES just manages the indicators and anything that has High[0], etc needs to be in there.

It is not as difficult as people think. I have been using limit with touch orders in my strats for a couple of years and trading live everyday for a while and they work nicely.

Math. A gateway drug to reality.
Reply With Quote
The following user says Thank You to traderwerks for this post:
 
  #6 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

G@@D ... its not difficult, only like learning to swim


traderwerks View Post

It is not as difficult as people think. I have been using limit with touch orders in my strats for a couple of years and trading live everyday for a while and they work nicely.

traderwerks,

Again, thanks for the share..

Just to clarify then, to sync my head, and nothing code specific ..

It really doesnt matter what chart type/period is being used, and you are using the normal(?!) available EnterLongStopLimit() with (I guess) true bool condition (because I am thinking on adding a cancel order if not filled in 2 bars etc). For some reason my feeling was there might be different Enter() commands only useable inside OnMarketData, but cant find any in the help

This has been REALLY helpful!

Thanks
Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote
 
  #7 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received

I like to swim


Trader.Jon View Post

It really doesnt matter what chart type/period is being used, and you are using the normal(?!) available EnterLongStopLimit() with (I guess) true bool condition (because I am thinking on adding a cancel order if not filled in 2 bars etc).

Well, you are mostly correct. It would be a EnterLongLimit order. No sense in putting a stop orde r in OnMarketData.


Trader.Jon View Post

For some reason my feeling was there might be different Enter() commands only useable inside OnMarketData, but cant find any in the help

OnMarketData is just like OnBarUpdate, only it happens a lot more often ( usually ). So anything you can use in OnBarUpdate, you can use in OnMarketData.

Math. A gateway drug to reality.
Reply With Quote
The following user says Thank You to traderwerks for this post:
 
  #8 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

almost floating along


traderwerks View Post
OnMarketData is just like OnBarUpdate, only it happens a lot more often ( usually ). So anything you can use in OnBarUpdate, you can use in OnMarketData.

traderwerks,

With your (much appreciated) assistance I was able to get an order placed and covered in a strategy, running parallel to orders placed with OnBarUpdate. I didnt change any of the entry handling code: just moved to code as suggested
 
Code
											#region Region_OnMarketData
//		
    protected override void OnMarketData(MarketDataEventArgs e)
					{
			 //Update bid / ask / spread variables
           UpdateBidAskSpread(out cAsk, out cBid, out cSpread);  
		

if ( e.Price == touch_price )

   {	Print("Last = "+e.Price);	 		
	if ((iOrderL1 == null || Historical) && iQuantity1 != 0)
	{	iOrderL1 = EnterLongLimit(0, true, iQuantity1, Closes[0][0] + 1*TickSize, sENTRY1L); 
		LL_EntryBar0_OMD_L1 = CurrentBars[0];
			Print("Entered LL_Order from OnMarketData PreviousBar#= "+CurrentBars[0]+", Time of bar=  "+Times[0][0]+", bar closed "+Closes[0][0]+", BarHI= "+Highs[0][0]+", BarLO= "+Lows[0][0]);
						
	}
	
	}
	
		}
Prints show me behaviour I expected, plus some I didnt. The orders in OnBarUpdate are only submitted once,
 
Code
 iOrderL5 = EnterLongStopLimit(0, true, iQuantity5, Closes[0][0]+ 2*TickSize, Closes[0][0]+ 1*TickSize, sENTRY5L);
	iOrderL2 = EnterLong(0, iQuantity2, sENTRY2L);
and are not submitted again when actively working, but the OnMarketData order is submitted on every tick even when working
 
Code
 	iOrderL1 = EnterLongLimit(0, true, iQuantity1, Closes[0][0] + 1*TickSize, sENTRY1L);
The 'entries per direction' is set to 1 so the orders are not sent out, but it is still bothersome that the order handling isnt working the same.

From the output:
 
Code
Last = 1.404
3/28/2011 7:45:55 AM Entered internal PlaceOrder() method at 3/28/2011 7:45:55 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4041 StopPrice=0 SignalName='e1L' FromEntrySignal=''
3/28/2011 7:45:55 AM Ignored PlaceOrder() method at 3/28/2011 7:45:55 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4041 StopPrice=0 SignalName='e1L' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
Entered LL_Order from OnMarketData PreviousBar#= 653, Time of bar=  3/28/2011 7:45:52 AM, bar closed 1.404, BarHI= 1.4052, BarLO= 1.404
Last = 1.404
3/28/2011 7:45:55 AM Entered internal PlaceOrder() method at 3/28/2011 7:45:55 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4041 StopPrice=0 SignalName='e1L' FromEntrySignal=''
3/28/2011 7:45:55 AM Ignored PlaceOrder() method at 3/28/2011 7:45:55 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4041 StopPrice=0 SignalName='e1L' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
Entered LL_Order from OnMarketData PreviousBar#= 653, Time of bar=  3/28/2011 7:45:52 AM, bar closed 1.404, BarHI= 1.4052, BarLO= 1.404
Last = 1.404
3/28/2011 7:45:56 AM Entered internal PlaceOrder() method at 3/28/2011 7:45:56 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4041 StopPrice=0 SignalName='e1L' FromEntrySignal=''
3/28/2011 7:45:56 AM Ignored PlaceOrder() method at 3/28/2011 7:45:56 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4041 StopPrice=0 SignalName='e1L' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
Entered LL_Order from OnMarketData PreviousBar#= 653, Time of bar=  3/28/2011 7:45:52 AM, bar closed 1.404, BarHI= 1.4052, BarLO= 1.404
Last = 1.404
Any thoughts or suggestions?
Jon

Followup: Even though the 1L long entry from OnMarketData was stopped out, the print is still showing entry price would be 1.404. The next bar closed 1.4030 and was a trigger bar for a market order L2 that was completed, but the e.Price still printing out at 1.4040

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!

Last edited by Trader.Jon; March 28th, 2011 at 10:14 AM.
Reply With Quote
 
  #9 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received

After you place your order, reset your touch price or whatever so you don't get any more orders. The order will be cancelled at the end of the bar.

Math. A gateway drug to reality.
Reply With Quote
The following user says Thank You to traderwerks for this post:
 
  #10 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received



traderwerks View Post
After you place your order, reset your touch price or whatever so you don't get any more orders. The order will be cancelled at the end of the bar.

I think thats probably the only thing I havent tried yet
It is annoying that I am still restricted by bar updates (in a way)

Thanks,
Jon

Writing to you from the wonderful province of Ontario, Canada. Home to the world's biggest natural negative ion generator, the Niagara Falls, and to those that dare to know how to go over it in a barrel. SALUTE!
Reply With Quote

Reply



futures io > > > > > MIT/LIT anyone with good working example code?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
how is eotpro's ncep working sharky Trading Reviews and Vendors 60 June 16th, 2016 09:10 AM
Market Replay Not working Mercury NinjaTrader 4 September 24th, 2011 07:34 PM
DrawDot code not working in NT7..? prisonbreaker82 NinjaTrader Programming 2 June 6th, 2011 12:52 PM
Does anyone use Market if Touched (MIT) to take profit cw30000 The Elite Circle 3 June 2nd, 2011 01:02 AM
NT7b12 and strategies (not working) nanobiotech NinjaTrader 9 March 28th, 2010 08:28 AM


All times are GMT -4. The time now is 08:58 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-18 in 0.13 seconds with 19 queries on phoenix via your IP 107.20.115.174