NexusFi: Find Your Edge


Home Menu

 





Problems Converting NT 6.5 indicators to NT7


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Mindset with 10 posts (1 thanks)
    2. looks_two Fat Tails with 8 posts (10 thanks)
    3. looks_3 Zondor with 7 posts (2 thanks)
    4. looks_4 Big Mike with 5 posts (1 thanks)
      Best Posters
    1. looks_one gregid with 2 thanks per post
    2. looks_two Fat Tails with 1.3 thanks per post
    3. looks_3 eDanny with 0.5 thanks per post
    4. looks_4 Zondor with 0.3 thanks per post
    1. trending_up 26,434 views
    2. thumb_up 26 thanks given
    3. group 16 followers
    1. forum 68 posts
    2. attach_file 16 attachments




 
Search this Thread

Problems Converting NT 6.5 indicators to NT7

  #11 (permalink)
 
eDanny's Avatar
 eDanny 
East Rochester, NY
 
Experience: Intermediate
Platform: NT
Posts: 329 since Jul 2009
Thanks Given: 18
Thanks Received: 425


lolu View Post
It never did.

Can you compile this in NT7Beta without those two parameters ? Please let me know.

Lolu

What I said in the post was they would compile in 6.5 with or without those parameters, not in NT7. Most of my DrawText() code would compile ok in NT7 because I had always used the bool and pixel offset. NT7 had other issues which prevented compiling. Dan

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
15 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
My NQ Trading Journal
11 thanks
  #12 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

Roonius posted some very valuable code here if you want to use Menu Items

Biggest problem I have had is understanding the GetXByBarIdx and GetY methods.
Below is a little sample code that shows the problem - click the line on and off over a bar.
Two errors -
1. sometimes the bar is one bar off - and then magically it will just start working perfectly
2. if you put a second chart in the panel - it goes all wrong.

I have battled with it for about 3 weeks and it's unsupported obviously so if anyone here can show me the path to enlightenment ........

Attached Files
Elite Membership required to download: Mouseline.zip
Reply With Quote
  #13 (permalink)
 FBJS 
Toronto
 
Experience: Advanced
Platform: NinjaTrader
Posts: 109 since Sep 2009
Thanks Given: 30
Thanks Received: 193



Zondor View Post
In NT7, rows must be added to a list before attempting to read from or write into those rows. Otherwise, "index out of range" runtime errors are generated.

Thanks Zondor, this was very useful. It helped me to solve part of the problem with Ed's Level 2 indicator, where I described an issue here:



All I did was add the following code in the Initialize() section:

for (int rowCount = 0; rowCount < 50; rowCount++)
{
askRows.Add(new DOMRow(0,0));
bidRows.Add(new DOMRow(0,0));
}


This pre-populated all the rows for the bid/ask for level 2, and avoided throwing errors.

However, I do have one question if you might have an idea about it:

Even with this fix, it still requires an actual OnMarketDepth() event to occur before real data shows up for the bid/ask row. In other words, the indicator starts out blank, and then as OnMarketDepth() events occur, it populates the level 2. It didn't work this way in 6.5... do you know of any code changes that might be causing this, and/or how to force a complete refresh of level 2 data right on Initialize()?

Thanks!

Reply With Quote
Thanked by:
  #14 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731


FBJS View Post

Even with this fix, it still requires an actual OnMarketDepth() event to occur before real data shows up for the bid/ask row. In other words, the indicator starts out blank, and then as OnMarketDepth() events occur, it populates the level 2. It didn't work this way in 6.5... do you know of any code changes that might be causing this, and/or how to force a complete refresh of level 2 data right on Initialize()?

Thanks!


Nice work with Ed's Level 2, FBJS! I don't know of any way to get around the problem you mentioned above, because the OnMarketDepth events are the only way I know to get the Level 2 data. There is Level 2 historical data in the database, and if we could access it we would be able to get around this problem, as well as give persistence to indicators such as DOM_bands. This is something we might need to ask on the Ninjatrader forums.

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #15 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731


Mindset View Post
Roonius posted some very valuable code here if you want to use Menu Items

Biggest problem I have had is understanding the GetXByBarIdx and GetY methods.
Below is a little sample code that shows the problem - click the line on and off over a bar.
Two errors -
1. sometimes the bar is one bar off - and then magically it will just start working perfectly
2. if you put a second chart in the panel - it goes all wrong.

