Topics
Replies
firemyst
25 Mar 2024, 02:18
( Updated at: 25 Mar 2024, 06:43 )
You need to post it here:
https://ctrader.com/forum/suggestions
@firemyst
firemyst
25 Mar 2024, 02:16
( Updated at: 25 Mar 2024, 06:43 )
THis is not the forum for this.
You need to post it here:
https://ctrader.com/forum/suggestions
@firemyst
firemyst
25 Mar 2024, 02:07
( Updated at: 25 Mar 2024, 06:43 )
Why don't you look at their online tutorials Spotware has?
https://help.ctrader.com/ctrader-automate/guides/network-access/#how-to-use-network-access
Or try using Google:
@firemyst
firemyst
24 Mar 2024, 08:01
Hi there:
You can't change the colors of “Output”s programmatically.
Instead, what you need to do is create another set of Outputs to represent the Lines that will be output when price rises above or below.
Assuming you want the line colors to change if price is above p[index] or below p[index] (as that's the only “pivot line” i see in your code).
So first, for the “tc” and “bc”, you need to make those plot types “DiscontinuousLine”
Next, create your new output objects. Ex:
[Output("TC2", LineColor = "Yellow", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.LinesDots, Thickness = 1)]
public IndicatorDataSeries tc2 { get; set; }
[Output("BC2", LineColor = "Cyan", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.LinesDots, Thickness = 1)]
public IndicatorDataSeries bc2 { get; set; }
Then plot the values of each line accordingly:
p[index] = (High[index] + Low[index] + Close[index]) / 3.0;
//bc[index] = (High[index] + Low[index]) / 2.0;
//tc[index] = ((p[index] - bc[index]) + p[index]);
if (Close[index] > p[index])
{
bc[index] = (High[index] + Low[index]) / 2.0;
bc2[index] = double.Nan;
tc[index] = double.Nan;
tc2[index] = ((p[index] - bc[index]) + p[index]);
}
else if (Close[index] < p[index])
{
bc2[index] = (High[index] + Low[index]) / 2.0;
bc[index] = double.Nan;
tc2[index] = double.Nan;
tc[index] = ((p[index] - bc[index]) + p[index]);
}
else
{
bc[index] = (High[index] + Low[index]) / 2.0;
bc2[index] = double.Nan;
tc2[index] = double.Nan;
tc[index] = ((p[index] - bc[index]) + p[index]);
}
@firemyst
firemyst
23 Mar 2024, 03:24
( Updated at: 23 Mar 2024, 05:34 )
You need to be more clear in your post.
You say “how can i exclude catches in the second loop if the symbol is already present in the first one?” when you have 4 loops in your example code.
Then you say, “not show lomit orders if a active position is already open on the same symbol.” when your sample code for limit orders is the 3rd loop shown in the code?
If I understand what I think you're trying to do, why not just:
if (Positions.Count(x => x.SymbolName == theSymbolName) == 0)
{
//didn't find it in current open positions, so add it
if (!Limits.ContainsKey(theSymbolName)
Limits.Add(theSymbolName,0);
}
@firemyst
firemyst
23 Mar 2024, 03:11
( Updated at: 23 Mar 2024, 05:34 )
Ever hear of a search engine called Google? :-)
I would recommend writing your data as json formatted data as it's simple to write, parse, and read the data written:
Also using Google, you can see there's been several questions/examples on cTrader throughout the years as well:
@firemyst
firemyst
22 Mar 2024, 08:01
RE: RE: "Memory management" in cbots
ctid4921325 said:
firemyst said:
Most of the newbies I've helped, their memory issues stem from having a lot of Print statements in their code. Printing lots of information to the logs will suck up memory since there's no automated way to clear it.
The other big problem is if your indicators/bots draw A LOT of chart objects. cTrader cannot easily handle hundreds and hundreds of custom chart objects being drawn on charts. For instance, if you draw your own custom TrendLine objects, once you hit about 1,000 objects, performance will degrade noticeably. So you have to have your own built in methods to clean up objects, or limit the number you draw on any chart continuously. Example: if you use TrendLines to draw your own Heikin Ashi candles on a chart overlaying normal candles on say an M1 chart, you'll easily end up with over 500 HA bars on top of the regular M! bars. So what you need to do is limit it so your indicator/bot only draws the most recent 500 HA bars, removing the previous ones on each new bar drawn.
And for such drawings, you only want it to happen “OnBar” and not “OnTick” where possible – redrawing everything on every tick is very resource intensive, especially if you have multiple indicators/bots doing it at the same time.
Ahah.. fantastic thanks firemyst.. yes, I am outputing hundreds of lines of print. I have the print wrapped in a method called Debug, which skips or pints based parameters, but it is on. I will turn those off and see what happens.
I do a little bit of drawing, but i'm not approaching 100 objects let alone 1000, and I've moved almost everything to OnBar out of ontick.
Thanks for the tip, I'll turnon/reduce my prints and we'll see what that does.
Thanks again.
Keep us posted please.
In my bots/indicators, I have a “debug” flag as a parameter that I can set when I run them. Of course, if true it will print out lots of info to the log; when false it doesn't print anything from the code. I've found this to be a great approach.
@firemyst
firemyst
22 Mar 2024, 01:15
( Updated at: 22 Mar 2024, 07:52 )
Most of the newbies I've helped, their memory issues stem from having a lot of Print statements in their code. Printing lots of information to the logs will suck up memory since there's no automated way to clear it.
The other big problem is if your indicators/bots draw A LOT of chart objects. cTrader cannot easily handle hundreds and hundreds of custom chart objects being drawn on charts. For instance, if you draw your own custom TrendLine objects, once you hit about 1,000 objects, performance will degrade noticeably. So you have to have your own built in methods to clean up objects, or limit the number you draw on any chart continuously. Example: if you use TrendLines to draw your own Heikin Ashi candles on a chart overlaying normal candles on say an M1 chart, you'll easily end up with over 500 HA bars on top of the regular M! bars. So what you need to do is limit it so your indicator/bot only draws the most recent 500 HA bars, removing the previous ones on each new bar drawn.
And for such drawings, you only want it to happen “OnBar” and not “OnTick” where possible – redrawing everything on every tick is very resource intensive, especially if you have multiple indicators/bots doing it at the same time.
@firemyst
firemyst
22 Mar 2024, 01:06
( Updated at: 22 Mar 2024, 07:52 )
TO change the volume, use the ModifyVolume method;
To close a position entirely, use the Close method.
@firemyst
firemyst
18 Mar 2024, 01:20
( Updated at: 18 Mar 2024, 14:40 )
I provided you an example in your other post:
https://ctrader.com/forum/cbot-support/42024
@firemyst
firemyst
18 Mar 2024, 01:18
I'll give you a few snippets. This is what I did and have notepad launching from cbots this way:
//you need to grant full access permissions
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
//These are for showing Notepad. Put them in top of your class file
[DllImport("user32.dll", EntryPoint = "SetWindowText")]
private static extern int SetWindowText(IntPtr hWnd, string text);
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
//to actually launch notepad from your code.
//don't put this in the ontick event or you'll crash your machine trying
//to constantly launch notepad on every tick.
//the Process class is found in System.Diagnostics
Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
if (notepad != null)
{
notepad.WaitForInputIdle();
if (!string.IsNullOrEmpty(title))
SetWindowText(notepad.MainWindowHandle, title);
if (!string.IsNullOrEmpty(message))
{
IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
SendMessage(child, 0x000C, 0, message);
}
}
@firemyst
firemyst
15 Mar 2024, 00:32
( Updated at: 15 Mar 2024, 06:59 )
RE: RE:
caputojr said:
PanagiotisCharalampous said:
Hi caputojr,
If you google it, you will find many.
Best Regards,
Panagiotis
Hi Panagiotis,
Thank you for your prompt reply. In fact I did a google search but i could only find paid indicators and so I came here looking for some enlightment.
I hope I can find someone willing to help.
Thanks
You obviously need to improve your Google skills because when I googled it, 2 of the first 3 results are multitime frame moving averages that are free:
@firemyst
firemyst
13 Mar 2024, 00:20
RE: RE: Trailing SL distance
polepole said:
Thank you for your reply, it is almost clear now. Although it is strange that you do not have a parameter where you can specify the trailing distance when you activate the trailing SL.
Let me see if I understood corectly:
- I have a BUY opened at price P
- Price has risen at P+60pips and now I set a SL at P+15pips
Question 3: If I enable trialing SL, the SL will now trail at 45 pips below current price? Alternatively, if I enable trailing SL and there is no SL, it will trail at 60 pips?
Then:
- Price has now reached P+100 and SL is at P+55 (because it's trailing 45 pips)
- I move the SL to P+30pips
Question 4: Will this change the trailing distance to 70 pips?
Question 5: If I move the SL at P+70pips, will this change the trailing distance to 30 pips?
Thank you!
Some times the best way to learn is to try it yourself and see what happens… self discovery is a wonderful thing :-)
3: If I enable trialing SL, the SL will now trail at 45 pips below current price? Alternatively, if I enable trailing SL and there is no SL, it will trail at 60 pips?
If you meant you set the SL at P+15 when price reached P+60, then yes, the SL should remain approximately 45 pips behind. I say “approximately” because cTrader doesn't move the SL with every tick (from what I understand) to keep server loads low.
Questions 4 & 5 - try it yourself manually. Place an order in a demo account. Wait for your order to get x-pips in profit. THen manually move your SL forward and/or backwards and watch what happens. Then you'll see it in action and learn so much more than by me answering your questions.
@firemyst
firemyst
10 Mar 2024, 03:12
( Updated at: 10 Mar 2024, 05:44 )
"However, the problem is that when I tried copying the code to use, it resulted in errors, and there are no examples for me to follow."
Have you even tried Google?
A simple search on “c# websocketclient example” brings back a list of websites, and the first one (medium.com) has a complete example including how to add it to your project using the NuGet package manager.
@firemyst
firemyst
25 Mar 2024, 02:21 ( Updated at: 25 Mar 2024, 06:43 )
You're posting in the wrong forum:
https://ctrader.com/forum/suggestions
@firemyst