Topics
Replies
Spotware
11 Nov 2013, 15:22
We've implemented new property in both Robot and Indicator classes: TimeZone. Instead of getting timezone from attribute you can use it;
protected override void OnStart() { Print("RobotTimeZone Setting: {0}", TimeZone); Print("RobotTimeZone Name: {0}", TimeZone.DisplayName); Print("Offset: {0}", TimeZone.BaseUtcOffset); Print("DST: {0}", TimeZone.SupportsDaylightSavingTime); }
Moreover, in nested indicators that inherit timezone from robot TimeZone property returns actual inherited timezone.
Please check new release of Spotware cAlgo (1.12).
@Spotware
Spotware
05 Nov 2013, 17:04
If this is correct:
- Call the method DrawText once, when the targetlevel1 is set to true
- Set the targetlevel1 to true if it is false and equity >= Target1
- Do not reset targetlevel1 back to false if the equity falls below the Target1.
Then the code should be:
if (!targetlevel1 && Account.Equity >= Target1) { targetlevel1 = true; ChartObjects.DrawText("objectName", " Level reached: {0}" + levelreached, StaticPosition.TopLeft, Colors.Red); }
@Spotware
Spotware
04 Nov 2013, 17:13
RE:
bp2012 said:
Please see the code below. It seems that Notifications.PlaySound does not work if called within the initialize method. However uncommenting the code in the Calculate method results in a sound every tick.
A recurring pattern in some of my indicators is to paint during the initialize phase and then repaint every x minutes or bars. If alert criteria is met during that first paint inside the initialize method, the notification sound does not play.
In Indicators it is only possible to call this method from the Calculate method.
@Spotware
Spotware
04 Nov 2013, 12:23
The property Count of any series is the total number of elements contained in it. Since series are zero based (the first index is zero), the last element index is Count - 1.
For example, series.High.Count - 1 is the last (current) index of the series. So, you do not need the GetIndexByDate method to get the last index of any series. Dido for the second to last index, that will be series.High.Count - 2.
To find the first bar of the previous day index you can use code similar to this:
private int GetFirstIndexOfPrevousDay(MarketSeries series) { var previousDay = Server.Time.AddDays(-1).Date; for (int i = 0; i < series.High.Count - 1; i++) if ( series.OpenTime[i].Date == previousDay) return i; return -1; }
Similarly you can code the last bar of the previous day:
private int GetFirstPrevousDayIndex(MarketSeries series) { var previousDay = Server.Time.AddDays(-1).Date; for (int i = series.High.Count - 1; i > 0; i--) if ( series.OpenTime[i].Date == previousDay) return i; return -1; }
Question 2
The method returns -1 if the series does not contain the OpenTime parameter.
@Spotware
Spotware
11 Nov 2013, 15:23
We've implemented new property in both Robot and Indicator classes: TimeZone. Instead of getting timezone from attribute you can use it;
Moreover, in nested indicators that inherit timezone from robot TimeZone property returns actual inherited timezone.
Please check new release of Spotware cAlgo (1.12).
@Spotware