NexusFi: Find Your Edge


Home Menu

 





Calculate cumulative sum from session start


Discussion in MultiCharts

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




 
Search this Thread

Calculate cumulative sum from session start

  #1 (permalink)
hhomsi8
Stockholm, Sweden
 
Posts: 10 since Feb 2023
Thanks Given: 7
Thanks Received: 0

Hi,

is it possible for someone to help me get the cumulative sum from start of the trading session/or if easier from specified starting time?

i will be using it for stocks (so I won't be having issues with different trading session starts). For instance, I just need to get the logic correct so I can use it in my testing.

for instance, if I want the cumulative sum of upticks from start of the session:

HTML Code:
inputs: sessionStart(1530), sessionEnd(2200),length(9);

var: cumupTicks(0);

if Time >= sessionStart and Time <= sessionEnd then 
    cumupTicks += Upticks  else cumupTicks = 0;


plot1( ccumupTicks , "Cumulative Upticks", Green );
or is it better to do:

HTML Code:
inputs: sessionStart(1530), sessionEnd(2200),length(9);

var: cumupTicks(0);

if Date <> Date[1] then 
    cumupTicks += Upticks  else cumupTicks= 0;


plot1( ccumupTicks , "Cumulative Upticks", Green );
Or How should it be? I appreciate any help.

Thanks in advance

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Quantum physics & Trading dynamics
The Elite Circle
Better Renko Gaps
The Elite Circle
Strategy stop orders partially filled
EasyLanguage Programming
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
68 thanks
Spoo-nalysis ES e-mini futures S&P 500
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
Trading with Intuition
15 thanks
The Trading Pit "Futures VIP" Account Journal
15 thanks
  #2 (permalink)
artisanpro
montreal, qc, canada
 
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18

I am answering in relation to Multicharts Power Language:

will NOT work -------------- cumupTicks += Upticks else cumupTicks = 0;

will work -------------------- cumupTicks = Upticks + cumupTicks[1] else cumupTicks = 0;


Now, in regards to your question of date vs session start, they both should work but which one is more efficient is unknown to me.

I have always wondered if there is a way to catch how fast an indicator executes - something similar to Excel VBA where you can actually measure the execution time.
I would be very happy if someone knows how to do this.

Reply With Quote
  #3 (permalink)
hhomsi8
Stockholm, Sweden
 
Posts: 10 since Feb 2023
Thanks Given: 7
Thanks Received: 0



artisanpro View Post
I am answering in relation to Multicharts Power Language:

will NOT work -------------- cumupTicks += Upticks else cumupTicks = 0;

will work -------------------- cumupTicks = Upticks + cumupTicks[1] else cumupTicks = 0;


Now, in regards to your question of date vs session start, they both should work but which one is more efficient is unknown to me.

I have always wondered if there is a way to catch how fast an indicator executes - something similar to Excel VBA where you can actually measure the execution time.
I would be very happy if someone knows how to do this.

Thanks a lot for taking the time to answer, Appreciate ur help. Just 1 more thing, wouldn't ur code cumupTicks = Upticks + cumupTicks[1] only sum the prev's bar tick instead of accumulating the values from count of 0? or have I misunderstood the logic?

Reply With Quote
  #4 (permalink)
artisanpro
montreal, qc, canada
 
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18

No, this will do the cumulative.

At bar one (1), cumupTicks[1] is zero so
cumupTicks is = Upticks + 0 ;

At bar two (2), cumupTicks[1] is = Upticks[1] so
cumupTicks = Upticks + cumupTicks[1] or
cumupTicks = Upticks + upTicks[1]

At bar three (3), cumupTicks[1] is = Upticks[1] + Upticks[2] so
cumupTicks = Upticks + cumupTicks[1] or
cumupTicks = Upticks + Upticks[1] + Upticks[2]

and so on

Reply With Quote
Thanked by:




Last Updated on June 4, 2023


© 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