Topics
Replies
DiamondTrades
19 Aug 2022, 23:15
( Updated at: 19 Aug 2022, 23:26 )
Also, to clarify, I have Version 4.3.9.7083 and 4.2.20 of cTrader installed and both have this issue.
@DiamondTrades
DiamondTrades
28 Sep 2021, 11:14
RE:
amusleh said:
Hi,
You have to define a mathematical relation between those numbers, then you can code it.
Try this:
using System; using cAlgo.API; using cAlgo.API.Internals; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class test : Indicator { [Parameter("Amount (Pips)", DefaultValue = 21)] public double AmountInPips { get; set; } [Parameter("Step (Pips)", DefaultValue = 100)] public double StepInPips { get; set; } [Parameter("Min Level (Price)", DefaultValue = 1)] public double MinLevelInPrice { get; set; } [Parameter("Max Level (Price)", DefaultValue = 10)] public double MaxLevelInPrice { get; set; } protected override void Initialize() { AmountInPips *= Symbol.PipSize; StepInPips *= Symbol.PipSize; for (var level = MinLevelInPrice; level < MaxLevelInPrice; level += StepInPips) { var lineLevel = Math.Round(level + AmountInPips, Symbol.Digits); Chart.DrawHorizontalLine(lineLevel.ToString(), lineLevel, Color.Red); // Uncomment the print if you want to check the line levels on your cTrader automate logs tab //Print(lineLevel); } } public override void Calculate(int index) { } } }
You might be able to find other better ways to code the same thing witch will be much faster than mine.
Thank you very much! This does the job perfectly
@DiamondTrades
DiamondTrades
27 Sep 2021, 11:29
RE:
amusleh said:
You can use Chart.DrawText:
for (double level = startHun; level <= max + stepHun; level += stepHun) { ChartObjects.DrawHorizontalLine("line_2" + level, level, Colors.Blue); // You can add some distance if you want to by adding some pips value to level // The x axis value to last bar on chart, you can change it based on your needs Chart.DrawText("line_2_text" + level, level.ToString(), Chart.LastVisibleBarIndex, level, Color.Blue); }
This works well, thanks
@DiamondTrades
DiamondTrades
27 Sep 2021, 11:28
RE:
firemyst said:
Use "Chart.DrawText" and put in your "level" parameter for the "double y" parameter.
Eg:
Chart.DrawText("line_2_text", "here is my text I want to draw", theBarIndex, level, Color.Red);
Thank you!
@DiamondTrades
DiamondTrades
19 Aug 2022, 23:49
I have resolved this. Posting fix for anyone that may come across the same issue again. This was related to my NuGet package settings. To fix, within VS 2022, go to "Tools > NuGet Package Manager > Package Manager Settings" Then within here "Package Sources" for me, I only had Offline Packages, which meant it couldn't update the Dependencies. So add nuget.org as a source "https://api.nuget.org/v3/index.json" is the correct link. Once added, it should now work.
@DiamondTrades