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?
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
Iran Talks Final Stages -- Two VLCCs Exit Hormuz, Record …
Traders Hideout
US Prop Firms Race Inside the CFTC Perimeter -- Tradeify …
Funded Trading Evaluation Firms
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
Iran Airspace Contract Surges to 33.5% as Project Freedo …
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