Indicator on chart not matching value of indicator used by robot at time of trade.

Created at 30 Mar 2016, 03:00
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!
ST

stevie.c

Joined 28.09.2015

Indicator on chart not matching value of indicator used by robot at time of trade.
30 Mar 2016, 03:00


Hi all,

I am using three moving averages and comparing them with their previous values to test in which direction they are moving, using Result.Last (0) and Result.Last(1). Depending on the outcome there will be a buy or sell position closed/opened.

I am printing out the values of the MAs into the backtest log so that I can see which precise values were being tested at the time a trade was placed.

However, I have noticed that the value of my moving averages can be significantly different to those displayed on the chart at the time a position was opened/closed. In some cases, two of the MAs are accurate for the trade time recorded, but the third (which is a slow MA) will be nowhere near the value shown on the chart (and we're talking an H1 chart, and it isn't a case of it being out by two ticks - it is nowhere near at all)

Has anyone else observed this, or can anyone offer any advice if I'm doing something wrong?

Thanks.


@stevie.c
Replies

croucrou
30 Mar 2016, 15:43

Maybe you formulated your "if" conditions improperly and it is satisfied after the second condition is met.

Is it possible to paste that part of the code here?


@croucrou

stevie.c
30 Mar 2016, 20:38

RE:

Thanks for the reply croucrou.

The code is as per the sample trend /algos/cbots/show/8, but with a third MA added, so I don't think it would be the "if" condition, particularly as the value being shown in the log seemingly has no relationship to the chart..?

 


@stevie.c

croucrou
30 Mar 2016, 22:56

All indications are that you have done something wrong while adding the third moving average.

I assumed above, that the positions' execution has been missed and that has been the reason for printing the values. Operator different from "&&" could cause that.

If the positions open and close correctly and only the printed values are wrong, it seems you have not been refering to the values of that moving average or expected bar.

Check carefully the added part of the code, with emphasis on printing line and definition of that moving average (period or bar number).

 


@croucrou

croucrou
31 Mar 2016, 14:08

 Yes, I know I confused it a bit, but anyway, I think there is something wrong with the added part of the code.


@croucrou

stevie.c
01 Apr 2016, 01:11

RE:

croucrou said:

 Yes, I know I confused it a bit, but anyway, I think there is something wrong with the added part of the code.

Hi croucrou - you were correct. Some of my constant defaults were in error. Thanks for taking the time to help me focus.


@stevie.c

croucrou
03 Apr 2016, 20:14

No problem. Great, that you solved your issue.


@croucrou