Raw spread for backtesting tickdata?

Created at 15 Mar 2021, 12:38
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!
RS

rsoudani

Joined 26.02.2021

Raw spread for backtesting tickdata?
15 Mar 2021, 12:38


Hi, i'm working on my own strategy, looks good on demo account and on firts live tests, but i can not backtest it because i need low spreads, and i have raw spread account on icmarkets, but for backtesting in cTrader i can only get tickdata from server where i cant choose spread and it seems to be much to high (i need tick data not bar data). Do you have any suggestions?


@rsoudani
Replies

amusleh
15 Mar 2021, 12:50

RE:

rsoudani said:

Hi, i'm working on my own strategy, looks good on demo account and on firts live tests, but i can not backtest it because i need low spreads, and i have raw spread account on icmarkets, but for backtesting in cTrader i can only get tickdata from server where i cant choose spread and it seems to be much to high (i need tick data not bar data). Do you have any suggestions?

Hi,

The tick data is from your broker price feed, you can try other brokers cTrader for backtesting and using their tick data. 


@amusleh

prosteel1
15 Mar 2021, 20:19 ( Updated at: 15 Mar 2021, 21:28 )

RE: RE:

amusleh said:

rsoudani said:

Hi, i'm working on my own strategy, looks good on demo account and on firts live tests, but i can not backtest it because i need low spreads, and i have raw spread account on icmarkets, but for backtesting in cTrader i can only get tickdata from server where i cant choose spread and it seems to be much to high (i need tick data not bar data). Do you have any suggestions?

Hi,

The tick data is from your broker price feed, you can try other brokers cTrader for backtesting and using their tick data. 

Are you running your bot using OnTick() as opposed to OnBar()? Running OnBar() instread of OnTick() might result in what you are describing.

Most cBots have 3 main methods:

OnStart()

OnTick()

OnStop()

Do you have these? Or do you have..

OnStart()

OnBar()

OnStop()

I use a condition to check if the channel height (ChHt) is large enough compared to the spread: (ChHt > 2 * (Symbol.Ask - Symbol.Bid))

This eliminates charts during high spread events like on the market open in order to ensure there is a small of risk to return. I also keep track of the channel height of successful trades during a backtest and store the highest value which is also as a check to eliminate big gaps creating huge charts that block trades. I run a backtest once to get the highest successful chart height and then run it a second time so that huge charts resulting from gaps are eliminated the second time I do a backtest.

I love ICMarkets data fyi.  From what I have seen it looks like the live spread when using the backtesting setting > Data > 'Tick data from server (accurate') does provide accurate spread, but I haven't verified it. I use the above methods to eliminate high spreads so I don't trade them.

There might be other methods to eliminating trading during high spreads, these are what I use.

Are you consistantly using Symbol.Bid and Symbol.Ask instead of LastBar.High or whatever the old crew use now days. When you are targeting spread as a metric and running OnTick, Symbol.Bid and Symbol.Ask is where it needs to be to use the tick data and thus get the accurate spread. I struggled with this for a while too.

^While I say consistantly reference Symbol.Bid and Symbol.Ask, I do use HighPrices and LowPrices etc for analysis, but then switch to Symbol.Bid and Symbol.Ask for updating OnTick() - this ensures that I am using the latest data for updates while using aggregated data for analysis.

I hope this helps, feel free to ask further questions :)


@prosteel1

rsoudani
15 Mar 2021, 21:16

RE: RE: RE:

prosteel1 said:

amusleh said:

rsoudani said:

Hi, i'm working on my own strategy, looks good on demo account and on firts live tests, but i can not backtest it because i need low spreads, and i have raw spread account on icmarkets, but for backtesting in cTrader i can only get tickdata from server where i cant choose spread and it seems to be much to high (i need tick data not bar data). Do you have any suggestions?

Hi,

The tick data is from your broker price feed, you can try other brokers cTrader for backtesting and using their tick data. 

I use a condition to check if the channel height (ChHt) is large enough compared to the spread: (ChHt > 2 * (Symbol.Ask - Symbol.Bid))

