Topics
Replies

firemyst
31 Aug 2022, 15:52

They are already there.

 

Just declare the parameter to be a type of "int" or "double".

 

Then you can apply the min/max settings, "step" setting, etc.


@firemyst

firemyst
29 Aug 2022, 18:56

RE:

hayes_paul said:

* ignore this, no method to delete the post.

 

What was your solution? I'm receiving this with independent class files.

Thank you.


@firemyst

firemyst
29 Aug 2022, 11:15

RE:

ctid3999979 said:

Hi

Been looking at the following API reference about using a switch for code execution when a position is closed for various reasons

Is shows Positions.Closed += Position_Closed is in the OnStart() funtion. Doesn't the OnStart() funtion only run when the cBot starts though? Shouldn't I put it on the onTick if I want it run after the cBot has started?

I'm confused when the Position_Closed function runs. I would hope that a Take Profit being hit would just simply be a method in and of itself that you can execute code against in the same way the onBar() is run whenever a new bar is created,

 

Ignore this...Just did some basic testing and its printing output in the log for every trade.

I know you said "ignore this", but wanted to provide some clarity as it doesn't seem all your original questions had been answered.

> Positions.Closed += Position_Closed is in the OnStart() funtion

This sets up the _event method_ called "Position_Closed" which will be executed everytime the ".Closed" event happens. Eg, when _any_ (and this is very important) position is closed. So if you have a GBPUSD bot instance running and an AUDUSD bot instance running, and an AUDUSD position is closed, the event will fire and both bot instances will execute the "Position_Closed" method. So if you're going to run multiple instances of the same bot, you need to check that the position that was closed is the one related to your bot instance.

And yes, you only want it in your "OnStart" method because it's an event handler, and you register it with the C# runtime, you don't want to keep registering it every time a tick comes through, hence why it's in OnStart and not "OnTick".

 

Hope that helps. :-)

 


@firemyst

firemyst
28 Aug 2022, 07:50

RE:

collinganesh said:

When is Renko charts going to be implemented?

 

Since they're implemented now, it would be great to have them implemented with wicks and tails.


@firemyst

firemyst
21 Aug 2022, 16:12 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi firemyst,

It will be fixed in a future update, it's a low priority issue at the moment. The fastest workaround is to use a newer VS version.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

This isn't as straight forward either @Panagiotis.

I created a new bot in cTrader version 4.2.20; I added Indicator references that were created in earlier versions of VS and cAlgo, and were all built in "release" mode under the .Net framework 4.8;

Then I clicked to edit in Visual Studio. The newly created bot puts all the reference paths to the "Debug" folder with no way to change it:

The bot won't compile as a result; I can't find a way to change the "Path" to the "Release" folder in VS 2022.

What I had to do is remove all the "Project" references and then add all the "Release" dll assembly references.

Why is this the default behavior - to add the path to a debug dll that doesn't exist instead of adding the assembly reference to a "release" mode dll that DOES exist?


@firemyst

firemyst
21 Aug 2022, 15:13 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE: RE:

mage said:

 

From Solution explorer, right click on your solution and add existing project, select project of your indicator. This should fix your issue.

It doesn't. I still try and build the solution and it fails, but gives no errors or warnings as to why:


@firemyst

firemyst
19 Aug 2022, 03:34

RE: RE:

kurtisnauss said:

PanagiotisCharalampous said:

Hi kurtisnauss,

I would suggest to use ModifyStopLossPrice() instead.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

The first reply actually did work when I added that to the final modify position line.

What would be the difference or benefit of doing it that way instead?

thanks

It doesn't adjust your take profit at all. It only affects the stoploss price, hence the method name.

1) It's simpler.

2) you don't have to worry about putting code like this:

(position.TakeProfit.HasValue ? position.TakeProfit.GetValueOrDefault() : (double?)null)

everywhere you call "ModifyPosition".

3) your code would be a nanoseconds faster because it's one less conditional statement that has to be evaluated and values retrieved.

 


