Topics
Replies

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:54 ( Updated at: 11 Oct 2024, 05:05 )

Did you ever get this resolved or figured out?


@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?

New York City Servers

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
08 Oct 2024, 09:38

Like what errors?

You haven't listed any errors, nor shared any screen captures, nor explained how to reproduce what you're experiencing. 

 


@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
04 Oct 2024, 14:45 ( Updated at: 05 Oct 2024, 06:09 )

You first have to extract them from the Zip file.

Once extracted, you should see a “.algo” file. You need to double click that to install.

Once installed, you should see them listed in “custom” submenu of the “indicators menu”. They'll be listed at the bottom until you restart cTrader and then they'll be listed in alphabetical order.

 

If that doesn't work, then you need to contact the developer as Panagiotis suggested


@firemyst

firemyst
04 Oct 2024, 14:42 ( Updated at: 05 Oct 2024, 08:40 )

Have you seen these examples?

https://help.ctrader.com/ctrader-algo/articles/for-developers/how-to-use-custom-indicators-in-cbots/#initialising-an-indicator

One way or the other you have to program it in your bot code, so reference the indicator in your bot instead of trying to read a value from teh chart


@firemyst

firemyst
03 Oct 2024, 07:58 ( Updated at: 03 Oct 2024, 07:59 )

RE: costum indicators not showing

PanagiotisCharalampous said: 

Hi there,

We have released a hotfix (5.0.38). Can you please advise if it resolves your issue?

Best regards,

Panagiotis

Not for me. I had a chart on AUDJPY Renko10. All custom indicators were showing. Then I switched to CADJPY and they vanished.

I tried switching time frames, symbols, didn't help.

Looked in the algo tab to see what logs were displayed, and there were no errors erported for any indicator. All it said is indicator loaded/unloaded.

I couldn't get the indicators back on the chart without restarting cTrader.

I haven't found a way to consistently reproduce them disappearing. So far, it just seems to be randomly.

Version 5.0.38.32023

 


@firemyst

firemyst
03 Oct 2024, 00:20

Hopefully you can get the latest version now and update to 5.0.38.

AGain, it's one of those things that people need to ask how much testing they do before releasing a version as this seems like something that should have been pretty straight forward and catching beforehand.


@firemyst

firemyst
03 Oct 2024, 00:17

I experienced this as well. My cTrader was just updated to version 5.0.38, so hopefully they have that issue fixed now. 


@firemyst

firemyst
03 Oct 2024, 00:14

What's the spread on your US30 when you place the order?

On a few brokers, the spread is larger than the 2-point SL you set. 

If you're doing this in a bot or indicator, you need to check the spread before placing your order. It's not a guarantee since the spread could hypothetically change at any given moment, but it's a good safety check


@firemyst

firemyst
03 Oct 2024, 00:07

Get the position, and then check the stoploss value.

 

if (p.StopLoss.GetValueOrDefault() == 0)

{

    //no stoploss on the position. DO what you want to do.

}


@firemyst

firemyst
02 Oct 2024, 07:48

RE: RE: When a bot was "unexpectedly terminated", cTrader shows the bot as still running

PanagiotisCharalampous said: 

Hi firemyst,

We were able to reproduce this some days ago and we are working on a solution.

Best regards,

Panagiotis

Thank you for the update.

I am going to have my VPS reimaged again since your team no longer needs it now.

 


@firemyst