NexusFi: Find Your Edge


Home Menu

 





reference last bar (of week)


Discussion in NinjaTrader

Updated
    1. trending_up 1,685 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?
US Prop Firms Race Inside the CFTC Perimeter -- Tradeify …
Funded Trading Evaluation Firms
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
Coinbase Launches Regulated Crypto Futures Across 26 Eur …
Cryptocurrency
BofA Projects $1.1 Trillion in Sports Event Contracts -- …
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
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 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