NexusFi: Find Your Edge


Home Menu

 





ASCIL Assistance - Date/Time


Discussion in Sierra Chart

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




 
Search this Thread

ASCIL Assistance - Date/Time

  #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?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
ondafringe
Albuquerque, NM, USA
 
Posts: 124 since Jul 2012
Thanks Given: 87
Thanks Received: 117

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: 117

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


© 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