Topics
Replies
firemyst
28 Oct 2024, 23:46
The “takeprofit” parameter in the execute market order is in Pips; you're supplying an actual price.
Replace “takeProfit” in the ExecuteMarketOrder with your parameter “TakeProfitPips”.
OR what you need to do is convert “takeProfit” back to pips as a distance from the current candle close, which seems pointless in this scenario as you have it since TP is measured from the current “close” price when the order is placed.
@firemyst
firemyst
27 Oct 2024, 08:51
Go scorched earth:
- copy your c# source code into a separate Notepad text file and save it separately.
- copy any other source code file affected in the solution into separate files for backup purposes
- delete everything from the folder, including the name of the bot/indicator itself
- Go into cTrader and create the new indicator/bot again from scratch
- open in Visual Studio
- Compile as is to make sure it works
- add any references you need to
- now open the file in visual studio
- copy and paste the source code from the backup Notepad file you created in step #1 into the .cs file
- try compiling again to see if it works
That should hopefully fix up or wipe out any “corruption” or otherwise bad metadata in the project you had initially created.
See if that works?
@firemyst
firemyst
24 Oct 2024, 01:22
Just glancing at your code, I noticed one way to improve it.
The “GetTrend()” method is a waste of CPU cycles. If the trend doesn't match a “sell”, it's always going to return a “buy”. If this is actually what you want, then redo the code like follows to remove a conditional check:
private TradeType GetTrend()
{
//Remove the first conditional check to save on CPU cycles and make your bot code
//that few nano-seconds faster
if (Bars.ClosePrices.Last(1) < ema200.Result.Last(1))
return TradeType.Sell;
else
return TradeType.Buy;
}
@firemyst
firemyst
24 Oct 2024, 00:54
I'm not sure about a plugin situation, but you can save the toggle button states to a file, and when the file is updated have your other running cBots read/update their charts based on whatever values you have saved in the file.
Note that this method isn't possible if you're running bots in the cloud as I don't believe bots in the cloud can read/write files.
Keep us posted with the solution you implement.
@firemyst
firemyst
24 Oct 2024, 00:37
RE: RE: RE: RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running
PanagiotisCharalampous said:
zossles said:
PanagiotisCharalampous said:
Hi firemyst,
We were able to reproduce this some days ago and we are working on a solution.
Best regards,
Panagiotis
It's still happening for us. Any ETA's on a fix? Another week? Month?
We do not have an ETA unfortunately. It will be released in one of the following updates
Is this issues resolved in the 5.0.40 release?
@firemyst
firemyst
23 Oct 2024, 00:39
( Updated at: 23 Oct 2024, 04:59 )
RE: position_closed looping for all bot instances
J.Lo said:
Still happening in 2024. i have multiple instances running. when a position closes and the position_closed event fires, it triggers this method for all instances (although it does just close the actual trade)
I can tell because i receive the SMS's *freaked me out
In fact, i noticed this behaviour in Positions_Modified and Positions_Opened aswell
My fix
private void Positions_Closed(PositionClosedEventArgs obj){ //step: weird bug - do not fire for symbols that are not the same - picked this up in my sms's if(obj.Position.Symbol.Name.ToUpper() != Symbol.Name.ToUpper()) return;
It appears this is intended behavior because of the way the event is wired. It's wired this way because it's on the “Positions” collection, not the individual “Position”. The “positions” is all the positions, not just a singular one.
https://help.ctrader.com/ctrader-algo/references/Trading/Positions/Positions/#closed
It occurs every time a position is closed. So it doesn't matter if a position is closed from a bot, a stop loss, a take profit, or someone manually closing it. That's why there's the “args” parameter is supplied so you can filter the event based on the symbol from the “positions” collection.
@firemyst
firemyst
17 Oct 2024, 01:45
( Updated at: 17 Oct 2024, 04:57 )
The example code on this page needs to be updated as well. It's showing example code for “LastValue” under the “Last” property.
It has the same example (correctly) under the LastValue property.
https://help.ctrader.com/ctrader-algo/references/Collections/DataSeries/DataSeries/#last
TO be comprehensive, an updated example should show difference like using “.Last(0)” vs “.Last(1)”
@firemyst
firemyst
17 Oct 2024, 01:40
( Updated at: 17 Oct 2024, 04:57 )
Depends on what you want.
You're getting the LastValue, which is value as of the moment it's taken in the current bar. As you know, values for the current bar can change depending on what the price does.
So at the beginning of the bar for example, the top band could be one value, but then if price really skyrockets and the band expands, the top band could end up being another value by the close of the bar.
If that's what you want, fine.
Perhaps what you want is the value of the previous bar when price closed? With Bollinger Bands, that shouldn't change. So instead of getting the .LastValue, you need to get .Last(1).
@firemyst
firemyst
17 Oct 2024, 01:32
( Updated at: 17 Oct 2024, 04:57 )
This is technical support.
If you want Spotware to consider implementing a feature, you need to put it in the Suggestions forum:
https://ctrader.com/forum/suggestions/
Or write a bot/indicator yourself that will do the deed.
@firemyst
firemyst
14 Oct 2024, 00:39
( Updated at: 14 Oct 2024, 05:07 )
RE: Chart can not pan to left side
PanagiotisCharalampous said:
Hi there,
Check the video below
Well that's a cool little feature I never knew cTrader had!
@firemyst
firemyst
11 Oct 2024, 00:49
( Updated at: 11 Oct 2024, 05:05 )
According to their reference page, it doesn't look like it:
https://help.ctrader.com/ctrader-algo/references/Account/IAccount/
@firemyst
firemyst
10 Oct 2024, 11:56
( Updated at: 11 Oct 2024, 05:05 )
For VPS service?
For broker?
Try Fusion Markets
@firemyst
firemyst
10 Oct 2024, 05:37
Since you're trading the US30 - what is a pip with the broker you're using?
Is it a point, or 0.1 points?
Pips don't always equal points with indices.
For instance, with Pepperstone, 1 pip equals 1 point on the US30; whereas on other brokers like Fusion Markets 1 point on US30 is 10 pips.
@firemyst
firemyst
06 Oct 2024, 03:03
RE: RE: Is it possible to get values from ChartIndicator
soskrr said:
PanagiotisCharalampous said:
Hi there,
It is not possible to get the values from the chart indicator. You would need to create the indicator inside your cBot instead.
Best regards,
Panagiotis
Hi there,
Let's say I have the Indicator's name
“MovingAverage”
, how can I create the indicator using that string?assembly = typeof(cAlgo.API.Indicators.MovingAverage).Assembly; Type type = assembly.GetType("cAlgo.API.Indicators.SimpleMovingAverage"); object instance = Activator.CreateInstance(type, new obj[] { //prams });
Can I use an assembly to do this ?
Thank you
Did you even look at the example URL link I provided?
Spotware has provided an example there for the SMA.
@firemyst
firemyst
04 Oct 2024, 14:47
( Updated at: 05 Oct 2024, 06:10 )
I don't believe there is, and think you'll have to keep track of it in your code.
Basically query the SL distance from whatever price you want, convert it to pips, and then save it in a variable before setting the SL property to true on the position.
@firemyst
firemyst
28 Oct 2024, 23:48 ( Updated at: 29 Oct 2024, 06:25 )
Did you try googling for your answer?
This is the first result I got:
https://ctrader.com/forum/ctrader-mobile/43814/
@firemyst