Topics
10 Aug 2023, 21:08
 354
 3
10 Aug 2023, 21:08
 385
 1
12 Oct 2020, 10:39
 1268
 2
04 Oct 2020, 21:56
 2892
 7
03 Oct 2020, 15:08
 1319
 4
03 Oct 2020, 14:59
 967
 1
30 Sep 2020, 16:30
 966
 2
30 Sep 2020, 16:20
 984
 3
25 Sep 2020, 11:03
 954
 2
24 Sep 2020, 20:14
 903
 2
16 Sep 2020, 10:25
 2086
 3
31 Aug 2020, 17:03
 1299
 4
29 Jul 2020, 13:59
 873
 2
27 Jul 2020, 21:41
 912
 2
27 Jul 2020, 17:03
 878
 2
Replies

luca.tocchi
22 Jun 2020, 11:35

RE:

PanagiotisCharalampous said:

Hi Luca,

It seems correct to me.

Best Regards,

Panagiotis 

Join us on Telegram

 

the RSI value from the last bar is not 34


@luca.tocchi

luca.tocchi
12 Jun 2020, 16:26

RE:

PanagiotisCharalampous said:

Hi Luca,

Just check with an if or a while statement.

Best Regards,

Panagiotis 

Join us on Telegram

yes, but the condition I don't know what it is

 


@luca.tocchi

luca.tocchi
12 Jun 2020, 16:08

RE:

PanagiotisCharalampous said:

Hi Luca,

You can add a check and request for a new symbol when this one comes up.

Best Regards,

Panagiotis 

Join us on Telegram

I need to know the instruction to do this, thanks a lot!


@luca.tocchi

luca.tocchi
12 Jun 2020, 11:01

RE:

PanagiotisCharalampous said:

Hi Luca,

You can add a check and request for a new symbol when this one comes up.

Best Regards,

Panagiotis 

Join us on Telegram

would be great! what is the instruction to do this?

 

thanks


@luca.tocchi

luca.tocchi
12 Jun 2020, 10:58

RE:

PanagiotisCharalampous said:

Hi Luca,

I tried this but I could not reproduce such an error. If you want to find more about the exception, check here.

Best Regards,

Panagiotis 

Join us on Telegram

 

it does it to me only with EURUSDt

is it possible to insert the instruction that prints symbols at random less than EURUSDt?


@luca.tocchi

luca.tocchi
12 Jun 2020, 10:44

RE:

.


@luca.tocchi

luca.tocchi
11 Jun 2020, 13:12

RE:

ok solved






 


@luca.tocchi

luca.tocchi
11 May 2020, 09:38

RE:

PanagiotisCharalampous said:

Hi Luca,

Which data are you referring to?

Best Regards,

Panagiotis 

Join us on Telegram

everything I printed on "diary"


@luca.tocchi

luca.tocchi
11 May 2020, 09:24

RE:

PanagiotisCharalampous said:

Hi luca,

There is no automatic way to restart a cBot.

Best Regards,

Panagiotis 

Join us on Telegram

 

is there an instruction that erases the data, for example what I printed? so as to lighten the program?

Thanks


@luca.tocchi

luca.tocchi
07 May 2020, 10:58

RE:

luca.tocchi said:

this is my ichimoku-based bot it works, but the OnTick () does not start, and therefore the "trail stop loss" does not start

where is the mistake?

