Topics
Replies

firemyst
26 Dec 2020, 16:29

RE: RE: RE:

vincenzo.dal.mare said:

firemyst said:

vincenzo.dal.mare said:

Hello guys,

how can i enter the jurik moving average?
in the list of moving average  available it does not appear even though I have downloaded it in my indicators.
can you give me a hand?
thank you all.

If you downloaded and installed it, then it should be under "indicators -> custom" and in that list.

 

If it's not there, then you probably didn't double-click to install the calgo file.

hello thanks for your answer. let me explain better ... I'm testing some trial and free cbots. I noticed that in the bot parameters window there are many types of moving averages, simple, exponential, weighted, triangular etc. however the jurik one is missing, despite having installed it in ctrader. can you make it appear in the list? thanks

 

No.

Only cTrader (Spotware) can do that. The only moving averages contained within that list are those that are natively included within cTrader.

If you want a Jurik moving average within a cBot, you have to make a separate parameter for it.

 


@firemyst

firemyst
26 Dec 2020, 12:55

RE:

vincenzo.dal.mare said:

Hello guys,

how can i enter the jurik moving average?
in the list of moving average  available it does not appear even though I have downloaded it in my indicators.
can you give me a hand?
thank you all.

If you downloaded and installed it, then it should be under "indicators -> custom" and in that list.

 

If it's not there, then you probably didn't double-click to install the calgo file.


@firemyst

firemyst
26 Dec 2020, 12:53

How do you define in an "uptrend" and "downtrend"? A bot doesn't just think "in an uptrend"... you have to define conditions that define what you think an "uptrend" is that can be programmed.

 

And how do you define "when resistance is formed"? What's "resistance"? When price doesn't break a certain level after x-candles? On each bar? On each tick? What happens if it breaks that line, comes back to stop you out, and then immediately breaks the line again? Do you get back in? Or leave it for several bars? Something else?

 

You should be a bit more specific in your requirements.


@firemyst

firemyst
19 Dec 2020, 15:36

For the trailing stop, change the ExecuteMarketOrder lines to have the following:

 

ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, SL, TP, null, true, null);

and

ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, SL, TP, null, true, null);


@firemyst

firemyst
19 Dec 2020, 15:30

AverageTrueRange _atr = Indicators.AverageTrueRange(MarketData.GetBars(TimeFrame.Daily, "GBPCHF"), 13, MovingAverageType.Exponential);

 

Change the parameter values as desired


@firemyst

firemyst
10 Dec 2020, 10:59

@Panagiotis?


@firemyst

firemyst
05 Dec 2020, 09:34

Not sure why you're asking because the pip-value doesn't change per-se on Forex pairs and indices.

For example, if you're trading the AUDUSD with Pepperstone, the pip value:

1) per 1 standard lot is always going to be 10 USD
2) per 0.1 standard lots is 1 USD
3) per 0.01 standard lots is 0.1 USD

Same thing with Indices.

Example again, point value per 1 standard lot on:
1) US500, US30, NAS100 is always 1 USD
2) AUS200 is always 1 AUD
3) GER30, FRA40 is always 1 EUR
4) UK100 is always 1 GBP

It doesn't matter if you're trading it today, tomorrow, yesterday, the current bar, or the previous bar.

The pip value doesn't change.

 


@firemyst

firemyst
01 Dec 2020, 03:49

RE: RE:

Adal said:

PanagiotisCharalampous said:

Hi Adal,

You need to remove the indicator from the chart, rename it in the Indicators list in cTrader Automate, build and then add it again.

Best Regards,

Panagiotis 

Join us on Telegram

How I write in the question I need to hide or present another indicator name. Is it possible?

From what @Panagiotis  said, it does not seem possible. You have to have the same indicator name as it's called in the Automate section.

 

@Panagiotis , is it possible to have the listing of the parameters on the chart itself? See the OP's original post. It has "(secret1, secret1), NAN" across the indicator area. Can this be "hidden" somehow?

 


@firemyst

firemyst
29 Nov 2020, 10:05

To hide the name of the indicator, you'll have to call it something different. cTrader takes the name off of whatever name you give the indicator when you create the new one in the Automate section of cTrader.

 

To hide the parameters, you have to do something like the following:

