open random instance

RE:

PanagiotisCharalampous said:

Hi Luca,

Check the Sample Martingale cBot. It has an example on how to execute random orders.

Best Regards,

Panagiotis 

Join us on Telegram

the sample Martingale cBot does not open assets. The "Sample Martingale cBot" creates a random Sell or Buy order only

maybe I got confused.

with instance I mean asset

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

....

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

Head of Community Management at cTrader
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?