Results with variable are incorrect.  [SOLVED]

Questions about MultiCharts and user contributed studies.
brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Results with variable are incorrect.

Postby brunor » 25 Nov 2013

This code calculates the result correctly.
But if I add a variable:
IndTotal = Value19+Value20+Value21+Value22+Value23+Value24+Value25+Value26+Value27+Value28
The results are offset by one period on the scanner (see attached image).
Scanner updates seem to lag a little. Any assistance would be appreciated.

Code: Select all

Var:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 );
//---------------------------------------------------------------------------------------------------------------------------------------
Condition19 = A;
Condition20 = B;
IF Condition19 then
Value19 = 1
Else Value19 = 0;
IF Condition20 then
Value20 = -1
Else Value20 = 0;
//---------------------------------------------------------------------------------------------------------------------------------------
Condition21 = C;
Condition22 = D;
IF Condition21 then
Value21 = 1
Else Value21 = 0;
IF Condition22 then
Value22 = -1
Else Value22 = 0;
//---------------------------------------------------------------------------------------------------------------------------------------
Condition23 = E;
Condition24 = F;
IF Condition23 then
Value23 = 1
Else Value23 = 0;
IF Condition24 then
Value24 = -1
Else Value24 = 0;
//---------------------------------------------------------------------------------------------------------------------------------------
Condition25 = G;
Condition26 = H;
IF Condition25 then
Value25 = 1
Else Value25 = 0;
IF Condition26 then
Value26 = -1
Else Value26 = 0;
//---------------------------------------------------------------------------------------------------------------------------------------
Condition27 = I;
Condition28 = J;
IF Condition27 then
Value27 = 1
Else Value27 = 0;
IF Condition28 then
Value28 = -1
Else Value28 = 0;
//---------------------------------------------------------------------------------------------------------------------------------------
//IndicatorTotal[4]

Plot1((Value19+Value20+Value21+Value22+Value23+Value24+Value25+Value26+Value27+Value28)[4],"[4]",black);

//-----------------------------------------------------------------------------------------------------------------------------------
//IndicatorTotal[3]

Plot2((Value19+Value20+Value21+Value22+Value23+Value24+Value25+Value26+Value27+Value28)[3],"[3]",black);

//---------------------------------------------------------------------------------------------------------------------------------------
//IndicatorTotal[2]

Plot3((Value19+Value20+Value21+Value22+Value23+Value24+Value25+Value26+Value27+Value28)[2],"[2]",black);

//---------------------------------------------------------------------------------------------------------------------------------------
//IndicatorTotal[1]

Plot4((Value19+Value20+Value21+Value22+Value23+Value24+Value25+Value26+Value27+Value28)[1],"[1]",black);

//-----------------------------------------------------------------------------------------------------------------------------------------------
//IndicatorTotal

Plot5(Value19+Value20+Value21+Value22+Value23+Value24+Value25+Value26+Value27+Value28,"1",black);
Last edited by brunor on 25 Nov 2013, edited 1 time in total.

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: Results with variable are incorrect.

Postby brunor » 25 Nov 2013

Image with description.
Attachments
Scanner.bmp
Image with description.
(910.78 KiB) Downloaded 476 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Results with variable are incorrect.

Postby Henry MultiСharts » 25 Nov 2013

Hello brunor,

Please attach a valid code that can be compiled and will replicate this behavior.

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: Results with variable are incorrect.

Postby brunor » 25 Nov 2013

I will forward this to you off-line.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Results with variable are incorrect.  [SOLVED]

Postby Henry MultiСharts » 29 Nov 2013

Our engineers have studied your code. The reason of this behavior was very simple - you need to do the summation not at the beginning of the code where it operates with the values generated on the previous bar, but after you receive the variable values calculated on the current bar.

brunor
Posts: 65
Joined: 11 Feb 2013
Has thanked: 24 times
Been thanked: 6 times

Re: Results with variable are incorrect.

Postby brunor » 29 Nov 2013

Thank you kindly for your support. Excellent as usual.


Return to “MultiCharts”