Topics
Replies
firemyst
05 Aug 2022, 10:53
You need to submit your suggestions here:
https://ctrader.com/forum/suggestions
This is the forum where Spotware takes suggestions for improving their products.
@firemyst
firemyst
04 Aug 2022, 04:30
( Updated at: 21 Dec 2023, 09:22 )
RE: RE:
kurtisnauss said:
firemyst said:
Bars.ClosePrices[index] > slowMa.Result[index]
This is going to happen on every bar where the close price is greater than the MA. If you have a long uptrend, and are on a small/fast time frame over a long period of back testing, this could happen thousands of times.
For example:
The condition will evaluate to true for every single one of those bars shown above if your slow MA is the yellow line, because the close price is above the MA.
But that's only in theory since we don't have the whole of your code and don't know what else is happening in your bot.
Yes, that makes sense that would be reading and storing data for every bar that is printed.
Therefore, when writing it as in example #1, does that tell it to only read it one time on the initial cross and then waits until the next time we see it crossover?
Yes.
In my above example, it wouldn't happen at all within the screen capture provided.
However, depending on the setting of your MA again, it could still happen quite a few times as shown here from the same chart (just a different MA period):
where you have a (any color) bar that closes below the line followed by a green bar that closes above the line. Those meet the conditions for Example #1.
In this screen capture, I see at least 11 times where that occurs.
@firemyst
firemyst
04 Aug 2022, 04:07
Try this as I believe you need to include/set the headers:
var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var result = client.PostAsync(endpoint, content).Result;
@firemyst
firemyst
04 Aug 2022, 03:56
Bars.ClosePrices[index] > slowMa.Result[index]
This is going to happen on every bar where the close price is greater than the MA. If you have a long uptrend, and are on a small/fast time frame over a long period of back testing, this could happen thousands of times.
For example:
The condition will evaluate to true for every single one of those bars shown above if your slow MA is the yellow line, because the close price is above the MA.
But that's only in theory since we don't have the whole of your code and don't know what else is happening in your bot.
@firemyst
firemyst
03 Aug 2022, 11:06
( Updated at: 21 Dec 2023, 09:22 )
RE: RE: Thank alot :)
kuwait007 said:
PanagiotisCharalampous said:
Hi kuwait007,
If your broker does not want to configure this for cTrader, you can try another broker. Here is an example from a broker that offers fractional contracts of 0.01 lots.
Best Regards,
Panagiotis
Many Thanks my friend :)
Pepperstone supports trading 0.1 lots on indices and 0.01 lots for forex.
@firemyst
firemyst
03 Aug 2022, 10:53
( Updated at: 21 Dec 2023, 09:22 )
RE: RE:
albert.isac94 said:
pantheljakob said:
I always have to keep my tablet on to take advanced profits which is really annoying!
I'd love to have the option to preset my trade with advanced take profits and breakeven distance
This functionality is already in cTrader, albeit after you place your order:
@firemyst
firemyst
03 Aug 2022, 06:53
RE:
amusleh said:
Hi,
Most probably we will support officially Visual Studio 2022 after cTrader 4.2 release.
Is there an official announcement on what versions of Visual Studio are still officially supported? Because there's nothing in this thread:
cTrader Desktop 4.2 Has Been Released!
@firemyst
firemyst
02 Aug 2022, 16:08
RE:
Anka Software said:
Hi,
Any way to get symbol type ie forex/index/cash etc?
Regards
Vivek
Maybe create C# HashSet objects calle "forex", "index", "cash" etc. IN each Has object, add the symbols you'll be trading that you would classify as forex, index, cash, etc, respectively.
@firemyst
firemyst
02 Aug 2022, 16:01
RE:
ctid4771555 said:
Hi
Is there any project template for Visual Studio already available to use, or it could be built in the future ?
Thanks
Not sure what you're asking for since if you're using Visual Studio you can easily create your own.
Just go into cTrader, under Automate, create a new indicator/bot, and then click to "edit in Visual Studio".
Why not save that as your template?
@firemyst
firemyst
29 Jul 2022, 03:02
( Updated at: 21 Dec 2023, 09:22 )
Issue with cTrader 4.2 attaching to processes for debugging
Hi @Spotware / @Panagiotis:
These are some great features and additions.
However, there's one that as an annoying drawback. Let's say you have at least 3-5 tabs open with trading charts with custom indicators. Now you have Visual Studio open trying to debug one of those indicators. You want to attach Visual Studio to the process.
How do you know which one to attach to?
Here you can see that there's at least 10 algohost processes launched, none of which have a title.
How does anyone know what process to attach the specific code they're debugging to from IDE's like Visual Studio?
I have to attach to the first one. Are breakpoints hit? No? Ok, I have to try the second one. Are breakpoints hit now? No? I have to try attaching to the next process. And so on and so forth.
Is there any way to make this a bit easier for developers? Like, can't @Spotware include a "Title" (or some other identifying information) when the separate algohost processes are spawned?
Thank you.
@firemyst
firemyst
14 Jul 2022, 03:26
" am trying to make this cbot open trades exactly on the MA crossing"
This depends on when you define a MA crossing. Right now, your code doesn't check the current bar/candle to see if the MA's crossed. Rather, it checks the previous bar and the bar before that (last(1) and last(2)).
If you want it on the exact tick that it happens, then you need to check the current values of the MA against the previous bar's values. Eg, last(0) and last(1) instead of last(1) and last(2).
@firemyst
firemyst
07 Jul 2022, 16:31
RE:
safaeianmohsen said:
Hello . Can anyone guide me? I want to add a code to the Ichimoku indicator so that whenever the values of Kijunsen and Span B are equal to each other, Only on the chart that is open , a sound allert will be generated.
If possible, please send it here.
You would do something like this (pseudo code) in your indicator's calculate method:
if (Kijunsen.Result.Last(0) == SpanB.Result.Last(0))
{
System.Media.SystemSounds.Exclamation.Play();
}
@firemyst
firemyst
07 Jul 2022, 16:28
"Are there now multiple instances of the historical bars taking up memory, or is cTrader intelligent enough to know it only needs one copy of this data for reference by any number of bots that need it?"
This is a question that only @Spotware / @Panagiotis / @Amusleh can answer.
@firemyst
firemyst
06 Jul 2022, 03:40
If it doesn't matter, why not just look for the first OnTick that happens after your specified time and execute the order then? So instead of checking if the time matches exactly, just check if onTickTime >= your specified time and if so, execute your actions. If you want it limited to only occur within a few seconds after your specified time, then pseudo logic would be:
if (onTIckTime >= yourSpecifiedTime && onTickTime <= OnTickTime + numberOfAllowedSecondsAfter)
{
// do what you have to do
}
If you do want it at the exact hour:minute:second and a tick doesn't come through, then there's nothing you can do as that's based on the market.
@firemyst
firemyst
29 Jun 2022, 05:16
RE:
cedric.boudreau said:
Do you have somewhere all founction of mathematique , document , i am litle tire to losse 1-2 hrs everytime to found the correct word...
i think addind that in your api guide will be appreciated.
in that case math.round(dsfd,2, up) ?
The "Math" api functions have nothing to do with Spotware as they are all part of the Microsoft .Net framework.
So you need to Google and find what you need on MIcrosoft.
For example, here's Microsoft's documentation for the Math class:
@firemyst
firemyst
27 Jun 2022, 07:14
//Quick example on how to sort positions by NetProfit (not gross profit)
//Change things around if you want to sort by time or something else.
foreach (Position p in Positions.FindAll(YourLabel, s.Name).OrderBy(x => x.NetProfit))
{
ClosePositionAsync(p, (TradeResult r) =>
{
if (r.IsSuccessful)
{
Print("Closed position \"{0} {1}\".", p.Id, p.Label);
}
else if (!r.IsSuccessful)
{
Print("WARNING! Could not close position \"{0} {1}\"!", p.Id, p.Label);
Print("Error message: {0}", r.Error.Value);
}
});
}
@firemyst
firemyst
06 Aug 2022, 11:34
RE: RE:
Alfie said:
Set a global bot variable called "CountOfTradesToday" = 0;
Set two date/time variables of the "Start time" and "end time" for your day.
Inside your bot's logic:
* check if CountOfTradesToday == 0
* if so, place your trade and increment CountOfTradesToday += 1
* if not, just skip
At end of your defined day, set CountOfTradesToday == 0 again to reset
@firemyst