NexusFi: Find Your Edge


Home Menu

 





x sessions ago


Discussion in NinjaTrader

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




 
Search this Thread

x sessions ago

  #1 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110

Hi guys,

Can you direct me on how to write this :

if (5 sessions ago)

Thank you

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Request for MACD with option to use different MAs for fa …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
55 thanks
NexusFi site changelog and issues/problem reporting
48 thanks
What percentage per day is possible? [Poll]
31 thanks
GFIs1 1 DAX trade per day journal
29 thanks

  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


What do you need this for? Some session templates have several sessions per day, so it is not quite clear, where this is leading to. Est-ce que tu peux préciser un peu ta demande?


SARdynamite View Post
Hi guys,

Can you direct me on how to write this :

if (5 sessions ago)

Thank you


Reply With Quote
  #4 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110

French friendly !
Sadly, ich spreche nicht deutsche. ;o)

Actually I wanted to compare the pre-market (market profile) total volume to the average pre-market volume of the past week (last 5 days).
I could also compare the ADR to the 5 latest ADR or the Initial Balance range.

Anyway nevermind me cause I just realised it could be done using DayOfWeek only.

Thanks nonetheless.

Started this thread Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

This is not so easy. I think you have two options to do that

(1) You define a session template with two different sessions, one for pre-market or night session, the other one for the day session. OnBarUpdate would then run through all the bars, and when the defined pre-market session starts, add up volume and at session-end affect this to a variable.

(2) If you do not want to use two session templates, you would need two variables of type TimeSpan to define begin and end of your pre-market session, relative to the session-end of the main session.

You may have a look at the pivot indicators. These also run through highs and lows of a session and then store a value, albeit they only do this for a single day and not for five.


SARdynamite View Post
French friendly !
Sadly, ich spreche nicht deutsche. ;o)

Actually I wanted to compare the pre-market (market profile) total volume to the average pre-market volume of the past week (last 5 days).
I could also compare the ADR to the 5 latest ADR or the Initial Balance range.

Anyway nevermind me cause I just realised it could be done using DayOfWeek only.

Thanks nonetheless.


Reply With Quote
  #6 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110

Hello mate,

I coded it just right now.
I did not check it yet but I'm pretty sure it should be valid.

I'm posting it for others because it might be reworked for other purposes

This one is the one week rolling average of the pre-market volume of European futures (8h-9h)

Get volIBavgWeek and declare all DataSeries


 
Code
if (DayOfWeek.Monday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBavgWeek.Set(volIBmonday[1]+volIBtuesday[0]+volIBwednesday[0]+volIBthursday[0]+volIBfriday[0]);                
                    volIBmonday[1].Set(Volume[0]);
                }
                else 
                {
                    volIBavgWeek.Set(volIBavgWeek[1]);
                    if (ToTime(Time[0])<=90000)    volIBmonday.Set(volIB[1]+Volume[0]);
                    else volIBmonday.Set(volIBmonday[1]);
                }
                volIBtuesday.Set(volIBtuesday[1]);
                volIBwednesday.Set(volIBwednesday[1]);
                volIBthursday.Set(volIBthursday[1]);
                volIBfriday.Set(volIBfriday[1]);
            }
            else if (DayOfWeek.Tuesday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBavgWeek.Set(volIBmonday[0]+volIBtuesday[1]+volIBwednesday[0]+volIBthursday[0]+volIBfriday[0]);        
                    volIBtuesday[1].Set(Volume[0]);
                }
                else 
                {
                    volIBavgWeek.Set(volIBavgWeek[1]);
                    if (ToTime(Time[0])<=90000)    volIBtuesday.Set(volIB[1]+Volume[0]);
                    else volIBtuesday.Set(volIBtuesday[1]);
                }
                volIBmonday.Set(volIBmonday[1]);
                volIBwednesday.Set(volIBwednesday[1]);
                volIBthursday.Set(volIBthursday[1]);
                volIBfriday.Set(volIBfriday[1]);
            }
            else if (DayOfWeek.Wednesday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBavgWeek.Set(volIBmonday[0]+volIBtuesday[0]+volIBwednesday[1]+volIBthursday[0]+volIBfriday[0]);
                    volIBwednesday[1].Set(Volume[0]);
                }
                else 
                {
                    volIBavgWeek.Set(volIBavgWeek[1]);
                    if (ToTime(Time[0])<=90000)    volIBwednesday.Set(volIB[1]+Volume[0]);
                    else volIBwednesday.Set(volIBwednesday[1]);
                }
                volIBmonday.Set(volIBmonday[1]);
                volIBtuesday.Set(volIBtuesday[1]);
                volIBthursday.Set(volIBthursday[1]);
                volIBfriday.Set(volIBfriday[1]);
            }
            else if (DayOfWeek.Thursday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBavgWeek.Set(volIBmonday[0]+volIBtuesday[0]+volIBwednesday[0]+volIBthursday[1]+volIBfriday[0]);            
                    volIBmonday[1].Set(Volume[0]);
                }
                else 
                {
                    volIBavgWeek.Set(volIBavgWeek[1]);
                    if (ToTime(Time[0])<=90000)    volIBthursday.Set(volIB[1]+Volume[0]);
                    else volIBthursday.Set(volIBthursday[1]);
                }
                volIBmonday.Set(volIBmonday[1]);
                volIBtuesday.Set(volIBtuesday[1]);
                volIBwednesday.Set(volIBwednesday[1]);
                volIBfriday.Set(volIBfriday[1]);
            }
            else if (DayOfWeek.Friday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBavgWeek.Set(volIBmonday[0]+volIBtuesday[0]+volIBwednesday[0]+volIBthursday[0]+volIBfriday[1]);
                    volIBfriday[1].Set(Volume[0]);
                }
                else 
                {
                    volIBavgWeek.Set(volIBavgWeek[1]);
                    if (ToTime(Time[0])<=90000)    volIBfriday.Set(volIB[1]+Volume[0]);
                    else volIBfriday.Set(volIBfriday[1]);
                }
                volIBmonday.Set(volIBmonday[1]);
                volIBtuesday.Set(volIBtuesday[1]);
                volIBwednesday.Set(volIBwednesday[1]);
                volIBthursday.Set(volIBthursday[1]);
            }

