nasdorq Posted June 19, 2019 Report Share Posted June 19, 2019 (edited) i created a cumulative $TICK paintbar if anyone is interested. It uses the Compare Symbol indicator, so the underlying chart doesn't have to be the $TICK itself. I have two calls for SessionInfo, which could maybe reduced to one somehow. Thanks to Jerry and Mike for creating the loop functions. public void MainCalculation() { var TT = GetTradingSessionInfo(Timestamp); TradingSessionInfo session = GetTradingSessionInfo(Timestamp); TimeSpan TS = (Timestamp[0] - session.SessionStart); // number of minutes into session int p = (int) TS.TotalMinutes; // convert Timespan to integer if (DateTime.UtcNow<TT.DayStart.AddDays(1)) // only plot current day { SetColor(Color.Black); SetYValue(Sum(p,TICK)); //plots a running total using the Sum loop function } } Edited June 19, 2019 by nasdorq missing line Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted June 19, 2019 Report Share Posted June 19, 2019 You going to share the code? Quote Link to comment Share on other sites More sharing options...
nasdorq Posted June 19, 2019 Author Report Share Posted June 19, 2019 The code didn't post initially. I had to copy to a notepad file and then copy/paste as plain text. Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted June 19, 2019 Report Share Posted June 19, 2019 with single sessioninfo call: public void MainCalculation() { TradingSessionInfo session = GetTradingSessionInfo(Timestamp); TimeSpan TS = (Timestamp[0] - session.SessionStart); // number of minutes into session int p = (int) TS.TotalMinutes; // convert Timespan to integer if (DateTime.UtcNow<session.DayStart.AddDays(1)) // only plot current day { SetColor(Color.Black); SetYValue(Sum(p,TICK)); //plots a running total using the Sum loop function } } NOTE: this code assumes that the paintbar is running on 1 minute bars. Could be optimized, though that would complicate the code a bit. 1 Quote Link to comment Share on other sites More sharing options...
ehjump Posted January 26, 2020 Report Share Posted January 26, 2020 On 6/19/2019 at 3:33 PM, Jerry Medved said: with single sessioninfo call: public void MainCalculation() { TradingSessionInfo session = GetTradingSessionInfo(Timestamp); TimeSpan TS = (Timestamp[0] - session.SessionStart); // number of minutes into session int p = (int) TS.TotalMinutes; // convert Timespan to integer if (DateTime.UtcNow<session.DayStart.AddDays(1)) // only plot current day { SetColor(Color.Black); SetYValue(Sum(p,TICK)); //plots a running total using the Sum loop function } } NOTE: this code assumes that the paintbar is running on 1 minute bars. Could be optimized, though that would complicate the code a bit. How would you do this to show on historical charts, a daily chart to be exact? That is, show paintbar for only the current month. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 26, 2020 Report Share Posted January 26, 2020 to check if the candle belongs to the current month, you do if (DateTime.UtcNow.Month == TimeStamp.Month && DateTime.UtcNow.Year == TimeStamp.Year) 1 Quote Link to comment Share on other sites More sharing options...
ehjump Posted January 26, 2020 Report Share Posted January 26, 2020 Thanks a lot. Just an FYI -- had to change "TimeStamp" to Timestamp with a small "s" Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 27, 2020 Report Share Posted January 27, 2020 LOL - yes. I didn't run it through the editor when I typed it in, sry. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.