I have battled with it for about 3 weeks and it's unsupported obviously so if anyone here can show me the path to enlightenment ........

The syntax is a little different in NT7. In the GOMCD indicator there is code for both versions of GetXByBar and for the NT7 version of GetY starting on Line 359. See if this works, thanks as usual, Gomi. Here are the variations:

For NT6.5: x=ChartControl.GetXByBarIdx(index);
yHigh = (bounds.Y + bounds.Height) - Convert.ToInt32((dsHigh.Get(index) - min) * scalingfactor);
For NT7: x=ChartControl.GetXByBarIdx(BarsArray[0],index);
yHigh = ChartControl.GetYByValue(this,dsHigh.Get(index));

Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #16 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

Gomi

Thanks - I had already downloaded your code and saw your different versions.
However I cannot get them to work in my little mouseline code.
The error I think is in how I call the index bar - I used to trade with TS and so easylanguage labels all it's bars already so you don't have to bother with all this computation.
My brain is exploding as the code basically works on a single chart but not when you add another chart to the same panel.

I have used GetXByBarIndex in 6.5 and didn't have any issues there which is why I am so stumped this code doesn't work.

Seems easy and the answer will be when... if... someone provides the answer!!!

Reply With Quote
  #17 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291

Here is how I see it.

This is straight from the regression channel indicator provided by NT - so that must be ok
 
Code
private int GetXPos(int barsBack)
{
int idx = (Bars.Count - 1) + Math.Max(0, Bars.Count - 1 - ChartControl.LastBarPainted) - barsBack;
return ChartControl.GetXByBarIdx(BarsArray[0], idx) + 1 - ChartControl.ChartStyle.GetBarPaintWidth(Bars.BarsData.ChartStyle.BarWidthUI) / 2;
}

private int GetYPos(double price, Rectangle bounds, double min, double max)
{	
return ChartControl.GetYByValue(this, price);
}
So the only thing to worry about is the barsback business which I do via this

barsback = (Bars.Count -1) - ((int) (e.X/Chartcontrol.BarSpace);

Which does work on a single chart but doesn't on multiple charts - so where is the error?

Reply With Quote
  #18 (permalink)
 MartinS 
Aberdeen + UK
 
Experience: Intermediate
Platform: NinjaTrader, TradeStation
Trading: NQ
Posts: 6 since Dec 2009
Thanks Given: 0
Thanks Received: 3


Mindset View Post
So the only thing to worry about is the barsback business which I do via this

barsback = (Bars.Count -1) - ((int) (e.X/Chartcontrol.BarSpace);

Which does work on a single chart but doesn't on multiple charts - so where is the error?

On a multi series chart, I don't think the bars are spaced according to ChartControl.BarSpace - they can be spaced unevenly when using non time based bars, and can overlap. The x-axis is then always time based, so maybe caculating the time difference per mouse increment is the way to go? But then what to do when there is a session break? I'll need to think some more about that, if someone else doesn't work it out first.

Reply With Quote
  #19 (permalink)
 MartinS 
Aberdeen + UK
 
Experience: Intermediate
Platform: NinjaTrader, TradeStation
Trading: NQ
Posts: 6 since Dec 2009
Thanks Given: 0
Thanks Received: 3

Mindset,
This works in my testing so far with tick charts. I have not used your code as I already had my own that worked on equidistant charts (one dataseries). Hold Ctrl key and click mouse on bar and it will draw vertical lines and show the bar time. Mouse click with no Ctrl key will clear it.

On a multiseries chart it calculates the time scale on the x-axis and uses that to find the bar you clicked on, or the bar closest to where you clicked.
However, when there is a session break on the chart it will not work so well as the time scale is then wrong. It should be possible to allow for that time gap, but I'm not sure yet if its worth the extra work.

Attached Files
Elite Membership required to download: aaTestGetBar.zip
Reply With Quote
Thanked by:
  #20 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291


I will try your code out MartinS once I have my machine up and running again.
However it doesn't 'feel' right that Ninja would use 1 function GetXByBarIdx on a single chart yet require you to change your code for multiple charts??
Also the GetXByBarIdx has a parameter of which BarArray you are referencing so it shouldn't need time?? I do wish support would support ChartControl.
I think they have a GetXByTime function line as well FYI but it's not something I have looked at yet.

Reply With Quote




Last Updated on October 24, 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