Topics
Replies
firemyst
18 Feb 2025, 05:15
Please post your requests in the correct forum. This is a tech support forum - they don't come here looking for suggestions to their product. That's what the suggestion forum is.
And before you post it there, vote on the suggestion as it has already been mentioned numerous times.
@firemyst
firemyst
18 Feb 2025, 04:54
Out of curiosity, why are you calculating startIndex twice?
int startIndex = Math.Max(0, Bars.Count - LookbackPeriod);
Just do it once in Calculate, and then pass the “startIndex” as a parameter to DrawSignal.
By doing so, it also means you no longer need this conditional check in DrawSignal:
if (barIndex < startIndex) return;
@firemyst
firemyst
18 Feb 2025, 01:14
the calgo documentation specifically states:
“The sleep functionality is available only for .NET 6 algos. While a cBot stays in sleep mode, all other events in the code will be ignored.”
If you need to do other things, then you obviously need to set your own timer and check if after x-seconds/minutes/hours/whatever.
So create your own timer, and set a flag after the desired amount of time has elapsed. When the flag is set to true, then continue executing whatever code you need to. In the mean time, you should still be able to listen to messages from whatever sockets you have set up.
@firemyst
firemyst
18 Feb 2025, 01:10
You didn't show the output of:
Print($"ATR: {atrValue}, TP: {_takeProfitDistance}, SL: {_trailingStopDistance}");
So basically, nobody knows what the numbers are along the way as it calculates the TP price you're setting. Have you tried debugging the code and/or used Visual studio to run in debug mode to see what the values are along the way to make sure they tee up to what you're expecting?
@firemyst
firemyst
18 Feb 2025, 01:00
RE: RE: ctrader can't get tp and sl and use them when my code says the opposite
Offhand I'd say your error is here:
// Calcul du SL et du TP double slPips = SlPercentage * Symbol.PipSize; double tpPips = TpPercentage * Symbol.PipSize;
Why are you taking the percentage here?
You're taking the percentage of the value of the pipsize. For non jpy forex pairs, this is 0.0001, so your number is only going to be smaller, which won't make placing the SL/TP practical.
so let's say you want to take 50% percentage. That means your pipsize is now going to be 0.00005, not the actual pips distance you want to place. Your modify order call is then placing the SL/TP at distances of only ½ pip - not even a full pip! With some symbols having pip spreads of greater than 0.5, how do you expect the system the order to be placed when the SL or TP is inside the spread?
@firemyst
firemyst
08 Feb 2025, 03:54
( Updated at: 14 Feb 2025, 18:19 )
Duplicate of this thread:
https://community.ctrader.com/forum/ctrader-algo/46280/
@firemyst
firemyst
07 Feb 2025, 02:52
( Updated at: 14 Feb 2025, 18:18 )
Limitations of cbots in the cloud:
https://www.spotware.com/terms-of-services
@firemyst
firemyst
07 Feb 2025, 02:51
( Updated at: 14 Feb 2025, 18:16 )
You should also check this page for when cbots are automatically restarted in the cloud:
https://www.spotware.com/terms-of-services
@firemyst
firemyst
18 Feb 2025, 05:18
@firemyst