Average Spread During Previous Week

Created at 09 Jan 2015, 19:01
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!
deklin's avatar

deklin

Joined 31.12.2014

Average Spread During Previous Week
09 Jan 2015, 19:01


How can I get the average spread value from the previous week?

Something like this, but it should return the average from the previous week:

var averageSpreadFromPreviousWeek = Math.Round(Symbol.Spread[ average from previous week ] / Symbol.PipSize, 2);

 


@deklin
Replies

Spotware
12 Jan 2015, 15:30

var averageSpreadFromPreviousWeek = Math.Round(Symbol.Spread[ average from previous week ] / Symbol.PipSize, 2);

Historical tick data is not available in cAlgo.API. However there is a workaround to retrieve it. You can backtest your cBot in tick data mode and perform all required calculations based on historical Bid and Ask prices.


@Spotware

Drummond360
10 Jan 2018, 22:11

RE:

Spotware said:

var averageSpreadFromPreviousWeek = Math.Round(Symbol.Spread[ average from previous week ] / Symbol.PipSize, 2);

Historical tick data is not available in cAlgo.API. However there is a workaround to retrieve it. You can backtest your cBot in tick data mode and perform all required calculations based on historical Bid and Ask prices.

 

Hi,

Is this answer still relevant?

I'm getting a print statement that doesnt make sense! and it the spread remains this value with every print, it never changes!

03/01/2018 13:25:00.000 |  spread = 9.9999999999989E-05

 

Using this code:

             double _Spread = Symbol.Ask - Symbol.Bid;
            Print(" spread = " + _Spread);

Am I missing something?!??!


@Drummond360

PanagiotisCharalampous
11 Jan 2018, 09:44

Hi Drummond360,

Can you please post the full cBot code so that we can check it? Also let us know on which broker you run this cBot.

Best Regards,

Panagiotis


@PanagiotisCharalampous

Drummond360
11 Jan 2018, 10:51

Hi Panagiotis,

Thank you for the quick reply... After thinking a little more on this I doubt it will fix my problem anyway...

I want my robot to check the spread so that it can provide more realistic backtest results...

However, I now assume that the backtest data is only the Bid price in order to draw the charts, then the user specifies the spread in the backtest parameters which then calculates the ask price... Is this correct?

If so, is there any 'best practice' to mimic realistic spreads in backtesting...

I'm using cAlgo with FxPro which offers the Interbank spread without a markup...

Thanks again for your help,

Drummond360


@Drummond360

Drummond360
11 Jan 2018, 13:44

Sorry ignore my last post, I've just discovered backtesting with tick data to offer more exact results...

 


@Drummond360