Topics
29 Mar 2019, 03:40
 1099
 3
13 Mar 2019, 00:33
 1500
 2
Replies

a.fernandez.martinez
26 Jun 2019, 19:43

Thanks, how to get the number of Watchlists ?

Watchlists.Count or .Length don't work.


@a.fernandez.martinez

a.fernandez.martinez
26 Jun 2019, 16:24

Problem with mobile is it's too difficult to make a technical analysis :

You need to choose the symbol, then when you are in the symbol page you need to press the full screen button on the graph and only then you an see your technical analysis.

 

You should be able to see it on the symbol page and it should be linked to your pc technical analysis.

 

As long as this is not in the app, the app is useless, atleast for me.


@a.fernandez.martinez

a.fernandez.martinez
26 Jun 2019, 16:13

I tried this and it doesn't work :

            IEnumerable<Watchlist> test = new List<Watchlist>(Watchlists);

            for (int i = 0; i < test.Count(); i++)
            {
                Print(test.ElementAt(i));

            }

 


@a.fernandez.martinez

a.fernandez.martinez
19 Jun 2019, 15:21

Is it dependent on me or on my broker ?


@a.fernandez.martinez

a.fernandez.martinez
19 Jun 2019, 15:17

Hahah I thought of that too, is there a way to know which version we have ? how to update without uninstalling and reintalling everything ?


@a.fernandez.martinez

a.fernandez.martinez
19 Jun 2019, 15:12 ( Updated at: 21 Dec 2023, 09:21 )

RE:

Panagiotis Charalampous said:

Hi a.fernandez.martinez,

Here is an example

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

        protected override void OnStart()
        {
            foreach (var watchlist in Watchlists)
            {
                foreach (var symbol in Symbols)
                    Print(watchlist.Name + " - " + symbol);
            }
        }

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

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

Best Regards,

Panagiotis

 

It doesn't work for me :( :

It's like Watchlists doesn't exist...


@a.fernandez.martinez

a.fernandez.martinez
19 Jun 2019, 15:03 ( Updated at: 21 Dec 2023, 09:21 )

RE:

Panagiotis Charalampous said:

Hi a.fernandez.martinez,

Can you post a code sample showing how you are using Watchlists?

Best Regards,

Panagiotis

I'm only using the watchlists in the trade mode as you can see below :

I'm looking for a way to get a list or an array of the symbols in a Watchlist, for example the USD MAJOR PAIRS like you can see in the picture.

For the USD MAJOR PAIRS watchlist, the string array could be something like :

USDMAJORPAIRS[0] = "GBPUSD";

USDMAJORPAIRS[1] = "USDJPY";

USDMAJORPAIRS[2] = "USDCAD";

USDMAJORPAIRS[3] = "USDCHF";

USDMAJORPAIRS[4] = "AUDUSD";

USDMAJORPAIRS[5] = "NZDUSD";

USDMAJORPAIRS[6] = "EURUSD";

 

But when I type watchlist in the Automate API reference nothing appears (top right corner) :

If I type watchlist in the code cTrader doesn't suggest anything, I tried to type Collections.Watchlist, Chart.Watchlist, Internals.Watchlist, and a lot more but there is no way to find them.

Is there a way to access watchlists from a cbot ?

 

I will also need to use Watchlists related events, like symbol added or watchlist renamed.

 

Thanks,

 

Best regards,


@a.fernandez.martinez

a.fernandez.martinez
22 Apr 2019, 19:11

Thanks Bart works perfect!


@a.fernandez.martinez

a.fernandez.martinez
12 Apr 2019, 21:07