the program works i removed the instructions as i don't want anyone to steal my job. the fact that the trail doesn't start I think it's due to something else

 

 

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 ichimokubot : Robot
    {

        [Parameter("Volume (Lots)", Group = "Volume", DefaultValue = 0.2, MinValue = 0.01, Step = 0.01)]
        public double Volume { get; set; }

        [Parameter("Stop Loss", DefaultValue = 8)]
        public double StopLoss { get; set; }

        [Parameter("Trigger When Gaining", DefaultValue = 0.5)]
        public double TriggerWhenGaining { get; set; }

        [Parameter("Trailing Stop Loss Distance", DefaultValue = 1)]
        public double TrailingStopLossDistance { get; set; }

        private double _highestGain;
        private bool _isTrailing;

        private Random random = new Random();
        private IchimokuKinkoHyo ichimoku;
        private ParabolicSAR parabolicSAR;
        public bool Restart;
        Symbol _symbol;

        protected override void OnStart()
        {
            Inizio:
            RefreshData();

            string EURUSD = Symbols[random.Next(Symbols.Count)];
            Symbols.GetSymbol("EURUSD");
            Print(EURUSD);

            var symbol = MarketData.GetSymbol(EURUSD);

            _symbol = Symbols.GetSymbol(EURUSD);

            ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Minute10, EURUSD), 9, 26, 52);
            parabolicSAR = Indicators.ParabolicSAR(MarketData.GetBars(TimeFrame.Minute10, EURUSD), 0.02, 0.2);

            var EURUSDSeries = MarketData.GetBars(TimeFrame.Minute10, EURUSD);
            var volumeInUnits = symbol.QuantityToVolumeInUnits(Volume);

            var position = Positions.Find("MyLabel");

            while (...)
            {
                if (...)
                {
                    if (....)
                    {
                        if (...)
                        {
                            if (..)
                            {
                                if (s...6)
                                {
                                    if (...)
                                    {
                                        if (..))
                                        {
                                            if (..)
                                            {
                                                if (...)
                                                {
                                                    var result = ExecuteMarketOrder(TradeType.Buy, EURUSD, volumeInUnits, "MyLabel", StopLoss, null);
                                                    _highestGain = Positions[0].Pips;
                                                    if (result.Error == ErrorCode.BadVolume)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Disconnected)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.EntityNotFound)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidRequest)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidStopLossTakeProfit)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.MarketClosed)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.NoMoney)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.TechnicalError)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Timeout)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.UnknownSymbol)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    System.Threading.Thread.Sleep(300000);
                                                    //break;
                                                }
                                                else
                                                {
                                                    goto Inizio;
                                                }
                                            }
                                            else
                                            {
                                                goto Inizio;
                                            }
                                        }
                                        else
                                        {
                                            goto Inizio;
                                        }
                                    }
                                    else
                                    {
                                        goto Inizio;
                                    }
                                }
                                else
                                {
                                    goto Inizio;
                                }
                            }
                            else
                            {
                                goto Inizio;
                            }
                        }
                        else
                        {
                            goto Inizio;
                        }
                    }
                    else
                    {
                        if (...)
                        {
                            if (...)
                            {
                                if (...)
                                {
                                    if (...)
                                    {
                                        if (..)
                                        {
                                            if (..)
                                            {
                                                if (...)
                                                {
                                                    var result = ExecuteMarketOrder(TradeType.Buy, EURUSD, volumeInUnits, "MyLabel", StopLoss, null);
                                                    _highestGain = Positions[0].Pips;
                                                    if (result.Error == ErrorCode.BadVolume)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Disconnected)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.EntityNotFound)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidRequest)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidStopLossTakeProfit)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.MarketClosed)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.NoMoney)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.TechnicalError)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Timeout)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.UnknownSymbol)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    System.Threading.Thread.Sleep(300000);
                                                    //break;
                                                }
                                                else
                                                {
                                                    goto Inizio;
                                                }
                                            }
                                            else
                                            {
                                                goto Inizio;
                                            }
                                        }
                                        else
                                        {
                                            goto Inizio;
                                        }

                                    }
                                    else
                                    {
                                        goto Inizio;
                                    }
                                }
                                else
                                {
                                    goto Inizio;
                                }
                            }
                            else
                            {
                                goto Inizio;
                            }
                        }
                        else
                        {
                            goto Inizio;
                        }
                    }
                }
                else
                {
                    if (...)
                    {
                        if (...)
                        {
                            if (..)
                            {
                                if (...)
                                {
                                    if (...)
                                    {
                                        if (...)
                                        {
                                            if (...)
                                            {
                                                if (...)
                                                {
                                                    var result = ExecuteMarketOrder(TradeType.Sell, EURUSD, volumeInUnits, "MyLabel", StopLoss, null);
                                                    _highestGain = Positions[0].Pips;
                                                    if (result.Error == ErrorCode.BadVolume)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Disconnected)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.EntityNotFound)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidRequest)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidStopLossTakeProfit)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.MarketClosed)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.NoMoney)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.TechnicalError)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Timeout)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.UnknownSymbol)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    System.Threading.Thread.Sleep(300000);
                                                    //break;
                                                }
                                                else
                                                {
                                                    goto Inizio;
                                                }
                                            }
                                            else
                                            {
                                                goto Inizio;
                                            }
                                        }
                                        else
                                        {
                                            goto Inizio;
                                        }
                                    }
                                    else
                                    {
                                        goto Inizio;
                                    }
                                }
                                else
                                {
                                    goto Inizio;
                                }
                            }
                            else
                            {
                                goto Inizio;
                            }
                        }
                        else
                        {
                            goto Inizio;
                        }
                    }
                    else
                    {
                        if (...)
                        {
                            if ()
                            {
                                if ()
                                {
                                    if ()
                                    {
                                        if ()
                                        {
                                            if ()
                                            {
                                                if ()
                                                {
                                                    //La chiusura della penultima candela deve essere a ribasso
                                                    var result = ExecuteMarketOrder(TradeType.Sell, EURUSD, volumeInUnits, "MyLabel", StopLoss, null);
                                                    _highestGain = Positions[0].Pips;
                                                    if (result.Error == ErrorCode.BadVolume)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Disconnected)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.EntityNotFound)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidRequest)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.InvalidStopLossTakeProfit)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.MarketClosed)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.NoMoney)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.TechnicalError)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.Timeout)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    if (result.Error == ErrorCode.UnknownSymbol)
                                                    {
                                                        goto Inizio;
                                                    }
                                                    System.Threading.Thread.Sleep(300000);
                                                    //break;
                                                }
                                                else
                                                {
                                                    goto Inizio;
                                                }
                                            }
                                            else
                                            {
                                                goto Inizio;
                                            }
                                        }
                                        else
                                        {
                                            goto Inizio;
                                        }
                                    }
                                    else
                                    {
                                        goto Inizio;
                                    }
                                }
                                else
                                {
                                    goto Inizio;
                                }
                            }
                            else
                            {
                                goto Inizio;
                            }
                        }
                        else
                        {
                            goto Inizio;
                        }
                    }
                }
            }
            if (Restart == false)
            {
                goto Inizio;
            }
        }
        protected override void OnTick()
        {
            var position = Positions.Find("MyLabel");

            if (position == null)
            {
                Stop();
                return;
            }
            //If the trigger is reached, the robot starts trailing
            if (!_isTrailing && position.Pips >= TriggerWhenGaining)
            {
                _isTrailing = true;
            }
            //If the cBot is trailing and the profit in pips is at the highest level, we need to readjust the stop loss
            if (_isTrailing && _highestGain < position.Pips)
            {
                //Based on the position's direction, we calculate the new stop loss price and we modify the position
                if (position.TradeType == TradeType.Buy)
                {
                    var newSLprice = _symbol.Ask - (_symbol.PipSize * TrailingStopLossDistance);
                    if (newSLprice > position.StopLoss)
                    {
                        ModifyPosition(position, newSLprice, null);
                    }
                }
                else
                {
                    var newSLprice = _symbol.Bid + (_symbol.PipSize * TrailingStopLossDistance);
                    if (newSLprice < position.StopLoss)
                    {
                        ModifyPosition(position, newSLprice, null);
                    }
                }
                //We reset the highest gain
                _highestGain = position.Pips;
            }
        }
        protected override void OnStop()
        {
            //This method is called when the cBot is stopped
            Restart = false;
        }

    }
}