Started this thread Reply With Quote
The following user says Thank You to SARdynamite for this post:
  #7 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110

sorry, the last code had some fills missing


here is an update with IB range and volume rolling weekly averages

the code is more dense and should work on ticks/volume/range charts too (precision = almost accurate, depending if the last candle is close to 9 o'clock) as long as the opening hour of the globex session is correctly set in the Session Manager

this is just a concept and it could be use for anything. i.e. rolling ADR, rolling whatever

this could be adaptated for US markets of course

get :
- volIBavgWeek
- rangeIBavgWeek


 
Code
            if (Bars.FirstBarOfSession)
            {
                volIB.Set(Volume[0]);
                IBhigh.Set(High[0]);
                IBlow.Ser(Low[0]);
                volIBavgWeek.Set(volIBmonday[0]+volIBtuesday[0]+volIBwednesday[0]+volIBthursday[0]+volIBfriday[0]);        
                rangeIBavgWeek.Set((rangeIBmonday[0]+rangeIBtuesday[0]+rangeIBwednesday[0]+rangeIBthursday[0]+rangeIBfriday[0])/5);        
            }
            else 
            {
                if (ToTime(Time[0])<=90000)
                {
                    volIB.Set(volIB[1]+Volume[0]);
                    IBhigh.Set(Math.Max(IBhigh,High[0]));
                    IBlow.Set(Math.Min(IBlow,Low[0]));
                }
                else 
                {
                    volIB.Set(volIB[1]);
                    IBhigh.Set(IBhigh[1]);
                    IBlow.Set(IBlow[1]);
                }
                volIBavgWeek.Set(volIBavgWeek[1]);
                rangeIBavgWeek.Set(rangeIBavgWeek[1]);
            }
            if (DayOfWeek.Monday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIB[1]);            
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIB[1]);        
                }
                else 
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);    
                }
            }
            else if (DayOfWeek.Tuesday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBmonday.Set(volIB[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);            
                    rangeIBmonday.Set(rangeIB[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);        
                }
                else 
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);    
                }
            }
            else if (DayOfWeek.Wednesday)
            {
                    if (Bars.FirstBarOfSession)
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIB[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);            
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIB[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);        
                }
                else 
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);    
                }
            }
            else if (DayOfWeek.Thursday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIB[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);            
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIB[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);        
                }
                else 
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);    
                }
            }
            else if (DayOfWeek.Friday)
            {
                if (Bars.FirstBarOfSession)
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIB[1]);
                    volIBfriday.Set(volIBfriday[1]);            
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIB[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);        
                }
                else 
                {
                    volIBmonday.Set(volIBmonday[1]);
                    volIBtuesday.Set(volIBtuesday[1]);
                    volIBwednesday.Set(volIBwednesday[1]);
                    volIBthursday.Set(volIBthursday[1]);
                    volIBfriday.Set(volIBfriday[1]);
                    rangeIBmonday.Set(rangeIBmonday[1]);
                    rangeIBtuesday.Set(rangeIBtuesday[1]);
                    rangeIBwednesday.Set(rangeIBwednesday[1]);
                    rangeIBthursday.Set(rangeIBthursday[1]);
                    rangeIBfriday.Set(rangeIBfriday[1]);    
                }
            }

Started this thread Reply With Quote
The following user says Thank You to SARdynamite for this post:
  #8 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110

the problem with this simple code is that if someday the market unusually close for whatever reason, il will make it set false values !!

Started this thread Reply With Quote
  #9 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

Also did you take into account that Monday's session starts on Sunday evening?

Let me know one thing: What do you need pre-market volume for. Or what would you conclude, if pre-market volume was unusually high? Would you expect a trending day?


SARdynamite View Post
the problem with this simple code is that if someday the market unusually close for whatever reason, il will make it set false values !!


Reply With Quote
  #10 (permalink)
 SARdynamite 
Belgium
 
Experience: Advanced
Platform: SaxoTrader
Broker: SaxoBank
Trading: ESTX
Posts: 289 since Dec 2009
Thanks Given: 243
Thanks Received: 110


It could be a hint for a trading day.

Monday's session beginning sunday's evening ? Do you talk about forex ?

I coded it initially for european indices longing from 8h to 22h GMT+1 time from monday to friday.

Started this thread Reply With Quote





Last Updated on July 13, 2010


© 2024 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 - Privacy Policy - Downloads - Top
no new posts