@firemyst

firemyst
18 Aug 2022, 04:35

RE:

kurtisnauss said:

Hi,

My trailing stop loss works very well, however, I am unsure how to get it to keep the take profit set to the current pip distance. 

every time it triggers the trailing stop it deletes the take profit and only begins trailing the stop loss until eventually it comes down and hits it.

I would like it so it can still take profit if price reaches it, but in an event that it comes just short of the take profit, it will have that safety net of the trailing stop.

here is the code currently:

        [Parameter("Include Trailing Stop", DefaultValue = true, Group = "Risk Management")]
        public bool IncludeTrailingStop { get; set; }

        [Parameter("Trailing Stop Trigger (pips)", MinValue = 1, MaxValue = 500, Step = 1, Group = "Risk Management")]
        public int TrailingStopTrigger { get; set; }

        [Parameter("Trailing Stop Step (pips)", MinValue = 1, MaxValue = 500, Step = 1, Group = "Risk Management")]
        public int TrailingStopStep { get; set; }


        protected override void OnTick()
        {
            if (IncludeTrailingStop)
            {
                SetTrailingStop();
            }
        }


        private void SetTrailingStop()
        {
            var sellPositions = Positions.FindAll(InstanceName, SymbolName, TradeType.Sell);
            foreach (var position in sellPositions)
            {
                double distance = position.EntryPrice - Symbol.Ask;
                if (distance < TrailingStopTrigger * Symbol.PipSize)
                    continue;

                double newStopLossPrice = Symbol.Ask + TrailingStopStep * Symbol.PipSize;
                if (position.StopLoss == null || newStopLossPrice < position.StopLoss)
                {
                    ModifyPosition(position, newStopLossPrice, null);
                }
            }

            var buyPositions = Positions.FindAll(InstanceName, SymbolName, TradeType.Buy);
            foreach (var position in buyPositions)
            {
                double distance = Symbol.Bid - position.EntryPrice;
                if (distance < TrailingStopTrigger * Symbol.PipSize)
                    continue;

                double newStopLossPrice = Symbol.Bid - TrailingStopStep * Symbol.PipSize;
                if (position.StopLoss == null || newStopLossPrice > position.StopLoss)
                {
                    ModifyPosition(position, newStopLossPrice, null);
                }
            }
        }

 

Your take profit disappears because you set it to "null" every time you "ModifyPosition".

ModifyPosition(position, newStopLossPrice, null);

 

So if you don't want to change your TakeProfit, set the value:

ModifyPosition(position, newStopLossPrice, (position.TakeProfit.HasValue ? position.TakeProfit.GetValueOrDefault() : (double?)null) )

 

 


@firemyst

firemyst
18 Aug 2022, 04:23

RE:

benjaminwolf123454321 said:

Hello, 

 

is there a way to add a multiselect parameter?

 

We can have an Enum like  

 

        [Parameter("Source")]
        public DataSeries Source { get; set; }

 

But can we have a [Flag] enum to give me the option to select multiple options at once in the parameters list?

 

Not as far as I'm aware in the fashion you're speaking. You could always try to "hack" your way around it. For instance, have all your options as several "boolean" parameters where users select "Yes/No" to each one, and then implement the appropriate logic in your bot to run with all their selections.

Otherwise, this would be considered more of a suggestion, so should be posted in the area for their dev team to consider.


@firemyst

firemyst
16 Aug 2022, 16:24

RE:

amusleh said:

Hi,

The cTrader Polynomial Regression Channel does repaint because it's retrofitted to price action.

You can try Bollinger Bands, Keltner Channels, and Donchain channel indicators.

Hi @amusleh / @PanagiotisCharalampous :

1) if we're programmatically getting the latest values from the PRC Indicator, on every "OnBar" event we should get the last(x-values) from the indicator where "x" is the number of periods we have set in the PRC Indicator because potentially all those values could have been updated, correct? Eg, it internally does the recalculation and retrofitting automatically before we call .Last()?

