NexusFi: Find Your Edge


Home Menu

 





About sessionlastbar


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 75 since Jan 2023
Thanks Given: 2
Thanks Received: 3

Is there an equivalent to the multi chart function sessionlastbar in tradestation's Easylanguage?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
Kalshi Sets $4.13B All-Time Weekly Record as Polymarket …
Prediction Markets & Event Contracts
Al Arabiya: US-Iran Draft Deal Within Hours Contains Hor …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
BERN ALGOS algo trading journal
8 thanks
  #2 (permalink)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 37 since Mar 2012
Thanks Given: 2
Thanks Received: 22

For Minute Bars and standard sessions this function should work (Be sure to choose a Boolean (True/False) as the Return Type for the Function)


 
Code
{SessionLastBar Function}

{Note - you must specify return type as Boolean}
{Note: NumericSession Type is assumed to be 0 and NumericSession Number is assumed to be 1
corresponding to the SessionEndTime(0,1) input values}

{If you are using sessions where those values need to be changed, then you will have to re-write 
the function with numeric inputs for the session type and session number.}

	If Time = SessionEndTime(0,1) then SessionLastBar = True
Else
	SessionLastBar = False;


Follow me on X Reply With Quote
  #3 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 75 since Jan 2023
Thanks Given: 2
Thanks Received: 3



TraderDoc2 View Post
For Minute Bars and standard sessions this function should work (Be sure to choose a Boolean (True/False) as the Return Type for the Function)


 
Code
{SessionLastBar Function}

{Note - you must specify return type as Boolean}
{Note: NumericSession Type is assumed to be 0 and NumericSession Number is assumed to be 1
corresponding to the SessionEndTime(0,1) input values}

{If you are using sessions where those values need to be changed, then you will have to re-write 
the function with numeric inputs for the session type and session number.}

	If Time = SessionEndTime(0,1) then SessionLastBar = True
Else
	SessionLastBar = False;

Thank you for your response.


Am I correct in my understanding that the session end time corresponds to the session last bar?


Reply With Quote
  #4 (permalink)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 37 since Mar 2012
Thanks Given: 2
Thanks Received: 22

Yes. Click on the last bar of a session. The displayed time stamp for that bar is normally the SessionEndTime. However, note that the time stamp of the first bar of a session is not the SessionStartTime, rather it is the SessionStartTime + the Bar Interval. So to find the time stamp of the first bar you could write this code:

Vars:
FirstBarTime(0);

FirstBarTime = CalcTime(SessionStartTime(0,1),BarInterval);


Follow me on X Reply With Quote
  #5 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 75 since Jan 2023
Thanks Given: 2
Thanks Received: 3


TraderDoc2 View Post
Yes. Click on the last bar of a session. The displayed time stamp for that bar is normally the SessionEndTime. However, note that the time stamp of the first bar of a session is not the SessionStartTime, rather it is the SessionStartTime + the Bar Interval. So to find the time stamp of the first bar you could write this code:

Vars:
FirstBarTime(0);

FirstBarTime = CalcTime(SessionStartTime(0,1),BarInterval);



Thank you for your reply.

This is the result of executing the code below using the sessionlastbar function in multichart, but I would like to get the same result in tradestation as in multichart in tradestation.

However, tradestation does not seem to have the sessionlastbar function, but as an alternative, can I use "CalcTime(SessionStartTime(0,1),BarInterval);" to get the same result? Can I get the same result?


Execution Resulthttps://app.screencast.com/VWu3cofSbT51R

 
Code
variable:Open_(0),High_(0),low_(0),Close_(0),indBar(0),countBar(0),iSShowAllert(false);

if barstatus(1) = 2 then

   begin

   countBar = countBar+1;
            //print(symbol,countBar );
   end;

if sessionlastbar then

   begin

   countBar=0;
            //print( date,time,countBar);
   end;

if Date[1] <> Date[0] then begin
   
   Open_ = open;
   High_ = high;
   low_  = low;
   Close_= close; 
		   
   end;		

if high>High_ then begin
    
   High_  = high;
    
   indBar = Symbol_CurrentBar;
           
   iSShowAllert =true;
      
   end;     
           
if indBar[1] +1 = indBar  or indBar[1] = indBar or  countBar = 2 then

   begin
            
   iSShowAllert = false;

   end

else begin
        
     iSShowAllert = true;

     end;

if iSShowAllert then begin
   
   if Open_<Close_ then

      Plot1(High_,"",Cyan);
      Alert ;
		
      end;
		
if iSShowAllert then begin
		
   if Open_<Close_  and Open_ = low_ or Open_ = low_+0.01  then 
      
      plot1(High_,"",yellow);
      
      end;
      
if iSShowAllert then begin
              
   if Open_>Close_ then

      Plot1(High_,"",red);
                     	
      end
		 
		 
else begin
   
     if date<>date[1]then
   
        NoPlot(1);
        
        end;


Reply With Quote




Last Updated on June 19, 2023


© 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