can I have an answer?


@luca.tocchi

luca.tocchi
29 Apr 2020, 12:14

RE:

PanagiotisCharalampous said:

Hi Luca,

As explained in another post, the Ichimoku indicator is projecting results in the future, hence you need to take that into account. Here is an example of how to adjust your indexing so that you can get the indicator value corresponding to the last bar

            var last = ichimoku.SenkouSpanA.Count - Bars.ClosePrices.Count;

            Print("Span A: ", ichimoku.SenkouSpanA.Last(last));
            Print("Span B: ", ichimoku.SenkouSpanB.Last(last));

You will need to adjust your logic based on this fact.

Best Regards,

Panagiotis 

Join us on Telegram

 

Thanks I was unable to resolve. Now yes instead


@luca.tocchi

luca.tocchi
28 Apr 2020, 11:14

RE:

PanagiotisCharalampous said:

Hi Luca,

See an example below

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(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        Symbol _symbol;
        protected override void OnStart()
        {
            _symbol = Symbols.GetSymbol("EURUSD");
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis 

Join us on Telegram

thanks

 


@luca.tocchi

luca.tocchi
27 Apr 2020, 09:25

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

5 è il valore della sesta ultima candela perché l'ultima è 0

Questo non è vero. 5 indica il quinto valore dell'ultimo valore dell'indicatore. Se si nota, l'indicatore Ichimoku stampa alcuni valori in futuro. È necessario prendere in considerazione anche questo.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

oh... now it work

thanks


@luca.tocchi

luca.tocchi
25 Apr 2020, 09:26 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi Luca,

This seems to happen only on symbols that have no data. See an example below

You need to use symbols that have data for this to work.

Best Regards,

Panagiotis 

Join us on Telegram

what do you think is the mistake in this case?


@luca.tocchi

luca.tocchi
24 Apr 2020, 12:34 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi Luca,

This seems to happen only on symbols that have no data. See an example below

You need to use symbols that have data for this to work.

Best Regards,

Panagiotis 

Join us on Telegram

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
    {

        private Random random = new Random();
        private IchimokuKinkoHyo ichimoku;

        protected override void OnStart()
        {
            string EURUSD = Symbols[random.Next(Symbols.Count)];
            Symbols.GetSymbol("EURUSD");
            Print(EURUSD);

            var symbol = MarketData.GetSymbol(EURUSD);

            var index = Bars.ClosePrices.Count - 5;

            ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Minute10, EURUSD), 9, 26, 52);

            Print("Span A: ", ichimoku.SenkouSpanA[index]);
            Print("Span B: ", ichimoku.SenkouSpanB[index]);

        }
    }
}

 

