NexusFi: Find Your Edge


Home Menu

 





Tricky NinjaScript coding {questions} . . .


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one eman with 3 posts (0 thanks)
    2. looks_two jmejedi with 3 posts (0 thanks)
    3. looks_3 TheWizard with 2 posts (1 thanks)
    4. looks_4 cory with 1 posts (0 thanks)
    1. trending_up 5,275 views
    2. thumb_up 2 thanks given
    3. group 5 followers
    1. forum 10 posts
    2. attach_file 2 attachments




 
Search this Thread

Tricky NinjaScript coding {questions} . . .

  #1 (permalink)
 
jmejedi's Avatar
 jmejedi 
Lilburn, GA
 
Experience: Beginner
Platform: NinjaTrader
Broker: VelocityFutures/TT
Trading: ES
Posts: 62 since Jan 2011
Thanks Given: 13
Thanks Received: 4

Fellow brothers & sisters traders,

I have the following tricky NinjaScript coding {questions} . . . which I am hoping you guys may help me with .............. I know I would arrive at these answers, eventually, but I would greatly appreciate if you guys could give me a head start:

1. Could someone please show me how I would submit 2 limit orders, one at the best bid & one at the best ask, that is, Buy-limit at the best bid & Sell-limit at the best ask ,,,,,,,,,,,,,, ?

2. After performing the above , could someone please show me how I would check and see if these limit orders got filled ,,,,,,,,,,,,,,,,,,,,,,,, ??

3. And now, could someone please show me how I would go about cancelling these limit orders ,,,,,,,,,,,,,,,,,,,,,,,,,,, ???

Thanks in advance for any help you may provide , Would be greatly appreciated !!

Thanks again,
Jimmy M. Espana

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
NexusFi Journal Challenge - May 2024
Feedback and Announcements
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
41 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #3 (permalink)
 eman 
Galveston ,TX
 
Experience: Intermediate
Platform: NT7
Broker: Zaner
Trading: Futures
Posts: 386 since Mar 2010
Thanks Given: 364
Thanks Received: 435


here are a few links back to the official NT7 help guide that should get you pointed in the right direction:


jmejedi View Post
1. Could someone please show me how I would submit 2 limit orders, one at the best bid & one at the best ask, that is, Buy-limit at the best bid & Sell-limit at the best ask ,,,,,,,,,,,,,, ?

EnterLongLimit()
EnterShortLimit()
keep in mind that you may not be able to straddle the market due to the Frank-Dodd stuff unless you are using two separate accounts


jmejedi View Post
2. After performing the above , could someone please show me how I would check and see if these limit orders got filled ,,,,,,,,,,,,,,,,,,,,,,,, ??

Advanced Order Handling
click to expand the second section that discusses IOrder class and OnOrderUpdate()


jmejedi View Post
3. And now, could someone please show me how I would go about cancelling these limit orders ,,,,,,,,,,,,,,,,,,,,,,,,,,, ???

CancelOrder()

cheers,
-e

Reply With Quote
  #4 (permalink)
 
jmejedi's Avatar
 jmejedi 
Lilburn, GA
 
Experience: Beginner
Platform: NinjaTrader
Broker: VelocityFutures/TT
Trading: ES
Posts: 62 since Jan 2011
Thanks Given: 13
Thanks Received: 4

thanks "eman" for the quick response . . . . . . . . . . . . I'll check those out ............................................. "eman" or anybody else . . . please see attachment attached ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, in addition to my above questions.... I want / need help with how to keep track of position in line . . . . for example, after submitting those said two limit orders........................ looking at this attachment,,, here's my explanation for the #s seen in this attachment:

What is highlighted in blue area is one scenario , the part above it is another scenario . . . each of these portions, can be considered 3-parts/3-levels ,,,,,,, the first part/first level, let's take for example the blue highlighted region, where there is a "7" and a "10", think of this as the two queues for best bid & best ask.... this is before we enter the two limit orders..... once our two limit orders are put into the queue...... now note the 2 part / 2 level ...... each queue is now +1 ...... b/c we just entered the best bid & best ask queues ......... doing so,, places us in place "8" & in place "11" , in the best bid & best ask queues , respectively ............. Now after having entered the lines..... some people/contracts ahead in those lines are satisfied (and leave the queue) & also some people/contracts come in line behind us ........ {{ I hope I'm making sense , you should be following my logic , at least I hope so , lol }} ................ after this activity/movement, we are no longer in the same place in line as we were when we first entered the line ....... the math being shown, should make sense . . . . . . . .

Alright,,,,, I hope you're following me ................................................ okay ...... back to where I want to go with this,,,, namely.... "how to keep track of position in line" .................... more specifically:

How (using NinjaScript) do I accomplish the goal of knowing where exactly am I in the line at any point in time ?

I know I need to GET the volume of the best bid & best ask . . . . I know I must know how much people/contracts ahead of me in line have left . . . . I know I must know how much people/contracts just got behind in line . . . . . . Okay/alright/fine....... Could someone please help me with how I would do this in NinjaScript . . . provide me with an example...... or could answer these questions for me, please ???

Thanks in advance,
Jimmy M. Espana

Attached Thumbnails
Click image for larger version

Name:	keepingTrackOfPositionInLine.jpg
Views:	256
Size:	95.0 KB
ID:	38456  
Started this thread Reply With Quote
  #5 (permalink)
 eman 
Galveston ,TX
 
