TEMPLATE LOADING ISSUE
TEMPLATE LOADING ISSUE
07 Nov 2024, 10:25
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using System.Net;
using Telegram.Bot;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class SA : Indicator
{
private MovingAverage _sma;
private MovingAverage _ema;
private MovingAverage _tma;
private IndicatorDataSeries _tsma;
private MovingAverage _wilderSmoothing;
private IndicatorDataSeries WilderSmoothing;
private int WilderSmoothingPeriod = 5;
private StackPanel stackPanel;
private TextBox _smaTextBox;
private TextBox _emaTextBox;
private TextBox _tmaTextBox;
private TextBox _tsmaTextBox;
private Ellipse _smaSignalPoint;
private Ellipse _emaSignalPoint;
private Ellipse _tmaSignalPoint;
private Ellipse _tsmaSignalPoint;
private bool _buySignalSentForSMA = false;
private bool _sellSignalSentForSMA = false;
private bool _buySignalSentForEMA = false;
private bool _sellSignalSentForEMA = false;
private bool _buySignalSentForTMA = false;
private bool _sellSignalSentForTMA = false;
private bool _buySignalSentForTSMA = false;
private bool _sellSignalSentForTSMA = false;
private int startIndex;
[Parameter(DefaultValue = Orientation.Vertical)]
public Orientation Orientation { get; set; }
[Parameter("SMA Period", DefaultValue = 200)]
public int SmaPeriod { get; set; }
[Parameter("EMA Period", DefaultValue = 200)]
public int EmaPeriod { get; set; }
[Parameter("TMA Period", DefaultValue = 200)]
public int TmaPeriod { get; set; }
[Parameter("TSMA Period", DefaultValue = 200)]
public int TsmaPeriod { get; set; }
[Output("SMA", LineColor = "Green", PlotType = PlotType.Line)]
public IndicatorDataSeries SmaResult { get; set; }
[Output("EMA", LineColor = "Red", PlotType = PlotType.Line)]
public IndicatorDataSeries EmaResult { get; set; }
[Output("TMA", LineColor = "Blue", PlotType = PlotType.Line)]
public IndicatorDataSeries TmaResult { get; set; }
[Output("TSMA", LineColor = "Purple", PlotType = PlotType.Line)]
public IndicatorDataSeries TsmaResult { get; set; }
[Output("Sell Point", Color = Colors.Red, PlotType = PlotType.Points, Thickness = 0)]
public IndicatorDataSeries SellSeries { get; set; }
[Output("Buy Point", Color = Colors.Lime, PlotType = PlotType.Points, Thickness = 0)]
public IndicatorDataSeries BuySeries { get; set; }
[Parameter("Bot Token", DefaultValue = "", Group = "Telegram Notifications")]
public string BotToken { get; set; }
[Parameter("Chat ID", DefaultValue = "", Group = "Telegram Notifications")]
public string ChatID { get; set; }
[Parameter("Send a Telegram?", DefaultValue = false, Group = "Telegram Notifications")]
public bool IncludeTelegram { get; set; }
protected override void Initialize()
{
_sma = Indicators.SimpleMovingAverage(MarketSeries.Close, SmaPeriod);
_ema = Indicators.ExponentialMovingAverage(MarketSeries.Close, EmaPeriod);
_tma = Indicators.TriangularMovingAverage(MarketSeries.Close, TmaPeriod);
_tsma = CreateDataSeries();
_wilderSmoothing = Indicators.WellesWilderSmoothing(MarketSeries.Close, WilderSmoothingPeriod);
WilderSmoothing = CreateDataSeries();
startIndex = MarketSeries.Close.Count - 1; // Set to current bar on load
stackPanel = new StackPanel
{
Orientation = Orientation.Vertical,
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Bottom,
BackgroundColor = Color.FromArgb(5, Color.White),
Margin = 10
};
_smaTextBox = CreateTextBox();
var smaSignalPanel = CreateSignalPanel(_smaTextBox, out _smaSignalPoint);
_emaTextBox = CreateTextBox();
var emaSignalPanel = CreateSignalPanel(_emaTextBox, out _emaSignalPoint);
_tmaTextBox = CreateTextBox();
var tmaSignalPanel = CreateSignalPanel(_tmaTextBox, out _tmaSignalPoint);
_tsmaTextBox = CreateTextBox();
var tsmaSignalPanel = CreateSignalPanel(_tsmaTextBox, out _tsmaSignalPoint);
stackPanel.AddChild(smaSignalPanel);
stackPanel.AddChild(emaSignalPanel);
stackPanel.AddChild(tmaSignalPanel);
stackPanel.AddChild(tsmaSignalPanel);
Chart.AddControl(stackPanel);
}
public override void Calculate(int index)
{
if (index < startIndex) return;
SmaResult[index] = _sma.Result[index];
EmaResult[index] = _ema.Result[index];
TmaResult[index] = _tma.Result[index];
CalculateTSMA(index);
WilderSmoothing[index] = _wilderSmoothing.Result[index];
CheckForSignals(index, SmaResult, "SMA");
CheckForSignals(index, EmaResult, "EMA");
CheckForSignals(index, TmaResult, "TMA");
CheckForSignals(index, TsmaResult, "TSMA");
}
private void CalculateTSMA(int index)
{
if (index < TsmaPeriod) return;
double sumX = 0;
double sumY = 0;
double sumXY = 0;
double sumX2 = 0;
for (int i = 0; i < TsmaPeriod; i++)
{
int x = i + 1;
double y = MarketSeries.Close[index - i];
sumX += x;
sumY += y;
sumXY += x * y;
sumX2 += x * x;
}
double slope = (TsmaPeriod * sumXY - sumX * sumY) / (TsmaPeriod * sumX2 - sumX * sumX);
double intercept = (sumY - slope * sumX) / TsmaPeriod;
TsmaResult[index] = intercept - (slope / 300) * TsmaPeriod;
}
private TextBox CreateTextBox()
{
return new TextBox
{
Margin = 5,
Text = "Waiting for Signal...",
BackgroundColor = Color.Black,
ForegroundColor = Color.White,
Width = 100,
FontSize = 14,
HorizontalAlignment = HorizontalAlignment.Left
};
}
private StackPanel CreateSignalPanel(TextBox textBox, out Ellipse signalPoint)
{
signalPoint = new Ellipse
{
Width = 10,
Height = 10,
FillColor = Color.Gray,
Margin = 5
};
var signalPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
Margin = 5
};
signalPanel.AddChild(signalPoint);
return signalPanel;
}
private void CheckForSignals(int index, IndicatorDataSeries maResult, string maType)
{
double buffer = Symbol.Name.Contains("USTECH") ? 0.002 : 0.0001;
bool buySignal = WilderSmoothing[index] < maResult[index] - buffer && MarketSeries.Close[index - 1] >= maResult[index - 1];
bool sellSignal = WilderSmoothing[index] > maResult[index] + buffer && MarketSeries.Close[index - 1] <= maResult[index - 1];
TextBox targetTextBox = null;
Ellipse targetSignalPoint = null;
ref bool buySignalSent = ref _buySignalSentForSMA;
ref bool sellSignalSent = ref _sellSignalSentForSMA;
switch (maType)
{
case "SMA":
targetTextBox = _smaTextBox;
targetSignalPoint = _smaSignalPoint;
break;
case "EMA":
targetTextBox = _emaTextBox;
targetSignalPoint = _emaSignalPoint;
buySignalSent = ref _buySignalSentForEMA;
sellSignalSent = ref _sellSignalSentForEMA;
break;
case "TMA":
targetTextBox = _tmaTextBox;
targetSignalPoint = _tmaSignalPoint;
buySignalSent = ref _buySignalSentForTMA;
sellSignalSent = ref _sellSignalSentForTMA;
break;
case "TSMA":
targetTextBox = _tsmaTextBox;
targetSignalPoint = _tsmaSignalPoint;
buySignalSent = ref _buySignalSentForTSMA;
sellSignalSent = ref _sellSignalSentForTSMA;
break;
}
if (buySignal && !buySignalSent)
{
buySignalSent = true;
sellSignalSent = false;
UpdateSignalText(targetTextBox, $"{maType} Buy Signal", targetSignalPoint, Color.Lime, index, "buy");
}
else if (sellSignal && !sellSignalSent)
{
sellSignalSent = true;
buySignalSent = false;
UpdateSignalText(targetTextBox, $"{maType} Sell Signal", targetSignalPoint, Color.Red, index, "sell");
}
}
private async void UpdateSignalText(TextBox targetTextBox, string signalText, Ellipse signalPoint, Color signalColor, int index, string signalType)
{
// Set the text for the chart display
targetTextBox.Text = signalText;
signalPoint.FillColor = signalColor;
// Prepare the Telegram message
string symbolName = Symbol.Name;
string timeframe = TimeFrame.ToString();
double bidPrice = Symbol.Bid;
string telegramMessage = $"Signal: Possible {signalType} signal using {targetTextBox.Text}\n" +
$"Symbol: {symbolName}\n" +
$"Bid Price: {Math.Round(bidPrice, 5)}\n" +
$"Timeframe: {timeframe}\n";
if (IncludeTelegram)
{
try
{
var bot = new TelegramBotClient(BotToken);
await bot.SendTextMessageAsync(ChatID, telegramMessage);
}
catch (Exception ex)
{
Print($"Telegram notification error: {ex.Message}");
}
}
}
}}
THIS INDICATOR WHEN SAVED TO TEMPLATE AND IT'S IN "AccessRights = AccessRights.FullAccess)]"OR “AccessRights = AccessRights.NONE)]”ON CTRADER.VER 4.9.2, THE TEMPLATE IS LOADING WITHOUT ANY PROBLEM,
BUT
IT'S NOT LOADING WHEN THE SAME INDICATOR IS SAVED IN TEMPLATE AND IT' HAS “AccessRights = AccessRights.FullAccess)]” ON CTRADER.VER 5.0…
BUT IT'S ONLY LOADING WHEN IT'S IN “AccessRights = AccessRights.NONE)]”
SO THE THING IS THAT IF ACCESSRIGHTS IS TURNED TO NONE I WON'T GET NOTIFICATION AND I WANT TO GET THE NOTIFICATIONS
Replies
dokinya
07 Nov 2024, 15:30
RE: TEMPLATE LOADING ISSUE
PanagiotisCharalampous said:
Hi there,
The solution to your problem is to add the indicator on the chart and provide full access permissions. Then the template should load without a problem.
Best regards,
Panagiotis
Hi there!
did you understood what am saying?
did you try out?
did you create a template with this indicator then try to load that template on another chart and see if this indicator will appear on the chart?
the issue is when i create a template and include other indicators, then try and load that template on another chart all other indicators are showing except this one. do you understand my point?
thank you
PanagiotisCharalampous
08 Nov 2024, 06:17
RE: RE: TEMPLATE LOADING ISSUE
dokinya said:
PanagiotisCharalampous said:
Hi there,
The solution to your problem is to add the indicator on the chart and provide full access permissions. Then the template should load without a problem.
Best regards,
Panagiotis
Hi there!
did you understood what am saying?
did you try out?
did you create a template with this indicator then try to load that template on another chart and see if this indicator will appear on the chart?
the issue is when i create a template and include other indicators, then try and load that template on another chart all other indicators are showing except this one. do you understand my point?
thank you
Hi there,
Yes. Did you try what I suggested? Did you add the indicator on the chart, give full permissions and then try to load the template again?
Best regards,
Panagiotis
@PanagiotisCharalampous
dokinya
08 Nov 2024, 08:55
( Updated at: 08 Nov 2024, 10:18 )
RE: RE: RE: TEMPLATE LOADING ISSUE
PanagiotisCharalampous said:
dokinya said:
PanagiotisCharalampous said:
Hi there,
The solution to your problem is to add the indicator on the chart and provide full access permissions. Then the template should load without a problem.
Best regards,
Panagiotis
Hi there!
did you understood what am saying?
did you try out?
did you create a template with this indicator then try to load that template on another chart and see if this indicator will appear on the chart?
the issue is when i create a template and include other indicators, then try and load that template on another chart all other indicators are showing except this one. do you understand my point?
thank you
Hi there,
Yes. Did you try what I suggested? Did you add the indicator on the chart, give full permissions and then try to load the template again?
Best regards,
Panagiotis
Greetings
i have tried what you are suggesting and it's still not working.
but i don't think you've tried what am saying
at this point am starting to feel like you've not tried it out you are assuming and ignoring this issue or you are being dismissive
Again add this indicator to a chart
it will prompt you to allow it (give full permissions)
click allow (sad am the one showing ctrader team how to add an indicator on the chart)
then click okay
at this point the indicator should be running
STEP 2 CREATE A TEMPLATE
right click on the chart and go to template, name the template and click save as shown on the image above ……..(did you do this?)
Note:
this is where there problem is
RIGHT CLICK ON THE CHART, GO TO TEMPLATE, THEN CLICK ON THE TEMPLATE YOU CREATED AND SEE WHAT HAPPENS, OR OPEN ANOTHER CHART AND GO STRAIGHT TO THE TEMPLATE YOU CREATED AND CLICK IT THEN SEE WHAT HAPPEN, WHATEVER HAPPENS IS NOT HAPPENING ON CTRADER VER 4.9.2
i hope i've made my self clear this time round.
IF YOU WANT TO WATCH A VIDEO HERE IS THE LINK AND I'VE ALSO UPLOAD THE SAME VIDEO ON- @cTrader_Team, @cTrader_Official
https://t.me/cTrader_Official/134049
https://www.dropbox.com/scl/fi/g9siwysrrdxnux8is0j51/Video_2024_08_28-2.mp4?rlkey=k873mebb7zzm65r1cijt5m845&st=fgrhr1wx&dl=0
i have tried different ideas nothing seem to be working. but i think the issue is with the ctrader ver 5.0 because it's working fine on ctrader ver. 4.9.2
i have sent an email now with the video, i've also sent a video to @cTrader_Team telegram account and also i've posted it on ctrader official chat group on telegram
PanagiotisCharalampous
08 Nov 2024, 10:23
( Updated at: 08 Nov 2024, 10:24 )
Hi,
What happens to you is by design so there is nothing to test. This is how it should work. Also in your video it does not seem you follow my instructions. Please record a video demonstrating that you follow my instructions and send it to us.
PS. Please show some respect to the forum and don't write in capitals as if you shout at us. We are trying to help you here.
Best regards,
Panagiotis
@PanagiotisCharalampous
dokinya
08 Nov 2024, 12:03
( Updated at: 08 Nov 2024, 12:07 )
RE: TEMPLATE LOADING ISSUE
PanagiotisCharalampous said:
Hi,
What happens to you is by design so there is nothing to test. This is how it should work. Also in your video it does not seem you follow my instructions. Please record a video demonstrating that you follow my instructions and send it to us.
PS. Please show some respect to the forum and don't write in capitals as if you shout at us. We are trying to help you here.
Best regards,
Panagiotis
Greetings!
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't thing we would be having this shenanigans,
your respond is extremely vague on what am supposed to do
PS. am the most respectful person i give what i get, can you be respectful, professional and courteous towards your clients. there is too much complain towards ctrader support
PanagiotisCharalampous
08 Nov 2024, 14:39
RE: RE: TEMPLATE LOADING ISSUE
dokinya said:
PanagiotisCharalampous said:
Hi,
What happens to you is by design so there is nothing to test. This is how it should work. Also in your video it does not seem you follow my instructions. Please record a video demonstrating that you follow my instructions and send it to us.
PS. Please show some respect to the forum and don't write in capitals as if you shout at us. We are trying to help you here.
Best regards,
Panagiotis
Greetings!
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't thing we would be having this shenanigans,
your respond is extremely vague on what am supposed to do
PS. am the most respectful person i give what i get, can you be respectful, professional and courteous towards your clients. there is too much complain towards ctrader support
Hi there,
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't thing we would be having this shenanigans,
You never said that you did not understand what I proposed. Instead you wrote that you did it. If you wrote earlier that you do not understand what I am suggesting you to do, I would have tried to explain it in a different way. Instead you chose to send complaint emails to the management. In order to help you further, please withdraw your complaint.
@PanagiotisCharalampous
dokinya
08 Nov 2024, 14:42
( Updated at: 08 Nov 2024, 14:44 )
RE: RE: TEMPLATE LOADING ISSUE
dokinya said:
PanagiotisCharalampous said:
Hi,
What happens to you is by design so there is nothing to test. This is how it should work. Also in your video it does not seem you follow my instructions. Please record a video demonstrating that you follow my instructions and send it to us.
PS. Please show some respect to the forum and don't write in capitals as if you shout at us. We are trying to help you here.
Best regards,
Panagiotis
Greetings!
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't think we would be having this shenanigans,
your respond is extremely vague on what am supposed to do
PS. am the most respectful person i give what i get, can you be respectful, professional and courteous towards your clients. there is too much complain towards ctrader support
by clicking allow is that what you mean when you say “add the indicator on the chart and provide full access permissions.”?
PanagiotisCharalampous
08 Nov 2024, 14:51
RE: RE: RE: TEMPLATE LOADING ISSUE
dokinya said:
dokinya said:
PanagiotisCharalampous said:
Hi,
What happens to you is by design so there is nothing to test. This is how it should work. Also in your video it does not seem you follow my instructions. Please record a video demonstrating that you follow my instructions and send it to us.
PS. Please show some respect to the forum and don't write in capitals as if you shout at us. We are trying to help you here.
Best regards,
Panagiotis
Greetings!
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't think we would be having this shenanigans,
your respond is extremely vague on what am supposed to do
PS. am the most respectful person i give what i get, can you be respectful, professional and courteous towards your clients. there is too much complain towards ctrader support
by clicking allow is that what you mean when you say “add the indicator on the chart and provide full access permissions.”?
Yes
@PanagiotisCharalampous
dokinya
08 Nov 2024, 15:09
RE: RE: RE: RE: TEMPLATE LOADING ISSUE
PanagiotisCharalampous said:
dokinya said:
dokinya said:
PanagiotisCharalampous said:
Hi,
What happens to you is by design so there is nothing to test. This is how it should work. Also in your video it does not seem you follow my instructions. Please record a video demonstrating that you follow my instructions and send it to us.
PS. Please show some respect to the forum and don't write in capitals as if you shout at us. We are trying to help you here.
Best regards,
Panagiotis
Greetings!
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't think we would be having this shenanigans,
your respond is extremely vague on what am supposed to do
PS. am the most respectful person i give what i get, can you be respectful, professional and courteous towards your clients. there is too much complain towards ctrader support
by clicking allow is that what you mean when you say “add the indicator on the chart and provide full access permissions.”?
Yes
on the attached screenshot earlier that's exactly what i did,
then i save that template, when i load that template on another chart it's not loading the indicator, even when i click to load the same template on the same chart so that indicator can appear it's not loading and this is what i've been saying all along.
dokinya
11 Nov 2024, 07:09
RE: RE: RE: TEMPLATE LOADING ISSUE
PanagiotisCharalampous said:
dokinya said:
PanagiotisCharalampous said:
Hi,
What happens to you is by design so there is nothing to test. This is how it should work. Also in your video it does not seem you follow my instructions. Please record a video demonstrating that you follow my instructions and send it to us.
PS. Please show some respect to the forum and don't write in capitals as if you shout at us. We are trying to help you here.
Best regards,
Panagiotis
Greetings!
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't thing we would be having this shenanigans,
your respond is extremely vague on what am supposed to do
PS. am the most respectful person i give what i get, can you be respectful, professional and courteous towards your clients. there is too much complain towards ctrader support
Hi there,
i don't understand what you mean by “provide full access permissions” if you could can provide a screenshot showing how i can provide full access permissions when i add the indicator on the chart i don't thing we would be having this shenanigans,
You never said that you did not understand what I proposed. Instead you wrote that you did it. If you wrote earlier that you do not understand what I am suggesting you to do, I would have tried to explain it in a different way. Instead you chose to send complaint emails to the management. In order to help you further, please withdraw your complaint.
Greetings
what do you mean “in order to help you further,please withdraw your complaint”, you are threatening me now.
i have a genuine complain against you and now you are threatening me?
PanagiotisCharalampous
07 Nov 2024, 14:17
Hi there,
The solution to your problem is to add the indicator on the chart and provide full access permissions. Then the template should load without a problem.
Best regards,
Panagiotis
@PanagiotisCharalampous