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,569 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?
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
$12M Ceasefire Contract Goes Disputed as Bandar Abbas St …
Prediction Markets & Event Contracts
April Jobs Beat Flips Fed Hike Odds Past 52% for First T …
Traders Hideout
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
The 50/50 Paradox: Peace and Invasion Each at 20% -- Ira …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
3 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,855


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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

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