NexusFi: Find Your Edge


Home Menu

 





SessionLastBar & Strategy Engine Calculation


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 4 posts (1 thanks)
    2. looks_two juveman11 with 3 posts (0 thanks)
    3. looks_3 andby with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 3,592 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 9 posts
    2. attach_file 1 attachments




 
Search this Thread

SessionLastBar & Strategy Engine Calculation

  #1 (permalink)
 
juveman11's Avatar
 juveman11 
Montreal, QC, Canada
 
Experience: Beginner
Platform: MultiCharts
Trading: Crude CL
Posts: 17 since Jun 2016
Thanks Given: 6
Thanks Received: 6

Hi guys, I have finished reading the EL essentials PDF and I'm trying to understand how the machine calculates a strategy. The PDF mentions that by default, the strategy is calculated once at the CLOSE of the bar.

Here's a simple code on 60 min GBP/USD. I understand what's going on but trying to figure out how the machine processed it.

input: mycounter(0);
vars: mycount(0) ;

if sessionlastbar[1] then mycount = 0;
mycount= mycount +1;

if mycounter = mycount then buy next bar at market;
if marketposition = 1 then sell next bar at market;


When mycounter=1 this code buys at the open of the first bar of the session and sells at the open of the bar after it as shown in the attached screenshot.

At the close of the last bar in the session (the 16:59 bar) ---> sessionlastbar[1] is FALSE so how is it buying at the open of the 18:00 bar? It only becomes true once the 18:00 bar closes.

Please excuse my newbie-ness

Attached Thumbnails
Click image for larger version

Name:	example.png
Views:	215
Size:	26.7 KB
ID:	228027  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


juveman11,

I would suggest to add print statements to your code, so you know what's going on internally.

Something like this should show you what your code sees:

 
Code
Print( DateTimeToString( DateTime ), "; sessionlastbar = ", sessionlastbar, "; sessionlastbar[1] = ", sessionlastbar[1], "; mycounter = ", mycounter, "; mycount = ", mycount ) ;
Based on that you should gain more insights. I'd also suggest checking your session template, just to make sure that there aren't sessions ending at 1600.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
 
juveman11's Avatar
 juveman11 
Montreal, QC, Canada
 
Experience: Beginner
Platform: MultiCharts
Trading: Crude CL
Posts: 17 since Jun 2016
Thanks Given: 6
Thanks Received: 6

ABCTG,

The session ends at the 16:59 bar, it even shows a dotted vertical line on my chart and I checked by plotting the session end time.

Using the print function, it is telling me that BOTH sessionlastbar and sessionlastbar[1] are true at the 16:59 bar every single time....strange

Started this thread Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

juveman11,

not all reserved words can be back referenced (meaning give you the values they had on previous bars - they could simply return the current bar's value even when you check for [1]), therefore it's usually a good practice to store the reserved word in a variable and reference the variable in your code.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
 
juveman11's Avatar
 juveman11 
Montreal, QC, Canada
 
Experience: Beginner
Platform: MultiCharts
Trading: Crude CL
Posts: 17 since Jun 2016
Thanks Given: 6
Thanks Received: 6


ABCTG View Post
juveman11,

not all reserved words can be back referenced (meaning give you the values they had on previous bars - they could simply return the current bar's value even when you check for [1]), therefore it's usually a good practice to store the reserved word in a variable and reference the variable in your code.

Regards,

ABCTG

Just tried it and you're right! Thanks!

Started this thread Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

juveman11,

great, thanks for letting me know.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #8 (permalink)
 
andby's Avatar
 andby 
Norwich, UK
 
Experience: Intermediate
Platform: Multiple:research&executi
Broker: Started with Stage5/OEC ... multiple
Trading: Anything found profitable goes ...
Posts: 168 since Jul 2012
Thanks Given: 88
Thanks Received: 88


ABCTG View Post
juveman11,

not all reserved words can be back referenced (meaning give you the values they had on previous bars - they could simply return the current bar's value even when you check for [1]), therefore it's usually a good practice to store the reserved word in a variable and reference the variable in your code.

Regards,

ABCTG

What's the definition of this function (sessionlastbar) - I don't see it available in Tradestation.

thx

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

andby,

it's a reserved word that is exclusive to Multicharts.

Regards,

ABCTG


andby View Post
What's the definition of this function (sessionlastbar) - I don't see it available in Tradestation.

thx


Follow me on Twitter Reply With Quote
  #10 (permalink)
 
andby's Avatar
 andby 
Norwich, UK
 
Experience: Intermediate
Platform: Multiple:research&executi
Broker: Started with Stage5/OEC ... multiple
Trading: Anything found profitable goes ...
Posts: 168 since Jul 2012
Thanks Given: 88
Thanks Received: 88



ABCTG View Post
andby,

it's a reserved word that is exclusive to Multicharts.

Regards,

ABCTG

Alright, so no custom equivalent function written in EL that could be imported?

Understood ...

Reply With Quote




Last Updated on June 1, 2018


© 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