NexusFi: Find Your Edge


Home Menu

 





Trouble Programming Simple Indicator


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one buddy858 with 12 posts (3 thanks)
    2. looks_two Fat Tails with 2 posts (5 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 alextrd with 1 posts (0 thanks)
    1. trending_up 5,271 views
    2. thumb_up 9 thanks given
    3. group 5 followers
    1. forum 16 posts
    2. attach_file 10 attachments




 
Search this Thread

Trouble Programming Simple Indicator

  #1 (permalink)
 
buddy858's Avatar
 buddy858 
Mandeville, LA
 
Experience: Intermediate
Platform: Ninja Trader, Tradestation
Trading: CL, GC, ES
Posts: 101 since Dec 2011
Thanks Given: 496
Thanks Received: 154

I just started trying to learn how to program yesterday, but I'm having a really difficult go at it.

I was attempting to divide the volume output by seconds per bar for use with Tick, Range and Renko type charts, but I really have no idea what I'm doing. I've been working on it and watching videos and reading the help menu for hours and hours, but I'm getting pretty stuck now. I have looked at other indicators and taken a few ideas from a few, but it's just not working. Would anyone be willing to help me out with this? I would really appreciate it. My retarded code is attached. I'm sure it's laughable, at best.

Best,

Daniel

VolumePerSecond.cs

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



buddy858 View Post
I just started trying to learn how to program yesterday, but I'm having a really difficult go at it.

I was attempting to divide the volume output by seconds per bar for use with Tick, Range and Renko type charts, but I really have no idea what I'm doing. I've been working on it and watching videos and reading the help menu for hours and hours, but I'm getting pretty stuck now. I have looked at other indicators and taken a few ideas from a few, but it's just not working. Would anyone be willing to help me out with this? I would really appreciate it. My retarded code is attached. I'm sure it's laughable, at best.

Best,

Daniel

Attachment 112938

You have not declared the variable totalseconds, which would be of type double. Also there is a useless DataSeries volpersec, which has not been initialized and not be used so far. Just delete it.

Further your indicator will not display correctly for the first bar of each session and the first bar after a technical break, because your way of calculating the bar duration includes the session breaks and technical breaks.

Otherwise your indicator should work as expected.

Reply With Quote
Thanked by:
  #4 (permalink)
 
buddy858's Avatar
 buddy858 
Mandeville, LA
 
Experience: Intermediate
Platform: Ninja Trader, Tradestation
Trading: CL, GC, ES
Posts: 101 since Dec 2011
Thanks Given: 496
Thanks Received: 154


Fat Tails View Post
You have not declared the variable totalseconds, which would be of type double. Also there is a useless DataSeries volpersec, which has not been initialized and not be used so far. Just delete it.

Further your indicator will not display correctly for the first bar of each session and the first bar after a technical break, because your way of calculating the bar duration includes the session breaks and technical breaks.

Otherwise your indicator should work as expected.

Ok, thank you very much. Going to take a look now and get back to you...

Started this thread Reply With Quote
  #5 (permalink)
 
buddy858's Avatar
 buddy858 
Mandeville, LA
 
Experience: Intermediate
Platform: Ninja Trader, Tradestation
Trading: CL, GC, ES
Posts: 101 since Dec 2011
Thanks Given: 496
Thanks Received: 154


Fat Tails View Post
You have not declared the variable totalseconds, which would be of type double. Also there is a useless DataSeries volpersec, which has not been initialized and not be used so far. Just delete it.

Further your indicator will not display correctly for the first bar of each session and the first bar after a technical break, because your way of calculating the bar duration includes the session breaks and technical breaks.

Otherwise your indicator should work as expected.

I added "private double totalseconds; under variables. Did I at least get that right? Probably not. Please forgive my ignorance.

Re: "your indicator will not display correctly for the first bar of each session..." I deleted the "If current bar < 1 return..." lines under OnBarUpdate. Was that what I should have done to address this problem? I suppose it's obvious I have no idea what I'm doing here, and that's fine. I just have to keep working at it and asking for help if I'm going to learn how to do this.

Also, under properties, is that all I need in that section?

Thank you so very much for your help; I really appreciate it

Started this thread Reply With Quote
  #6 (permalink)
 
buddy858's Avatar
 buddy858 
Mandeville, LA
 
Experience: Intermediate
Platform: Ninja Trader, Tradestation
Trading: CL, GC, ES
Posts: 101 since Dec 2011
Thanks Given: 496
Thanks Received: 154

I also deleted the DataSeries. It compiles, but it yields no values when added to a chart...

Attached Files
Elite Membership required to download: VolPerSec.cs
Started this thread Reply With Quote
  #7 (permalink)
 
buddy858's Avatar
 buddy858 
Mandeville, LA
 
Experience: Intermediate
Platform: Ninja Trader, Tradestation
Trading: CL, GC, ES
Posts: 101 since Dec 2011
Thanks Given: 496
Thanks Received: 154


Fat Tails View Post
You have not declared the variable totalseconds, which would be of type double. Also there is a useless DataSeries volpersec, which has not been initialized and not be used so far. Just delete it.

Further your indicator will not display correctly for the first bar of each session and the first bar after a technical break, because your way of calculating the bar duration includes the session breaks and technical breaks.

Otherwise your indicator should work as expected.

Ok, I found this Make sure you have enough bars in the data series you are accessing - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum so I now realize I need that "If (currentbar < 1) return;" statement...

It's still not working for me though...not sure what the problem is now...

Started this thread Reply With Quote
  #8 (permalink)
 
buddy858's Avatar
 buddy858 
Mandeville, LA
 
Experience: Intermediate
Platform: Ninja Trader, Tradestation
Trading: CL, GC, ES
Posts: 101 since Dec 2011
Thanks Given: 496
Thanks Received: 154


Fat Tails View Post
You have not declared the variable totalseconds, which would be of type double. Also there is a useless DataSeries volpersec, which has not been initialized and not be used so far. Just delete it.

Further your indicator will not display correctly for the first bar of each session and the first bar after a technical break, because your way of calculating the bar duration includes the session breaks and technical breaks.

Otherwise your indicator should work as expected.

Ok, I've got it now. Bertrand at NT support actually helped me get this all worked out over the past hour or so. One step closer now...

Daniel

Attached Files
Elite Membership required to download: VolumePerSecond.cs
Started this thread Reply With Quote
  #9 (permalink)
 
buddy858's Avatar
 buddy858 
Mandeville, LA
 
Experience: Intermediate
Platform: Ninja Trader, Tradestation
Trading: CL, GC, ES
Posts: 101 since Dec 2011
Thanks Given: 496
Thanks Received: 154


Fat Tails View Post
You have not declared the variable totalseconds, which would be of type double. Also there is a useless DataSeries volpersec, which has not been initialized and not be used so far. Just delete it.

Further your indicator will not display correctly for the first bar of each session and the first bar after a technical break, because your way of calculating the bar duration includes the session breaks and technical breaks.

Otherwise your indicator should work as expected.


Just a couple of questions left now: Bertrand used int instead of double. What are your thoughts on that? And how do I make it display correctly for the first bar of each session and for the first bar after a technical break? I don't really understand what I could possibly do here.

best,

Daniel

Started this thread Reply With Quote
  #10 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



buddy858 View Post
Just a couple of questions left now: Bertrand used int instead of double. What are your thoughts on that? And how do I make it display correctly for the first bar of each session and for the first bar after a technical break? I don't really understand what I could possibly do here.

best,

Daniel

int or double:

timer.TotalSeconds returns a double value. There is no need to convert it to int, because you will use it as divisor for Volume[0], which itself contains a double value.

first bar of session:

Check for Bars.FirstBarOfSession with every bar. In case that you have a first bar of the session, you do not calculate timer = Time[0] - Time[1], but timer = Time[0] - sessionBegin. You can find out the sessionBegin via Bars.Session.GetNextBeginEnd(Bars, 0, out sessionBegin, out sessionEnd), where sessionBegin and sessionEnd are DateTime objects.

Reply With Quote
Thanked by:




Last Updated on September 18, 2013


© 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