now works

But..

I put: var index = Bars.ClosePrices.Count - 5;

5 is the value of the sixth last candle because the last one is 0

but the SSA and SSB values do not match

the blue line are the value of SSA e SSB


@luca.tocchi

luca.tocchi
24 Apr 2020, 11:35

RE:

PanagiotisCharalampous said:

Hi Luca,

Can you post the complete cBot code?

Best Regards,

Panagiotis 

Join us on Telegram

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 ValoriSpanIchimoku : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        private IchimokuKinkoHyo ichimoku;
        private Random random = new Random();

        protected override void OnStart()
        {
            string EURUSD = Symbols[random.Next(Symbols.Count)];
            Symbols.GetSymbol("EURUSD");
            Print(EURUSD);


            ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Hour, EURUSD), 9, 26, 52);

            var index5 = Bars.ClosePrices.Count - 5;

            Print("Span A: ", ichimoku.SenkouSpanA[index5]);
            Print("Span B: ", ichimoku.SenkouSpanB[index5]);

        }

    }
}


@luca.tocchi

luca.tocchi
24 Apr 2020, 11:13

RE:

PanagiotisCharalampous said:

Hi Luca,

Why do you think there is a problem?

Best Regards,

Panagiotis 

Join us on Telegram

because the values are wrong

and Say "NaN"


@luca.tocchi

luca.tocchi
22 Apr 2020, 11:18

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Probabilmente è lo stesso problema di cui sopra. Se si imposta prezzi di stop loss sbagliato non saranno accettati. Lo stop loss deve essere inferiore al prezzo di ingresso per le posizioni di acquisto e superiore al prezzo di ingresso per le posizioni di vendita.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

oh Ok thanks


@luca.tocchi

luca.tocchi
22 Apr 2020, 11:01

RE:

PanagiotisCharalampous said:

Hi Luca,

This is because you cannot set a stop loss below a sell position's entry price e.g. 0. Note that SL and TP in ModifyPosition are set as prices not as pips. 

Best Regards,

Panagiotis 

Join us on Telegram

can you tell me what is the error please?

Thanks a lot


@luca.tocchi

luca.tocchi
21 Apr 2020, 10:29

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Questo non è possibile è possibile è un stop loss al di del prezzo di una entrata di vendita, posizione ad esempio 0. Si noti che SL e TP in ModifyPosition sono sono modosono come prezzi non come pip.

Migliori saluti

Panagiotis 

Comi a noi su Telegram

I try to change it. but the stop loss is not changed

 

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class esempio : Robot
    {

        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        private Random random = new Random();


        protected override void OnStart()
        {

            string EURUSD = Symbols[random.Next(Symbols.Count)];
            Symbols.GetSymbol(EURUSD);
            Print(EURUSD);
            var EURUSDSeries = MarketData.GetBars(TimeFrame.Minute10, EURUSD);
            var symbol = MarketData.GetSymbol(EURUSD);

            ExecuteMarketOrder(TradeType.Buy, EURUSD, 20000, "Mylabel", 5, null, null, false);
            var Posizione = Positions.Find("Mylabel", EURUSD, TradeType.Buy);
            if (Posizione.Pips >= 0.2)
            {
                ModifyPosition(Posizione, 1, null, false);

            }

        }
    }
}


@luca.tocchi