Here's the code :

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
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 BACKTESTING_GOTTAGOFAST : Robot
    {

        [Parameter("Range in seconds", DefaultValue = 3600, MinValue = 60, MaxValue = 86400)]
        public int range { get; set; }


        protected override void OnStart()
        {
        }

        protected override void OnTick()
        {
        }

        protected override void OnStop()
        {
        }





        //////////////////////////////////////////////////////////////////
        ///////////                  CURRENCY                  ///////////
        public static class Currency
        {
            // ---------- Methods

            public static double ExchangeRate(string chartCurrencyPair)
            {
                string accountCurrency = Account.Currency;
                string chartCurrency = chartCurrencyPair.Substring(0, 3);

                if (accountCurrency != chartCurrency)
                {
                    Symbol exchangeSymbol = MarketData.GetSymbol(accountCurrency + chartCurrency);
                    if (exchangeSymbol != null)
                    {
                        return exchangeSymbol.Bid;
                    }

                    else
                    {
                        exchangeSymbol = MarketData.GetSymbol(chartCurrency + accountCurrency);
                        return 1 / exchangeSymbol.Bid;
                    }
                }
                else
                {
                    return 1;
                }
            }

        }
    }
}

 


@a.fernandez.martinez

a.fernandez.martinez
08 Apr 2019, 05:24

I just realised I used Symbol.Bid instead of exchangeSymbol.Bid.

I still have the 3 errors from Account and MarketData, that I can't use for some reason, do I need to pass them to the method instead of using it directly inside ?


@a.fernandez.martinez

a.fernandez.martinez
08 Apr 2019, 05:17

The only solution I found for the moment is run the bot on backtesting first and get the values from the variables you want to pass to the real bot, is there another way to do all in one?


@a.fernandez.martinez

a.fernandez.martinez
08 Apr 2019, 05:08 ( Updated at: 21 Dec 2023, 09:21 )

Here is the image it didn't upload for some reason :


@a.fernandez.martinez

a.fernandez.martinez
04 Apr 2019, 19:49

RE:

Panagiotis Charalampous said:

  1. Why do you have ; before the function body?

That was the cause of the error, sorry it was late I didn't pay attention...........

I'll check twice before posting next time, thanks !


@a.fernandez.martinez

a.fernandez.martinez
29 Mar 2019, 13:13

I was tired yesterday what I meant was this :

if (current tick open time != previous tick open time && difference between current tick bid and previous tick bid > 0.0001)
               {
               }

 


@a.fernandez.martinez

a.fernandez.martinez
29 Mar 2019, 03:44

it doesn't work very well at higher timeframe due to the pip difference condition


@a.fernandez.martinez

a.fernandez.martinez
21 Mar 2019, 17:57

yes no problem I just wanted to know


@a.fernandez.martinez

a.fernandez.martinez
18 Mar 2019, 11:36

int marketSeriesCloseLength = MarketSeries.Close.Count;

I meant to do this : int marketSeriesCloseLength = mathTimeframe.Close.Count

*facepalm*

I made the change and it looks like it works, I'll double check this evening, thanks a lot (again) !

 

for (int i = marketSeriesCloseLength - 1; i >= 1; i--)
{

I'm looping through all the close prices for the selected timeframe beginning by the end.

However now that you point it out, I realise I can just loop from the beginning, I'll make the change.

 


@a.fernandez.martinez

a.fernandez.martinez
17 Mar 2019, 17:04 ( Updated at: 21 Dec 2023, 09:21 )

The first Image with better quality :

 

Data type is : Tick Data from the Server (accurate)


@a.fernandez.martinez

a.fernandez.martinez
17 Mar 2019, 00:02

I solved the problem by making a class instead of a struct


@a.fernandez.martinez

a.fernandez.martinez
16 Mar 2019, 03:29

I tried to do it outside of the loop like this :

 

bool isFirstTick = true;

TickData currentData;
currentData.Time = Server.Time;
currentData.Ask = Symbol.Ask;
currentData.Bid = Symbol.Bid;
currentData.Variation = 0;
            if (isFirstTick)
            {
                currentData.SetVariation(0, 0);
                isFirstTick = false;
            }
            else
                currentData.SetVariation(currentData.Bid, tickRecord[tickRecord.Count - 1].Bid);

tickRecord.Add(currentData);

 

It still didn't work, same results...


@a.fernandez.martinez