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 Quick Summary with 1 posts (0 thanks)
    3. looks_3 rleplae with 1 posts (1 thanks)
    4. looks_4 ABCTG with 1 posts (1 thanks)
    1. trending_up 1,460 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




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

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?
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Kalshi Sets $4.13B All-Time Weekly Record as Polymarket …
Prediction Markets & Event Contracts
Victory Day Delivers: Russia-Ukraine Ceasefire Market Cl …
Prediction Markets & Event Contracts
The Confluence Meter: A Multi-Layered Signal Framework B …
The Elite Circle
Orban Crashes to 21pct on Record Turnout -- McIlroy Drop …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #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: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,860


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 X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 yeskannan 
memphis, TN usa
 
Experience: Beginner
Platform: Ninja Trader
Trading: ES
Posts: 28 since Feb 2017
Thanks Given: 8
Thanks Received: 5

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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

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 X Reply With Quote
Thanked by:
  #6 (permalink)
 yeskannan 
memphis, TN usa
 
Experience: Beginner
Platform: Ninja Trader
Trading: ES
Posts: 28 since Feb 2017
Thanks Given: 8
Thanks Received: 5

Thanks a lot ABCTG.

It works. Regards


Started this thread Reply With Quote




Last Updated on May 3, 2018


© 2026 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 - Downloads - Top
no new posts