Volume ROC indicator Results don't make sense to me.

Created at 25 Mar 2021, 02:54
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!
3E

3eunguyen

Joined 24.02.2021

Volume ROC indicator Results don't make sense to me.
25 Mar 2021, 02:54


Sorry for the noob question.

I'm running this cBot, where I just print the last value of the VolumeROC indicator to the log. When I backtest it and compare it to the value of the exact same indicator that I display on my chart, I get completely different values. It keeps printing negative numbers around -80 and -99 in the log.


@3eunguyen
Replies

amusleh
25 Mar 2021, 10:11

RE:

3eunguyen said:

Sorry for the noob question.

I'm running this cBot, where I just print the last value of the VolumeROC indicator to the log. When I backtest it and compare it to the value of the exact same indicator that I display on my chart, I get completely different values. It keeps printing negative numbers around -80 and -99 in the log.

Can you post your cBot code here? the Volume ROC can go in negative side.


@amusleh

3eunguyen
25 Mar 2021, 21:46

RE: RE: VolumeROC only works OnTick()

amusleh said:

3eunguyen said:

Sorry for the noob question.

I'm running this cBot, where I just print the last value of the VolumeROC indicator to the log. When I backtest it and compare it to the value of the exact same indicator that I display on my chart, I get completely different values. It keeps printing negative numbers around -80 and -99 in the log.

Can you post your cBot code here? the Volume ROC can go in negative side.

 

It's good, turns out VolumeROC won't work if you run it inside OnBar(), it has to be OnTick(). That kinda sucks, I hope it doesn't affect all volume indicators.

//Doesn't Work  

protected override void OnBar()
        {
            Print(vRoc.Result.LastValue);
        }

//Works

protected override void OnTick()
        {
            Print(vRoc.Result.LastValue);
        }


@3eunguyen

amusleh
26 Mar 2021, 08:52

RE: RE: RE: VolumeROC only works OnTick()

3eunguyen said:

amusleh said:

3eunguyen said:

Sorry for the noob question.

I'm running this cBot, where I just print the last value of the VolumeROC indicator to the log. When I backtest it and compare it to the value of the exact same indicator that I display on my chart, I get completely different values. It keeps printing negative numbers around -80 and -99 in the log.

Can you post your cBot code here? the Volume ROC can go in negative side.

 

It's good, turns out VolumeROC won't work if you run it inside OnBar(), it has to be OnTick(). That kinda sucks, I hope it doesn't affect all volume indicators.

//Doesn't Work  

protected override void OnBar()
        {
            Print(vRoc.Result.LastValue);
        }

//Works

protected override void OnTick()
        {
            Print(vRoc.Result.LastValue);
        }

The OnBar is called when a new bar is opened or a previous bar closed, so the last value of indicator series is not completed yet or even maybe not set yet.

Inside OnBar you should not use LastValue, instead use Last(1) which will give you the last completed bar values.


@amusleh