Multiple Symbols

Created at 13 Jul 2015, 21:15
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
BBalazs's avatar

BBalazs

Joined 13.07.2015

Multiple Symbols
13 Jul 2015, 21:15


Hey there!

I'm quite new to C++, so I thought I would seek some help here.

Is there a way to use more than just one symbol's closing price for a calculation?

For example, how would you code this in cAlgo?

(EURUSD(close) + USDJPY(close)) / GBPUSD(close)

Thanks for the help in advance.


@BBalazs
Replies

Makagon
13 Jul 2015, 22:58

+


@Makagon

Makagon
13 Jul 2015, 23:25

Ok, it's easy, use this:

var eurusd = MarketData.GetSeries("EURUSD", TimeFrame.Daily);

var usdjpy = MarketData.GetSeries("USDJPY", TimeFrame.Daily);

var gbpusd= MarketData.GetSeries("GBPUSD", TimeFrame.Daily);

next...

(eurusd.Close(LastResult)+usdjpy .Close(LastResult))/gbpusd.Close(LastResult)


@Makagon

BBalazs
14 Jul 2015, 08:20

Thank you for the quick response, you helped me a great deal :)


@BBalazs

BBalazs
14 Jul 2015, 08:40

It works like magic, but I wonder, is there a way to not just refer to the close of the Day?

If I switch to the H4 for example, I want the indicator to calculate the results based on the close of the h4 bar, not the daily. Same goes for the Weekly or whatever TF.


@BBalazs

Spotware
14 Jul 2015, 11:02

Dear Trader,

You can use the Timeframe without selecting one of the supported timeframe values.It will return you the timeframe used in the current instance.

The following code snippet illustrates it.

       TimeFrame time = TimeFrame;

        Print(time.ToString());

We hope this helps you.

Please note that we do not provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You also can contact one of our Partners or post a job in Development Jobs section for any coding assistance.


@Spotware

BBalazs
14 Jul 2015, 11:24

Okay, I'm sorry if I broke any rules. Is there a site or book you would recommend to learn the basics of programming in C++ / cAlgo?


@BBalazs

BBalazs
14 Jul 2015, 11:37

Nevermind, I got it. Found it in the 'What's new' section.


@BBalazs

Spotware
14 Jul 2015, 11:43

RE:

BBalazs said:

Okay, I'm sorry if I broke any rules. Is there a site or book you would recommend to learn the basics of programming in C++ / cAlgo?

Dear BBalazs,

Please take a look at API Programmer's Guides, to our API Reference section and at this thread: /forum/cbot-support/5688?page=1#5


@Spotware