Continuation post of John R’s topic from old Share Wealth Systems Forum: http://www.sharewealthsystems.com/forum/index.php/topic,3526.120.html

Please continue the discussion below.

Continuation post of John R’s topic from old Share Wealth Systems Forum: http://www.sharewealthsystems.com/forum/index.php/topic,3526.120.html

Please continue the discussion below.

Have spent a couple of days trying to get this to work, it’s a Normalisation indicator and the original code is within the parenthesis brackets.

My intention will be to get 5 to 10 stocks from New Entries scans plugged into and displayed in a single indicator panel through ‘input()’. I can then have a number of indicator panels in one chart.

But first would like to get the code working. Although have tried to rectify the ValueWhen error, having done plenty of research on Metastock forum, and swapping the code around I still can’t get it working.

The BC error:

-> VALUEWHEN function has invalid number of arguments

*{ Normalised price Indicator for equal comparison of stocks }*

*{ NP = ((PR - BASE) / BASE) * 100 ; where BASE is the base price at the date specified }*

BASE_DATE:= DayOfMonth()=1 AND Month()=7 AND Year()=2019;

BASE := ValueWhen(1, BASE_DATE);

NP := ((CLOSE - BASE) / BASE)*100;

NP;

Thanks in advance.

Hi John,

You need to specify what price point the ValueWhen() function is going to use. i.e. High, Low, Close, Open.

Try this:

BASE := ValueWhen(1, BASE_DATE, C);

Regards,

Vincent.

Thanks that did the trick.

Secondly with same formula, if the first part (Stock0) is for example $XSO underlying price chart, that when adding additional stocks (Stock1) to the formula indicator panel, why it wouldn’t plot a line to represent Stock1’s price data?

BASE_DATE:= DayOfMonth()=1 AND Month()=4 AND Year()=2020;

STOCK0 := ValueWhen(1, BASE_DATE,C);

NP0 := ((CLOSE - STOCK0) / STOCK0)*100;

NP0;

STOCK1 := Security("$BSL.XASX",C);

BASE1 := ValueWhen(1, BASE_DATE, STOCK1);

NP1 := ((C - BASE1) / BASE1)*100;

NP1;

Thanks again,

ps. if you can get this to work it’s all I will need as adding a few more stocks will be easy.

Hi John,

Looks like you haven’t used the right Code for BSL in your security function.

Try this:

STOCK1 := Security(“BSL.XASX”,C);

You need to ensure the security codes are 100% correct otherwise BCFL will just return “0” for that function.

Please note, all the indicators in your formula will be output into one panel. You will need to apply your formula to a chart, then manually separate the indicators to individual panels and save it as an overlay if you intend to use it frequently.

Regards,

Vince.

Hi all,

I am trying to discover if the most recent weekly high is less than 13 weeks ago.

peakbars: = peakbars ( 1, c, 13 )

COND1: = peakbars <= 13

Firstly, I don’t know what the % Minimum Change is supposed to mean in the syntax for PEAKBARS. I just put 13 to see what happens.

Secondly, it says that I haven’t defined COND1.

I tried using Bill Langford’s program for the Weekly Pivot reversal as a template but I obviously have a long way to go. My programming days using Cobol, RPG2 and Basic have been of no use to me in trying to conquer BCFL.

Any help would be gratefully appreciated.

Kind regards,

John.

I have no idea of what you said!

Hi John,

Looks like the syntax is all muddled up in your code, which would explain the error message of COND1 not being defined.

The use of a semicolon at the end of each condition / line of code is critical for BCFL to understand the independent bits. Otherwise it simply reads it all as one long line.

Peakbars is not the right function for this particular problem either. Try the below formula instead:

REF1 := Ref(HIGH, -13);

COND1 := HIGH < REF1;

COND1;

This code will return TRUE (or a 1) if the most recent weekly high is less than 13 weeks ago, provided it is applied to weekly charts.

Hope this helps.

Kind Regards,

Vince.

Thanks Vince. That has done the trick.

John.