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
21 Apr 2020, 10:00

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Che vuoi dire? Può darci un esempio?

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

 

in this program the stop loss is not changed.

I don't understand where the error is


@luca.tocchi

luca.tocchi
14 Apr 2020, 11:48

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

È possibile utilizzare le serie di dati Bars.OpenPrices. Se avete del aperto prezzo 10 candele prima, si dipicchino Bars.OpenPrices[Bars.OpenPrices.Count - 10].

Migliori saluti

Panagiotis 

Comi a noi su Telegram

 

Grazie

 


@luca.tocchi

luca.tocchi
10 Apr 2020, 15:08

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Per prima cosa devi spiegarci cosa significa la posizione take stop loss.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

I wanted to know what the instruction was to say that my position is closed by the stop loss

 

thanks


@luca.tocchi

luca.tocchi
09 Apr 2020, 12:30

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Salvare il simbolo utilizzato in una variabile globale e utilizzarlo per il calcolo delle variabili di arresto finali.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

thanks for the advice and for your patience


@luca.tocchi

luca.tocchi
09 Apr 2020, 12:24

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Ti sembra di scambiare su un altro simbolo, ma si utilizzano i valori del simbolo del grafico per calcolare il trailing stop loss. Questo è ovviamente sbagliato.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

How can I solve the problem?
sorry but I'm learning to program


@luca.tocchi

luca.tocchi
09 Apr 2020, 12:24

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Ti sembra di scambiare su un altro simbolo, ma si utilizzano i valori del simbolo del grafico per calcolare il trailing stop loss. Questo è ovviamente sbagliato.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

How can I solve the problem?
sorry but I'm learning to program


@luca.tocchi

luca.tocchi
09 Apr 2020, 12:07

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Il codice viene eseguito solo all'avvio. Questo è il motivo per cui non cambia. È necessario inserire l'account di accesso in OnTick().

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

ok i did this, adding the multi symbol.

but it still doesn't work, I miss it so little but I don't understand the mistake

 

 

 

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

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

        [Parameter("Trigger When Gaining", DefaultValue = 1)]
        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();

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

            ExecuteMarketOrder(TradeType.Sell, EURUSD, 20000, "Miaposizione", StopLoss, null);
            _highestGain = Positions[0].Pips;
        }

        protected override void OnTick()
        {
            var position1 = Positions.Find("Miaposizione");
            if (!_isTrailing && position1.Pips >= TriggerWhenGaining)
            {
                _isTrailing = true;
            }
            if (_isTrailing && _highestGain < position1.Pips)
            {
                var newSLprice1 = Symbol.Bid + (Symbol.PipSize * TrailingStopLossDistance);
                if (newSLprice1 < position1.StopLoss)
                {
                    ModifyPosition(position1, newSLprice1, null);
                }
                _highestGain = position1.Pips;
            }

        }
    }
}


@luca.tocchi

luca.tocchi
08 Apr 2020, 18:10

RE:

PanagiotisCharalampous ha detto:

Ciao Luca,

Controlla questa condizione

 if (newSLprice1 > position1.StopLoss)

Se si sta dietro una posizione di vendita SL allora la nuova SL dovrebbe essere inferiore, non superiore.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

I did this test program, but the stop loss is not changed, it remains at -15 pips

 

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

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

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

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

        private double _highestGain;
        private bool _isTrailing;

        protected override void OnStart()
        {
            ExecuteMarketOrder(TradeType.Sell, Symbol, 20000, "Miaposizione", StopLoss, null);
            var position1 = Positions.Find("Miaposizione");

            _highestGain = Positions[0].Pips;
            if (!_isTrailing && position1.Pips >= TriggerWhenGaining)
            {
                _isTrailing = true;
            }
            if (_isTrailing && _highestGain < position1.Pips)
            {
                var newSLprice1 = Symbol.Bid + (Symbol.PipSize * TrailingStopLossDistance);
                if (newSLprice1 < position1.StopLoss)
                {
                    ModifyPosition(position1, newSLprice1, null);
                }
                _highestGain = position1.Pips;
            }
        }
    }
}


@luca.tocchi

luca.tocchi
07 Apr 2020, 09:39

RE:

PanagiotisCharalampous said:

Hi Luca,

Net profit is always reported in your account's currency. If your account is in euro, then Net profit will be in euros as well.

Best Regards,

Panagiotis 

Join us on Telegram

  

I badly explained myself. I meant the instructions to put the take profit and the stop loss in euros instead of in pips


@luca.tocchi

luca.tocchi
05 Apr 2020, 11:15

RE: RE:

firemyst ha detto:

luca.tocchi ha detto:

ciao come posso ottenere il prezzo ask di un certo simbolo?

Il mio programma crea risorse casuali, con Symbol.Ask il bot non prende il simbolo casuale

Grazie

Simbolo mySymbol - Symbols.GetSymbol("AUS200");

doppio sAsk : mySymbol.Ask;

thanks a lot!


@luca.tocchi

luca.tocchi
05 Apr 2020, 11:14

RE: RE:

firemyst ha detto:

luca.tocchi ha detto:

quali sono le dame per dire: Se il sar parabolico è in a?

Grazie

 

bool x : psar.result.last(0) > psar.result.last(1)

thanks


@luca.tocchi

luca.tocchi
31 Mar 2020, 19:04

RE:

PanagiotisCharalampous said:

Hi luca,

You can keep the symbol in a variable. See below

 var symbol = Symbols.GetSymbol("EURUSD");

Best Regards,

Panagiotis 

Join us on Telegram

I am writing here to not open a new question.

if I wanted to associate one or more indicators to the random asset how should I do it?

example: find a random asset for example eurusd. for example, I want to check the stochastic is uphill or downhill, But I would like to check it on the random asset (in this case EURUSD)

 

 if (_stochastic.PercentD.LastValue > _stochastic.PercentK.LastValue)
{

}

if I write like that, he checks the asset I play with

thanks


@luca.tocchi

luca.tocchi
31 Mar 2020, 15:16

RE:

PanagiotisCharalampous said:

Hi luca,

You can keep the symbol in a variable. See below

 var symbol = Symbols.GetSymbol("EURUSD");

Best Regards,

Panagiotis 

Join us on Telegram

thanks a lot!


@luca.tocchi

luca.tocchi
29 Mar 2020, 16:50

RE: RE: RE: RE:

firemyst said:

luca.tocchi said:

firemyst ha detto:

luca.tocchi ha detto:

pot la parte del codice in grassetto?

il programma controlla lo spread, se lo spread è maggiore di max spred deve è aggiunta un ispere e controlla altrimenti deve.

aiutatemi vi prego

 

....

casuale privato - nuovo Random();


protected
override void OnStart() -
_stochastic - Indicators.StochasticOscillator(K_Period,
Slow_K, D_Period, maType);
spread di var - Symbol.Ask - Symbol.Bid; while (spread > MaxSpread) -
Stampa("Spread suck, go in other asset");



Stampa([casuale. Simboli di SuoNeri(Conta)]);
deve aprire un altro punto e che la di spread> verifica sia falsa o stampa:


("Spread Ok");

è questo il mio problema

....

Lo farei in modo non altro'.

Qualcosa lungo le linee di:

bool spreadOK = false;
double spread = 0;
int numberOfSymbols = Symbols.Count
int numberOfSymbolsChecked = 0;

while (!spreadOk && numberOfSymbolsChecked < numberOfSymbols)
{
  Symbol s = Symbols[random.Next(Symbols.Count)];
  spread = s.Ask - s.Bid;
  if (spread <= MaxSpread)
    spreadOk = true;
  numberOfSymbolsChecked += 1;
}

if (!spreadOk)
  Print("Could not find any valid symbols with a good spread.");

 

I did it. But it gives me this error: Error CS0029: Could not implicitly convert type 'string' to 'cAlgo.API.Internals.Symbol'.

what's the problem?

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

        [Parameter("Max Spread", DefaultValue = 1, MinValue = -5.0)]
        public double MaxSpread { get; set; }

        private Random random = new Random();

        protected override void OnStart()
        {
            bool spreadOk = false;
            double spread = 0;
            int numberOfSymbols = Symbols.Count;
            int numberOfSymbolsChecked = 0;


            while (!spreadOk && numberOfSymbolsChecked < numberOfSymbols)
            {
                Symbol s = Symbols[random.Next(Symbols.Count)];
                spread = s.Ask - s.Bid;
                if (spread <= MaxSpread)
                    spreadOk = true;
                numberOfSymbolsChecked += 1;
            }

            if (!spreadOk)
                Print("Could not find any valid symbols with a good spread.");

        }
    }
}

 

The problem is the line:

Symbol s = Symbols[random.Next(Symbols.Count)];

That lines doesn't return a Symbol object, but a string that's the name of the symbol.

You will need to use

Symbols.GetSymbol

to convert the string name to an actual Symbol object.

So first change the line to:

string symbolName = Symbols[random.Next(Symbols.Count)];

and then you need to add in and complete the line:

Symbol s = Symbols.GetSymbol....

 

 

 

   there is still errors...

I didn't understand this very much

 

 [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class spread : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Parameter("Max Spread", DefaultValue = 1, MinValue = -5.0)]
        public double MaxSpread { get; set; }

        private Random random = new Random();

        protected override void OnStart()
        {
            bool spreadOk = false;
            double spread = 0;
            int numberOfSymbols = Symbols.Count;
            int numberOfSymbolsChecked = 0;


            while (!spreadOk && numberOfSymbolsChecked < numberOfSymbols)
            {
                string symbolName = Symbols[random.Next(Symbols.Count)];
                Symbol s = Symbols.GetSymbols(string symbolName);
                spread = s.Ask - s.Bid;
                if (spread <= MaxSpread)
                    spreadOk = true;
                numberOfSymbolsChecked += 1;
            }

            if (!spreadOk)
                Print("Could not find any valid symbols with a good spread.");

        }
    }
}


@luca.tocchi