//Change from this
[Parameter("Password1", DefaultValue = "secret1")]
public string Pass1 { get; set; }
[Parameter("Password2", DefaultValue = "secret1")]
public string Pass2 { get; set; }


//To this:
//[Parameter("Password1", DefaultValue = "secret1")]
public string Pass1 { get; set; }
Pass1 = "secret1";

//[Parameter("Password2", DefaultValue = "secret1")]
public string Pass2 { get; set; }
Pass2 = "secret1";

The parameters won't show up in cTrader, but with them set to "public", anyone who's importing your calgo file can see the properties "Pass1" and "Pass2" and access them.

If you want to hide them so they can't be seen outside the class file, change them from public to private.

 


@firemyst

firemyst
29 Nov 2020, 10:01

I don't believe the BBW indicator comes native to cTrader, so you can't add it like you do the BB's.

You have to do something like the following:

 

Bbw = new BollingerBandsWidth(); //this could vary depending on the class
Bbw = Indicators.GetIndicator<BollingerBandsWidth>( [whatever the parameters are for the custom BBW indicator you have] );

 


@firemyst

firemyst
29 Nov 2020, 09:57

How did you "try" adding a trailing stop loss?

The simple way to do it is:

 position.ModifyTrailingStop(true);

or

 position.ModifyTrailingStop(false);

 

 

 


@firemyst

firemyst
24 Nov 2020, 09:56

If it's a "point a pip", then -2.1 pip SL would place it above the chart because it would be at roughly 45.15, which is 2.1 pips above 43.05.

 

Different brokers also do different sizes for pips.

Example: IC Markets with forex -- if you put "20" for a stop loss, that's the equivalent of "2" when using Pepperstone for the exact same currency.

 


@firemyst

firemyst
24 Nov 2020, 09:46

Not sure what you're asking?

When you first enter a trade, typically you're negative a few pips depending on your spread.


@firemyst

firemyst
23 Nov 2020, 04:04

Can't you just use a simple formula such as:

 

(starting price - current price) / (starting price time - elapsed time)

 

??


@firemyst

firemyst
22 Nov 2020, 14:41

I am experiencing the same issue too, so you are not alone.

 

I wonder if it has anything to do with this forum being hacked from all the spam messages being posted?


@firemyst

firemyst
11 Nov 2020, 14:10

Link on Spotware's site on how to include custom indicators witihn indicators. It's the same for bots.


@firemyst

firemyst
05 Nov 2020, 14:20

RE:

ctid2032775 said:

Dear Panagiotis,

I know that there is a way to programmatically Stop() a cBot. But is there a way to "restart" a cBot, as well?

The reason of my question is that one of my cBots uses an automatic optimization method when started and a "drop-out" scenario under certain conditions. It would be great to just restart the cBot if those conditions are met instead of implement a second optimization logic for this case...

Many thanks and best regards,
Christian

Why "stop" and "Start" the bot?

I think a good work around in your case is to just set a global boolean flag.

Call it "bool _dropOut" and when the bot first starts, set it to "false".

In your OnTick and OnBar methods, check the flag before you do anything.

Eg:

protected override void OnTick()
{
    if (!_dropOut)
    {
       //do your normal ontick code logic
    }
    else
    {
        //check for the conditions to set _dropOut = false
    }
}

protected override void OnBar()
{
    if (!_dropOut)
    {
       //do your normal onbar code logic
    }
}

 

Your bot will always be running, it won't execute any OnTick or OnBar code unless set to false.

thus, no need to worry about stopping and restarting.

Easy peazy :-)

 


@firemyst

firemyst
19 Oct 2020, 04:03

RE: RE: RE:

prosteel1 said:

firemyst said:

caglar_G said:

What is the best method for initating a wait for a bot, example: The bot made a trade and closed, after closing you want it to wait for an x amount of time. Is threading.sleep sufficient?

I'd rather not use threading.sleep as it basically suspends the bot for a set amount of time, I might want the bot to do some calulations in the meantime. Is there an alternative to threading.sleep to achieve something like that? Thanks!  

You have multiple options depending on how you want to wait.

