NexusFi: Find Your Edge


Home Menu

 





ASCIL Assistance - Date/Time


Discussion in Sierra Chart

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




 
Search this Thread
  #1 (permalink)
 Slapshot 
Birmingham UK
 
Experience: Intermediate
Platform: Sierrachart
Trading: ES, Forex, Currency Futures, Oil, Natural Gas
Frequency: Daily
Duration: Hours
Posts: 10 since Mar 2013
Thanks Given: 5
Thanks Received: 6

The zigzag study (code is in Studies7.cpp) has the option to display the length of time a line is drawn before a reversal occurs.

The time is always formatted as hh.mm.ss using the code below. I'd like to display only the amount of minutes the wave has taken. This is simple enough by changing the GetLength parameters. However, I primarily use tick charts and the time for a reversal can spread over several hours, what the function doesn't do is convert the total time into purely minutes. As an example, if the time taken was 1h 55 mins it would display as 01:55:00, what I want it to display is 115.

I hoping someone might be able to help recoding this as I'm struggling to understand what to change and where. Thanks in advance.




if (ShowZigZagDuration.GetYesNo())
{
if (BarLabelText.GetLength() != 0)
{
if (UseMultiLineLabels.GetYesNo())
BarLabelText += "\n";
else
BarLabelText += " ";
}

double ZigZagTimeSpan = 0;
if (sc.ChartDataType == INTRADAY_DATA)
{
if (ZigZagIndex < sc.ArraySize - 1)
ZigZagTimeSpan = (sc.BaseDateTimeIn[ZigZagIndex + 1] - sc.BaseDateTimeIn[BackRefIndex + 1]).GetAsDouble();
else
ZigZagTimeSpan = (sc.LatestDateTimeForLastBar - sc.BaseDateTimeIn[BackRefIndex + 1]).GetAsDouble();
}
else
{
ZigZagTimeSpan = (sc.BaseDateTimeIn[ZigZagIndex] - sc.BaseDateTimeIn[BackRefIndex + 1]).GetAsDouble();
}

SCString TimeDurationStr;
if (sc.ChartDataType == INTRADAY_DATA)
{
TimeDurationStr = sc.FormatGraphValue(ZigZagTimeSpan, 20);

if (TimeDurationStr.GetLength() >= 3 && TimeDurationStr[0] == '0' && TimeDurationStr[1] == '0' && TimeDurationStr[2] == ':')
TimeDurationStr = TimeDurationStr.GetSubString(TimeDurationStr.GetLength() - 3, 3);
}

SCString LengthStr;

LengthStr += TimeDurationStr;

BarLabelText += LengthStr;


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
MegaETH Proves the Crowd Right: Prediction Markets Calle …
Prediction Markets & Event Contracts
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
ondafringe
Albuquerque, NM, USA
 
Posts: 124 since Jul 2012
Thanks Given: 87
Thanks Received: 118

I'm not an ACSIL guru by any means, but in the past, I have separated the hours and minutes using this code:

int hour = sc.BaseDateTimeIn[sc.Index].GetHour();
int minute = sc.BaseDateTimeIn[sc.Index].GetMinute();

Then I could do something like this:

int totMinutes = (hour * 60) + minute;

Then I could convert totMinutes to a string.

Maybe something similar would work for you.


Reply With Quote
Thanked by:
  #3 (permalink)
 Slapshot 
Birmingham UK
 
Experience: Intermediate
Platform: Sierrachart
Trading: ES, Forex, Currency Futures, Oil, Natural Gas
Frequency: Daily
Duration: Hours
Posts: 10 since Mar 2013
Thanks Given: 5
Thanks Received: 6


Thanks ondafringe

Finally managed to work this out, through lots of trial and error. Got it to work using the GetTimeInSeconds function. Code changes in Bold:

int ZigZagTimeSpan = 0;
if (sc.ChartDataType == INTRADAY_DATA)
{
if (ZigZagIndex < sc.ArraySize - 1)
ZigZagTimeSpan = ((sc.BaseDateTimeIn[ZigZagIndex + 1] - sc.BaseDateTimeIn[BackRefIndex + 1]).GetTimeInSeconds());
else
ZigZagTimeSpan = ((sc.LatestDateTimeForLastBar - sc.BaseDateTimeIn[BackRefIndex + 1]).GetTimeInSeconds());
}
else
{
ZigZagTimeSpan = ((sc.BaseDateTimeIn[ZigZagIndex] - sc.BaseDateTimeIn[BackRefIndex + 1]).GetTimeInSeconds());
}


SCString TimeDurationStr;

TimeDurationStr = SCString().Format("%i", int(ZigZagTimeSpan) /60);


Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
ondafringe
Albuquerque, NM, USA
 
Posts: 124 since Jul 2012
Thanks Given: 87
Thanks Received: 118

Good... Nothing more satisfying than solving a programming problem.

Well... okay... that's a bit of a stretch. lol


Reply With Quote




Last Updated on October 6, 2020


© 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