NexusFi: Find Your Edge


Home Menu

 





Need help for a newbie to NT7 Programming


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one yeskannan with 3 posts (0 thanks)
    2. looks_two ABCTG with 1 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 rleplae with 1 posts (1 thanks)
    1. trending_up 941 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Need help for a newbie to NT7 Programming

  #1 (permalink)
 yeskannan 
memphis, TN usa
 
Experience: Beginner
Platform: Ninja Trader
Trading: ES
Posts: 18 since Feb 2017
Thanks Given: 5
Thanks Received: 1

I have been trying to write the time difference between the current bar and the previous 2 bars to a streamfile using streamfilewriter. I cant use Time[0] - Time [2] because I gety an error that I cant use - for Time
I cant use Time[0].subtract(Time[2]) since this gives me 0 all the time. I have looked here but could not find any thing regarding the time difference between bars.

Someone Please help.

Thanks in advance

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


You could try and use Time[0].Ticks - Time[2].Ticks
Then you have the different in ticks
There are 10.000 ticks in a millisecond or 10 million ticks in a second

hope this helps you

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 yeskannan 
memphis, TN usa
 
Experience: Beginner
Platform: Ninja Trader
Trading: ES
Posts: 18 since Feb 2017
Thanks Given: 5
Thanks Received: 1

Thanks for the reply. When I tried the code to write this to an indicator or stream file writer I get the following error :

"Error on caling 'OnBarUpdate' method for Indicator 'TickTime' on bar 0: Bar Index needs to be greater/equal 0"

I am not sure how to proceed!

Started this thread Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

yeskannan,

this error will come up when you try to access a bar that is not yet present - for example trying to look back two bars on the first bar of the chart. You can prevent this by checking you have enough bars.
Depending on how far back (in this case two bars from the current bar), adding the following code at the top of OnBarUpdate should prevent the error.
 
Code
if (CurrentBar <= 2)
{
   return;
}
You can find additional information here.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
 yeskannan 
memphis, TN usa
 
Experience: Beginner
Platform: Ninja Trader
Trading: ES
Posts: 18 since Feb 2017
Thanks Given: 5
Thanks Received: 1

Thanks a lot ABCTG.

It works. Regards

Started this thread Reply With Quote




Last Updated on May 3, 2018


© 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