luca.tocchi
29 Mar 2020, 11:24

RE: RE:

firemyst ha detto:

luca.tocchi ha detto:

pot la parte del codice in grassetto?

il programma controlla lo spread, se lo spread è maggiore di max spred deve è aggiunta un ispere e controlla altrimenti deve.

aiutatemi vi prego

 

....

casuale privato - nuovo Random();


protected
override void OnStart() -
_stochastic - Indicators.StochasticOscillator(K_Period,
Slow_K, D_Period, maType);
spread di var - Symbol.Ask - Symbol.Bid; while (spread > MaxSpread) -
Stampa("Spread suck, go in other asset");



Stampa([casuale. Simboli di SuoNeri(Conta)]);
deve aprire un altro punto e che la di spread> verifica sia falsa o stampa:


("Spread Ok");

è questo il mio problema

....

Lo farei in modo non altro'.

Qualcosa lungo le linee di:

bool spreadOK = false;
double spread = 0;
int numberOfSymbols = Symbols.Count
int numberOfSymbolsChecked = 0;

while (!spreadOk && numberOfSymbolsChecked < numberOfSymbols)
{
  Symbol s = Symbols[random.Next(Symbols.Count)];
  spread = s.Ask - s.Bid;
  if (spread <= MaxSpread)
    spreadOk = true;
  numberOfSymbolsChecked += 1;
}

if (!spreadOk)
  Print("Could not find any valid symbols with a good spread.");

 

I did it. But it gives me this error: Error CS0029: Could not implicitly convert type 'string' to 'cAlgo.API.Internals.Symbol'.

what's the problem?

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

        [Parameter("Max Spread", DefaultValue = 1, MinValue = -5.0)]
        public double MaxSpread { get; set; }

        private Random random = new Random();

        protected override void OnStart()
        {
            bool spreadOk = false;
            double spread = 0;
            int numberOfSymbols = Symbols.Count;
            int numberOfSymbolsChecked = 0;


            while (!spreadOk && numberOfSymbolsChecked < numberOfSymbols)
            {
                Symbol s = Symbols[random.Next(Symbols.Count)];
                spread = s.Ask - s.Bid;
                if (spread <= MaxSpread)
                    spreadOk = true;
                numberOfSymbolsChecked += 1;
            }

            if (!spreadOk)
                Print("Could not find any valid symbols with a good spread.");

        }
    }
}

 


@luca.tocchi

luca.tocchi
27 Mar 2020, 14:01

RE:

PanagiotisCharalampous said:

Hi Luca,

Please stop spamming the forum with the same subject. I have given you guidance on how to program this simple algorithm on another thread. If you cannot program it yourself, you can consider paying somebody to do this for you.

Best Regards,

Panagiotis 

Join us on Telegram

I'm sorry but nobody can help me

 


@luca.tocchi

luca.tocchi
26 Mar 2020, 15:25

RE:

PanagiotisCharalampous said:

Hi Luca,

You can use Symbols.GetSymbol() to get another symbol to check the spread and open a position.

Best Regards,

Panagiotis 

Join us on Telegram

can you put it in my part of the program? So to open a random one?


@luca.tocchi

luca.tocchi
26 Mar 2020, 15:15

RE:

PanagiotisCharalampous said:

Hi Luca,

Here is something quick

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; }

        private Random random = new Random();

        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnTick()
        {
            Print(Symbols[random.Next(Symbols.Count)]);
        }

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

Best Regards,

Panagiotis 

Join us on Telegram

this is part of the code

....

 private Random random = new Random();


        protected override void OnStart()
        {
            _stochastic = Indicators.StochasticOscillator(K_Period, Slow_K, D_Period, maType);

            var spread = Symbol.Ask - Symbol.Bid;

            while (spread > MaxSpread)
            {
                Print("Spread suck, go in other asset");
                Print(Symbols[random.Next(Symbols.Count)]);
                //must open another symbol and verify that the condition of spread> maxspread is true or false
            }

            Print("Spread Ok");

 

is this my problem

 

....


@luca.tocchi

luca.tocchi
26 Mar 2020, 15:08

RE:

PanagiotisCharalampous said:

Hi Luca,

Here is something quick

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; }

        private Random random = new Random();

        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnTick()
        {
            Print(Symbols[random.Next(Symbols.Count)]);
        }

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

Best Regards,

Panagiotis 

Join us on Telegram

but in this case the print only. I need the symbol to open, and see his chart


@luca.tocchi

luca.tocchi
26 Mar 2020, 14:11

RE:

PanagiotisCharalampous said:

Hi Luca,

Indeed it is not very clear what do you mean. But whatever you are trying to do, you should check the example that gives you an idea on how to make random choices using the Random class. You just need to adjust it to your needs. If you want to select a random symbol, then use the Random class to generate a random index for the Symbols collection.

Best Regards,

Panagiotis 

Join us on Telegram

"If you want to select a random symbol, then use the Random class to generate a random index for the Symbols collection."

 

is what I'm looking for ... could I have the code? and a small explanation


@luca.tocchi