This eliminates charts during high spread events like on the market open in order to ensure there is a small of risk to return. I also keep track of the channel height of successful trades during a backtest and store the highest value which is also used as a check to eliminate big gaps creating huge charts that block trades. I run a backtest once to get the highest chart height and then run it a second time so that huge charts resulting from gaps are eliminated the second time I do a backtest.

I love ICMarkets data fyi.  From what I have seen it looks like the live spread when using the backtesting setting > Data > 'Tick data from server (accurate') does provide accurate spread, but I haven't verified it. I use the above methods to eliminate high spreads so I don't trade them.

There might be other methods to eliminating trading during high spreads, these are what I use.

Are you running your bot using OnTick() as opposed to OnBar()? Running OnBar() instread of OnTick() might result in what you are describing.

Are you consistantly using Symbol.Bid and Symbol.Ask instead of LastBar.High or whatever the old crew use now days. When you are targeting spread as a metric and running OnTick, Symbol.Bid and Symbol.Ask is where it needs to be to use the tick data and thus get the accurate spread. I struggled with this for a while too.

 

Thank you for the answer! I use both OnBar and OnTick methods in my code, and I use Symbol.Bid and Symbol.Ask as you suggest but did not take channel height into account. For the sake of clarity, could you please specify how do you calculate / where you get channel height?


@rsoudani

prosteel1
15 Mar 2021, 22:38 ( Updated at: 15 Mar 2021, 22:47 )

RE: RE: RE: RE:

rsoudani said:

prosteel1 said:

amusleh said:

rsoudani said:

Hi, i'm working on my own strategy, looks good on demo account and on firts live tests, but i can not backtest it because i need low spreads, and i have raw spread account on icmarkets, but for backtesting in cTrader i can only get tickdata from server where i cant choose spread and it seems to be much to high (i need tick data not bar data). Do you have any suggestions?

Hi,

The tick data is from your broker price feed, you can try other brokers cTrader for backtesting and using their tick data. 

I use a condition to check if the channel height (ChHt) is large enough compared to the spread: (ChHt > 2 * (Symbol.Ask - Symbol.Bid))

This eliminates charts during high spread events like on the market open in order to ensure there is a small of risk to return. I also keep track of the channel height of successful trades during a backtest and store the highest value which is also used as a check to eliminate big gaps creating huge charts that block trades. I run a backtest once to get the highest chart height and then run it a second time so that huge charts resulting from gaps are eliminated the second time I do a backtest.

I love ICMarkets data fyi.  From what I have seen it looks like the live spread when using the backtesting setting > Data > 'Tick data from server (accurate') does provide accurate spread, but I haven't verified it. I use the above methods to eliminate high spreads so I don't trade them.

There might be other methods to eliminating trading during high spreads, these are what I use.

Are you running your bot using OnTick() as opposed to OnBar()? Running OnBar() instread of OnTick() might result in what you are describing.

Are you consistantly using Symbol.Bid and Symbol.Ask instead of LastBar.High or whatever the old crew use now days. When you are targeting spread as a metric and running OnTick, Symbol.Bid and Symbol.Ask is where it needs to be to use the tick data and thus get the accurate spread. I struggled with this for a while too.

 

Thank you for the answer! I use both OnBar and OnTick methods in my code, and I use Symbol.Bid and Symbol.Ask as you suggest but did not take channel height into account. For the sake of clarity, could you please specify how do you calculate / where you get channel height?

Hi rsoudani,

              Nice! seems you are asking the right questions and coding using the right tools too. 

              I've been trying to find a good video to explain my method but can't find one atm. I'll keep looking for a good example, this one might suffice and explains the current moves on EUR/USD. Need to turn on closed captions and set the autotranslation to your language. 

 Basically, a channel is a consolidation channel - a move from a high to a low or visaversa. Since this is how I construct my chart heights it makes sense to discount charts when the spread is very high. As when I try to trade on charts when the spread is very high I usually get stopped out very quickly - so now I prevent most of those.

It's largely a matter of if the spread is larger than a percentage of  risk (also known as the potential loss or return - it doesn't make sense to be entering a trade where for a long trade, if the bid is at the entry level and the ask is at the take profit 2 level, we enter and immediately get profit stopped for zero profit - so we start with a sanity check and extend it to make sure the bot doesn't make silly trades :)


@prosteel1