Topics
Replies
firemyst
01 Jun 2023, 06:00
This is more a C# thing than a cTrader thing.
If you unsubscribe from events, it could free up some resources and make available for garbage collection.
Do a little Google research.
https://stackoverflow.com/questions/506092/is-it-necessary-to-explicitly-remove-event-handlers-in-c-sharp#:~:text=Yes%2C%20you%20will%20want%20to,reference%20remains%2C%20it%20is%20live.
@firemyst
firemyst
01 Jun 2023, 05:22
//Sample code to help you get started:
//Set the line size. If timeframe is "Minute", make it 2. Otherwise, make it 1.
int lineSize = (Chart.TimeFrame == TimeFrame.Minute ? 2 : 1);
for (double level = start; level <= max + step; level += step)
{
Print("{0} {1} {2}", level, level + half, level + quarter);
Chart.DrawHorizontalLine("WholeLine" + level, level, cWhole, lineSize, LineStyle.Solid);
Chart.DrawHorizontalLine("HalfLine" + level, level + half, cHalf, lineSize, LineStyle.Lines);
Chart.DrawHorizontalLine("QuarterUpLine" + level, level + quarter, cQuarter, lineSize, LineStyle.Dots);
Chart.DrawHorizontalLine("QuarterDownLine" + level, level - quarter, cQuarter, lineSize, LineStyle.Dots);
}
@firemyst
firemyst
01 Jun 2023, 05:16
I don't know that anyone has the actual source code to the native indicator within cTrader.
However, do a search on the site for "fibonacci" and you'll find other indicators/bots based on Fibonacci, and you might find code that can help you along:
Or look for yourself in the library of indicators readily available:
@firemyst
firemyst
01 Jun 2023, 05:05
RE:
rafiki.matu said:
Hey guys,
Trying to code an indicator that gives and arrow notification when the fast MA crosses the slow MA either from above or below.
How do i add a filter to the code to include the 200 EMA and only give a notification when the cross occurs above the 200 EMA for buy signals and below the 200 EMA for sell signals.
Anything i try gives errors.Below is the piece of code where am stuck.
The code does work whenever there is a MA cross but i want to add a filter to only give alerts after incorporating the 200EMA.
if(Functions.HasCrossedAbove(fastMA.Result, slowMA.Result, 0)){
Chart.DrawIcon("HasCrossedAbove",ChartIconType.UpTriangle,Bars[index].OpenTime,Bars[index].Low-arrowOffset,Color.LightBlue);
if (Playsound && Cup<2 ){
Notifications.PlaySound(SoundPath);
Cup++;
Cdown=0;
}
}if (Functions.HasCrossedBelow(fastMA.Result, slowMA.Result, 0)){
Chart.DrawIcon("HasCrossedBelow",ChartIconType.DownTriangle,Bars[index].OpenTime,Bars[index].High+arrowOffset,Color.Red);
if (Playsound && Cdown<2 ){
Notifications.PlaySound(SoundPath);
Cdown++;
Cup=0;
}
}
}
}
}
Any help will be highly appreciated.
Thanks.
Just test to see if the current closing price is above/below the 200MA.
//This is a mixture of sample/pseudo code but hopefully is enough to get you started
if (Bars.ClosePrices.LastValue > MA200.Result.LastValue)
{
if (Functions.HasCrossedAbove(fastMA.Result, slowMA.Result, 0))
{
Chart.DrawIcon("HasCrossedAbove",ChartIconType.UpTriangle,Bars[index].OpenTime,Bars[index].Low-arrowOffset,Color.LightBlue);
if (Playsound && Cup < 2 )
{
Notifications.PlaySound(SoundPath);
Cup++;
Cdown=0;
}
}
}
else if (Bars.ClosePrices.LastValue < MA200.Result.LastValue)
{
if (Functions.HasCrossedBelow(fastMA.Result, slowMA.Result, 0))
{
Chart.DrawIcon("HasCrossedBelow",ChartIconType.DownTriangle,Bars[index].OpenTime,Bars[index].High+arrowOffset,Color.Red);
if (Playsound && Cdown < 2 )
{
Notifications.PlaySound(SoundPath);
Cdown++;
Cup=0;
}
}
}
@firemyst
firemyst
01 Jun 2023, 04:55
Example to help you get started:
if (Bars[index].OpenTime.DayOfWeek != DayOfWeek.Sunday)
{
}
else
{
// skip Sunday
}
You just have to make sure your bot is set to work in your time zone, otherwise if your market data is being derived in another time zone, obviously that Sunday might not line up with your Sunday.
@firemyst
firemyst
29 May 2023, 09:30
RE:
PanagiotisChar said:
@firemyst,
No need to tag us on every discussion :) If we haven't replied then probably we can't help. As far as I know this information is not available via the API
Need help? Join us on Telegram
Need premium support? Trade with us
Well there you go @PanagiotisChar. Now that you've responded to this one you've just helped since nobody else seems to have known :-)
PS: I only tag you since you have all the insider info and knowledge about the product, or at least more than us regular joe-schmoes do :-)
@firemyst
firemyst
29 May 2023, 08:49
Great.
Yeah, the mobile version is a bit ridiculous with the little amount you can customize compared to other mobile trading platforms.
Get this, on the mobile version, even the only way to change the chart colors is changing the entire theme on your phone from "light" to "dark". They used to have it where you can specify the chart be in light or dark mode. Now, in order to do that, you have to put your entire phone in "dark theme", which is completely idiotic.
I really think Spotware needs to get a new person, who has actually looked at what competing products are capable of doing, and driving a better mobile version balancing features, performance, and what traders actually want if they do put "traders first".
@firemyst
firemyst
02 Jun 2023, 03:54 ( Updated at: 01 Dec 2024, 02:36 )
I would vote for the feature as it's already been posted as a suggestion:
@firemyst