Example #1: you want to wait until a new bar is opened. That's easy. Just create a bool flag such as "closedThisBar". In your Positions_Closed event method, set "closedThisBar" to true. In the OnBar method, set "closedThisBar" to false. Then whenever you're wanting to open a position, check the flag before opening the position.

eg, if (!closedThisBar) { OpenPosition.... }

 

Example #2: you want to wait x-minutes/second. That's a bit more involved, but not difficult. Use the timer. In the timer event method, when the number of seconds/minutes has passed, again set a flag to indicate it's ok to open positions again.

 

Example #3: you want to wait x-ticks. Similar to #1 except you also need a variable to count the number of ticks. When a position is closed, reset your tick count to zero. When your tick count reaches your set threshold, set the boolean flag to true so you can open positions again.

 

That's just 3 ways off the top of my head.

Hope it helps :-)

I like your Example #1 solution, as waiting for the current bar to close before opening a new trade if the last trade closed in loss is something I've been wanting to impliment, this is how I would do it that can run OnTick and use a different timeframe to the chart timeframe.

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter("Timeframe0", DefaultValue = "Hour4")]
        public TimeFrame tf0 { get; set; }
        int i = 0;
        protected override void OnStart()
        {
            Positions.Closed += PositionsOnClosed;
        }

        protected override void OnTick()
        {
            // Insert code to only run after count is larger than the count when the last position was closed
            Bars series = MarketData.GetBars(tf0);
            if (i == 0 || i < series.Count - 1)
            {
                // Insert normal Trading code
                Print("series.Count - 1 = " + (series.Count - 1));
            }
            else
            {
                // Insert other Calculations
            }
        }
        private void PositionsOnClosed(PositionClosedEventArgs args)
        {
            // Get Bars on the specified timeframe then write the current bar to i
            Bars series = MarketData.GetBars(tf0);
            int i = series.Count - 1;
        }
        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 

Doing a quick read of your code, I see a few potential issues:

1) you declare the variable "i" twice in two different scopes. You have it at the class level, and then also within the PositionsOnClosed method. This could be your intention. However, the value for the variable "i" in PositionsOnClosed will never be the same as the value for "i" declared under the TimeFrame class variable.

2) Why do you do this multiple times?

Bars series = MarketData.GetBars(tf0);

Every time a tick comes in or a position is closed, your bot has to wait (and could be a while!) for ALL bar data to load!

You should declare "series" at the class level, and initialize it ONCE in the "OnStart" method. Then you can reference it anywhere else in the bot, and you won't slow down your bot on every tick waiting for all the data to constantly load over and over again.

Your code rewritten quickly (may contain errors as I'm not in front of a compiler or cTrader):

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter("Timeframe0", DefaultValue = "Hour4")]
        public TimeFrame tf0 { get; set; }

	//why are you doing this twice? you declare it here and in "PositionsOnClosed". 
        int i = 0;

	//Declare once!
	Bars series;

        protected override void OnStart()
        {
		//
		//Just call it once.
		//"series" will henceforth always be updated with the latest every time a new bar is created.
		//
            series = MarketData.GetBars(tf0);

	//You can also include multiple time frames and initalize each one once
	//    series2 = MarketData.GetBars(tf1);
	//etc etc
	//just declare the variables at the higher class level scope as shown above and then 
	//you can reference anywhere in your code below.

            Positions.Closed += PositionsOnClosed;
        }

        protected override void OnTick()
        {
            // Insert code to only run after count is larger than the count when the last position was closed

		//
		//This "i" will always be zero because that's what you set it to up above. 
		//
            if (i == 0 || i < series.Count - 1)
            {
                // Insert normal Trading code
                Print("series.Count - 1 = " + (series.Count - 1));
            }
            else
            {
                // Insert other Calculations
            }
        }
        private void PositionsOnClosed(PositionClosedEventArgs args)
        {
            // Get Bars on the specified timeframe then write the current bar to i

		//
		//why are you declaring i twice in two different scopes? 
		//The value for "i" here won't be the same as "i" used in "OnTick" because that "i" is the class scope.
		//
            int i = series.Count - 1;
        }
        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 


@firemyst

firemyst
18 Oct 2020, 17:45

Easiest way is to multiply the ATR value by a fixed value, such as 100 or 1000 so its values are around the same as the tick volumes.


@firemyst