[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Help requested re. Plot and Shift-II



PureBytes Links

Trading Reference Links

The following code is what I was able to come up with. I will be very
grateful if someone can please examine the following for (a) logic and (b)
IF the logic is correct, the coding accuracy. Insofar as I can determine for
periods less than 99 the code seems to be working OK but it gets messed up
if the periods exceed 99.

TIA

Regards


Rakesh


==================================================
The first function is supposed to compute the appropriate value based on the
number of periods. The purpose of the second function is to ascertain the
number of periods to be used in the Shift part of the Plot statement.

function prv_cls_val(p,periods)

{

LookBk_pds=IIf(periods>99,((int(periods/2)+1)-50),int(periods/2)+1);

Plot_val=Ref(C,-1*LookBk_pds);

return Plot_val;

}

function prv_cls_shft_pds(periods)

{

Shft_PDs=IIf(periods>99,50,(int(periods/2)+1));

return shft_pds;

}


==================================================
On 1/9/07, Rakesh Sahgal <rakeshsahgal@xxxxxxxxx> wrote:
>
> I am trying to plot the close value of a prior period. Plotting the same
> using the Ref function is easy. Using the shift feature available in the
> plot statements to plot it is proving to be an unsolvable problem for me.
>
>
> The value to be plotted is based on the value of n and is computed as
> follows
>
> Shift_Pds=int(n+1)/2;
>
>
> PriorCls=ref(c,-1*Shift_pds); //this is vry simple if I settle for using
> the Ref function
>
> The tricky bit that I am not able to think through is - How do I shift the
> value for today such that:
>
> (i) If n < 100 then all the values subsequent to the value for today are
> plotted on the right of the last bar, and
>
> (ii) If N>100  then 50 values subsequent to the value for today  are
> plotted on the right of the last bar.
>
>
>
>
> TIA for any input on solving this problem.
>
>
> Regards
>
>
> R
>

Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.9/622 - Release Date: 1/10/2007 2:52 PM