Topics
Replies
lec0456
27 Feb 2019, 19:02
Hi I need a little more support on this. Its a bug. I changed my indicators back to chart.drawtext so that it would not cause a crash in my cbots. If IndicatorArea is supposed to work, then it needs to be debugged. It happens with any indicator that uses IndicatorArea.DrawText, not just one. You can reproduce this error by placing the DrawText OnCalculate and referencing the indicator in any cBot.
@lec0456
lec0456
27 Feb 2019, 10:19
RE:
fxwisdom1@gmail.com said:
I wanted to make an indi that only available to particular TF i.e. H1.
If the indi changes to higher/lower TF, it will not be run...
How can it identify which TF it is on now?
Thank you!
its just TimeFrame you can do something like this.and just calculate on a specific time frame only
switch (Convert.ToString(TimeFrame))
{
case "Minute":
PeriodDivisor = 1;
break;
case "Minute5":
PeriodDivisor = 5;
break;
case "Minute10":
PeriodDivisor = 10;
break;
case "Minute15":
PeriodDivisor = 15;
break;
case "Minute30":
PeriodDivisor = 30;
break;
case "Hour":
PeriodDivisor = 60;
break;
default:
PeriodDivisor = 120;
break;
}
@lec0456
lec0456
27 Feb 2019, 09:50
Ok so after further testing.
If I use chart.DrawText. It does not display the text on the indicator histogram.
If I use ChartArea.DrawText, I get the following error:
Error CS0120: An object reference is required for the non-static field, method, or property 'cAlgo.API.ChartArea.DrawText(string, string, int, double, cAlgo.API.Color)'
If I use IndicatorArea.DrawText, It displays on the indicator histogram BUT! I get an error when running the cBot:
Object reference not set to an instance of an object.
SO NONE OF THEM WORK PROPERLY!!!
@lec0456
lec0456
27 Feb 2019, 01:32
RE:
lec0456 said:
I recently went through the process of upgrading my code for the new API.
I had to change all my ChartObject.DrawText references to Chart.DrawText.
Except I noticed that with my indicators if it is not an overlay, chart.Drawtext does not work.
I had to change it to IndicatorArea.Drawtext. To me is the Indicator is an overlay then the "indicator area" is the chart bu that is not how it works.
So now, I see 3 new objects in the API to implement the DrawText method. Chart, ChartArea, and IndicatorArea.
Could you explain exactly what the 3 objects are for, the differences between them and how they should be used?
correction: To me [if] the Indicator is an overlay, then the "indicator area" is the chart bu that is not how it works.
@lec0456
lec0456
23 Feb 2019, 03:18
I am not sure I understnd you but, it sounds like you just want to create a slope indicator, that will subtract the current 14 prd moving average from the previous one. Then you feed that indicator into a cBot and make a trade when the last 3 prds are positive or negative. Here is an example of a slope indicator.
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = false)] public class myMASlope : Indicator { [Parameter(DefaultValue = 60)] public int paramPeriods { get; set; } [Parameter(DefaultValue = 1.9)] public double paramLimit { get; set; } [Output("MA Slope", PlotType = PlotType.Histogram, Thickness = 2, Color = Colors.Purple)] public IndicatorDataSeries Result { get; set; } [Output("SlopeMA", LineStyle = LineStyle.Lines, Color = Colors.Red)] public IndicatorDataSeries SlopeMA { get; set; } [Output("UpperLimit", PlotType = PlotType.Line, LineStyle = LineStyle.DotsRare, Thickness = 1, Color = Colors.Red)] public IndicatorDataSeries UpperLimit { get; set; } [Output("LowerLimit", PlotType = PlotType.Line, LineStyle = LineStyle.DotsRare, Thickness = 1, Color = Colors.Red)] public IndicatorDataSeries LowerLimit { get; set; } [Output("Center", LineStyle = LineStyle.DotsRare, Color = Colors.White)] public IndicatorDataSeries CenterLine { get; set; } private SimpleMovingAverage sma; private MovingAverage slopema; private SimpleMovingAverage slopema2; protected override void Initialize() { sma = Indicators.SimpleMovingAverage(MarketSeries.Close, paramPeriods); slopema = Indicators.MovingAverage(Result, 2, MovingAverageType.Exponential); slopema2 = Indicators.SimpleMovingAverage(slopema.Result, 2); } public override void Calculate(int index) { int t0 = index; int t1 = t0 - 1; int t2 = t1 - 1; if (t1 < 0) return; if (double.IsNaN(sma.Result[t1])) return; Result[index] = Math.Round((sma.Result[t0] - sma.Result[t1]) / (Symbol.PointSize), 2); SlopeMA[index] = slopema2.Result[index]; //Result[index]= Math.Round((sma.Result[t0]-sma.Result[t2])/(Symbol.PointSize*2),2); UpperLimit[index] = paramLimit; LowerLimit[index] = -paramLimit; CenterLine[index] = 0; } } }
@lec0456
lec0456
22 Feb 2019, 17:42
I did last night!! it opens a form that displays the countdown in a large font.
using System; using cAlgo.API; using System.Threading; using System.Windows.Forms; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class myCandleCountDown : Robot { [Parameter("Alert On", DefaultValue = true)] public bool paramAlertOn { get; set; } private Thread _thread; private frmCandleCountdown _counter; protected override void OnStart() { Timer.Start(1); _counter = new frmCandleCountdown(); //_thread = new Thread(() =>{ _counter.ShowDialog(); }); _thread = new Thread(() => { Application.Run(_counter); }); _thread.SetApartmentState(ApartmentState.STA); _thread.Start(); } protected override void OnTimer() { int cdMinutes = 14 - Time.Minute % 15; int cdSeconds = 59 - Time.Second; _thread = new Thread(() => _counter.UpdateCounter(cdMinutes.ToString("00")+":"+cdSeconds.ToString("00"))); _thread.SetApartmentState(ApartmentState.STA); _thread.Start(); if(cdMinutes==0 && cdSeconds==0 && paramAlertOn) Notifications.PlaySound(@"C:\Users\user\Documents\cAlgo\Sources\Robots\CountdownTimer.wav"); } } }
I added a simple form with a label and one function.
public void UpdateCounter(string _text) { lblCounter.Text = _text; }
@lec0456
lec0456
30 Dec 2018, 02:55
RE:
lec0456 said:
Actually, IC markets also has 6 daily candles for the week of Nov1-6 and Nov 8-13. It continues with some very strange behavior. The newyork market ends at 16:00 EST on friday instead of 17:00 and then resumes on sunday for the last hour of trading, this is all being agregated into friday's daily candle.here is an example:
http://icmarkets.ctrader.com/c/m8mPn
thats in 2015
@lec0456
lec0456
30 Dec 2018, 02:54
Actually, IC markets also has 6 daily candles for the week of Nov1-6 and Nov 8-13. It continues with some very strange behavior. The newyork market ends at 16:00 EST on friday instead of 17:00 and then resumes on sunday for the last hour of trading, this is all being agregated into friday's daily candle.here is an example:
http://icmarkets.ctrader.com/c/m8mPn
@lec0456
lec0456
29 Dec 2018, 07:13
Interesting, I looked at 3 other brokers and this behavior does not occur. They generate the 5 candles as expected during the weeks mentioned and agregated weekly as expected. also, for the broker where the behavior was observed I did not find it occuring in the past. So, it appears to be just these 2 instances.
@lec0456
lec0456
29 Dec 2018, 06:49
by the way, according to the weekly series, Nov 4 is included in the previous week's open and close prices. So, the week runns from 10/29, 10/30, 10/31, 11/1, 11/2, and 11/4!
You can see this here:
http://roboforex.ctrader.com/c/2tmPn
the purple dotted lines are the weekly hi and low from the weekly timeframe data.
@lec0456
lec0456
29 Dec 2018, 06:23
ok, this I was able to match the behavior so that a 5pm or 17:00 EST marks a new trading day. If I convert the server time in UTC to Eastern Standard Time and add 7 hours, it is consistently following the open and close of the daily candles.
I used this function:
DateTimeOffset TradeDate(DateTime d) { DateTimeOffset CurrentDateTime = DateTime.SpecifyKind(d, DateTimeKind.Utc); CurrentDateTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(CurrentDateTime, "Eastern Standard Time"); CurrentDateTime = CurrentDateTime.AddHours(7); return CurrentDateTime; }
Basically, instead of subtracting 5 from utc during the winter and subtracting 4 during the summer, it returns the time as +2 during the winter and +3 during the summer. it now works consistently throughout the year.
@lec0456
lec0456
28 Feb 2019, 17:21
ok, I didn't think of that because I didn't think the behavior was by design.
Previously you did not need to do that check. Its a perfectly fine work around but I think it should be fixed so that it works like it did previously.
Could you escalate this issue to your developers?
Thanks for all your help.
@lec0456