2) Or do we have to call the indicator's Calculate method to force it to recalculate all those previous values since it is retrofitted before calling the .Last(x) method?

Thank you.


@firemyst

firemyst
14 Aug 2022, 19:17

the indicator has 3 parameters, so you need to provide the 3 values in their expected order:

var tsv = Indicators.GetIndicator<TSV>(Length, MaType, MaPeriod);


@firemyst

firemyst
12 Aug 2022, 02:43

RE: RE:

Liquidity said:

 

Thanks! There seems to be a difference in the backtesting results after adding the above code into protected override void OnTick()

 

Of course there is.

That's because in OnTick, the code is checked with every "tick" that comes in; in "OnBar", the code is only run once when a new bar is started.


@firemyst

firemyst
09 Aug 2022, 09:33

RE:

PanagiotisCharalampous said:

Hi firemyst,

We will check this. Thanks for reporting.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Just wanted to touch base and see if there's any progress or if any more details are needed?

Thank you.


@firemyst

firemyst
09 Aug 2022, 03:21 ( Updated at: 09 Aug 2022, 03:22 )

RE: RE:

siglotcapital said:

PanagiotisCharalampous said:

Hi siglotcapital,

There is nothing uncrackable but it is not easy to crack a .algo file.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


Ok if that's the case, you're saying its more difficult to crack .algo file compared to .MQL file right?

Secondly what's now the best method to protect ones file if you don't want it stolen or cracked. I am sure their people who sells their protected Algo files out there and there must be a way they're are protecting it to avoid theft or piracy.

Please kindly enlighten me on the best method to go about this.

You can also run your code through an obfuscator and then compile it into cTrader. This way, if they do manage to crack a .algo file, at least the code would be obfuscated to make it more annoying for them to figur eout.

Also, since Spotware has the necessary keys to decrypt any .algo code files, it'll also make it more difficult for them to "peak" at and understand your source code as well (if you're worried about that)


@firemyst

firemyst
09 Aug 2022, 03:18

RE:

nujazzman said:

Before a new update available in 5/08/2022 no moving average appeared anymore even being enable. How can I fix that? Anybody else with this problem?

If you read the rest of the forums, you would see that a lot of other users are experiencing the same issue.

 

@PanagiotisCharalampous and his team are looking into it.


@firemyst

firemyst
09 Aug 2022, 03:16

RE: RE:

firemyst said:

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!

 

Bump. @Spotware?


@firemyst

firemyst
07 Aug 2022, 08:38

RE:

PureForm said:

Ok, so I stripped down a working indicator line by line to see what makes it update and found the following workaround.

for (int i=1; i<=500; i++)
{
    double j = Bars.MedianPrices.LastValue - Bars.MedianPrices.Last(i);
}


Add this code to the Calculate() function. It seems to wake up the indicator or feeds it bar data.
As you can see this is unnecessary taxing. I haven't found a solution that works with the Initialize() function.

This bug should be fixed ASAP.

You will want to change your code to be more like the following so it's not running through that loop when the markets are open:

if (!Symbol.MarketHours.IsOpened())
{
	for (int i=1; i<=500; i++)
	{
	    double j = Bars.MedianPrices.LastValue - Bars.MedianPrices.Last(i);
	}
}

 

And it's completely ridiculous that a version of cTrader would even get released with a bug like this... Spotware definitely needs to fix it asap!

 


@firemyst

firemyst
06 Aug 2022, 18:29

Same here. Most indicators aren't showing on the charts.

I've submitted a technical report through cTrader and have emailed PanagiotisCharalampous a video capture showing how we try to add indicators and nothing shows on the charts over the weekend when markets are closed.


@firemyst

firemyst
06 Aug 2022, 11:34

RE: RE:

Alfie said:

firemyst said:

Yes.

 

Good ,
Do you have the code? or logic?

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

firemyst
06 Aug 2022, 07:59

Yes.

 


@firemyst