Experience: Intermediate
Platform: NT7
Broker: Zaner
Trading: Futures
Posts: 386 since Mar 2010
Thanks Given: 364
Thanks Received: 435

two clarifications:
1. using limit orders allows you to specify a price; once submitted your limit price wouldn't change with the market;
2. until your order is filled, you may update your limit order as the Bid/Ask changes on a tick-by-tick basis.

i haven't tried (and am not sure if it's possible) to monitor my position in the queue. perhaps others have done some work in this area.

cheers,
-e

Reply With Quote
  #6 (permalink)
 
jmejedi's Avatar
 jmejedi 
Lilburn, GA
 
Experience: Beginner
Platform: NinjaTrader
Broker: VelocityFutures/TT
Trading: ES
Posts: 62 since Jan 2011
Thanks Given: 13
Thanks Received: 4

thanks "eman" for your input ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ladies & gentlemen . . . anyone else can help (please) ????

I have an idea regarding this . . . . . How could I (via NinjaScript) be able to find-out and/or know how much people/contracts just got traded on the most recent "last trade" ?
[[[ that is,, how to determine the 'volume' of the 'last trade' ?? ]]]

( furthermore,,,, & whether this 'last trade' occurred on the best bid side or the best ask side ,,,,,,,,,,, ??? )


to help out ,,,,, let's take the SuperDOM ........... the 'last trade' is highlighted in yellow..... & throughout each tick (aka trade)...... this yellow highlight switches between the best bid & best ask price levels ................. moreover... when this happens...... there's always # in parentheses . . . which I understand to be . . the last traded volume , , , , , , , , , , , , , , , , , , ,


Alright,,,, looking forward to some replies . . . . . Thanks in advance !

- Jimmy M. Espana

Started this thread Reply With Quote
  #7 (permalink)
 eman 
Galveston ,TX
 
Experience: Intermediate
Platform: NT7
Broker: Zaner
Trading: Futures
Posts: 386 since Mar 2010
Thanks Given: 364
Thanks Received: 435

maybe i misunderstood what you're asking here ... you can get the current ask/bid and volume by using GetCurrentAsk(), GetCurrentAskVolume(), GetCurrentBid(), and GetCurrentBidVolume()

i thought you were asking how to read the current order book at the exchange to determine what sequence/position your order is, etc.

cheers,
-e

edit: as far as volume of the last trade, if you have a 1-tick data series, then each "bar" in OnBarUpdate() would contain the price and volume of the last trade. you can also access this info via OnMarketData(), which is an advanced topic.

Reply With Quote
  #8 (permalink)
 traderwerks   is a Vendor
 
Posts: 692 since Jun 2009
Thanks Given: 436
Thanks Received: 465

What you are looking for is EPIQ (Estimated Position In Queue) feature of X_Trader, which ninja trader does not have.

You can write one for Ninja , but it is only an estimate, because you are only estimating the cancels that occur in front of you in the queue in addition to trades.

Have fun

Math. A gateway drug to reality.
Reply With Quote
Thanked by:
  #9 (permalink)
 
TheWizard's Avatar
 TheWizard 
Houston, TX
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus Futures, AMP, CQG
Trading: 6E
Posts: 1,731 since Jun 2009
Thanks Given: 517
Thanks Received: 4,224

I need help with some coding.. It's done for the most part, but I'm trying to do something I don't know how to code.

When the signal is given for a long, I want to enter at the HIGH of the bar prior to the signal bar.
Or (option #2) Enter at the High + 1 tick of the bar prior to the signal bar.

When the signal is given for a short, I want to enter at the LOW of the bar prior to the signal bar.
Or (option #2) Enter at the Low -1 tick of the bar prior to the signal bar.

I don't know how to code that and the Strategy creation wizard isn't much help. Can anyone help? Something like this:

ex: If long condition met:
EnterLong High[1]; (enter long at the high of the previous bar)

or EnterLong High[1]+1 tick; (or enter long at the high + 1 tick, of the previous bar)

ex: If short condition met:
EnterShort Low[1]; (enter short at the low of the previous bar)
EnterShort Low[1] -1 tick: (or enter short at the low -1 tick, of the previous bar)

Thank you for your consideration and time.

I'll be happy to share the strategy, once I get it working!

After all, it's what you learn AFTER you know it all, that counts!
Reply With Quote
  #10 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090



TheWizard View Post
I need help with some coding.. It's done for the most part, but I'm trying to do something I don't know how to code.

When the signal is given for a long, I want to enter at the HIGH of the bar prior to the signal bar.
Or (option #2) Enter at the High + 1 tick of the bar prior to the signal bar.

When the signal is given for a short, I want to enter at the LOW of the bar prior to the signal bar.
Or (option #2) Enter at the Low -1 tick of the bar prior to the signal bar.

I don't know how to code that and the Strategy creation wizard isn't much help. Can anyone help? Something like this:

ex: If long condition met:
EnterLong High[1]; (enter long at the high of the previous bar)

or EnterLong High[1]+1 tick; (or enter long at the high + 1 tick, of the previous bar)

ex: If short condition met:
EnterShort Low[1]; (enter short at the low of the previous bar)
EnterShort Low[1] -1 tick: (or enter short at the low -1 tick, of the previous bar)

Thank you for your consideration and time.

I'll be happy to share the strategy, once I get it working!

common sense says you can only enter after signal bar.

Reply With Quote




Last Updated on August 2, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts