NexusFi: Find Your Edge


Home Menu

 





reference last bar (of week)


Discussion in NinjaTrader

Updated
    1. trending_up 1,756 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 yeshe 
San Fransisco Ca
 
Experience: Intermediate
Platform: Ninjatrader
Broker: IB
Trading: forex
Posts: 18 since Jan 2014
Thanks Given: 5
Thanks Received: 1

Hello dear forum,

Can you help me with the following?

I want to have an indicator that refers to the last bar of the week (in historical data) for all open charts.

so for a minute chart it is the last minute bar of the week
for 1 hour chart is the last hour of the week
1 day chart it is friday
etc.

how to program this in ninjatrader
for example

if (Last bar of the week = true)
{
Weekhigh.Set(Highs[1][1]);
Weeklow.Set(Lows[1][1]);
}

many tx in advance

yeshe


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
US Prop Firms Race Inside the CFTC Perimeter -- Tradeify …
Funded Trading Evaluation Firms
Post-Summit Market Verdict: ES -1%, NQ -1.5%, 10-Year Yi …
Traders Hideout
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
Posts: 12 since Jun 2014
Thanks Given: 9
Thanks Received: 12


The question is always whether the last bar of the week was also the last trading day in that week. Theoretically, if you account for public holidays, etc, you would need to know in advance when the market closes.

The simple approach is on the next bar into the new week to notice that you are in a new week (which for your requirement) will work. Something like this:

 
Code
int dayOfWeek = 0;

void OnBarUpdate()
{
    if (Time[0].DayOfWeek < dayOfWeek)
    {
        // it seems that week has started new again, do your calculations for last week
    }
    dayOfWeek = Time[0].DayOfWeek;
    ....
}


Reply With Quote




Last Updated on October 21, 2014


© 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