Pivot points...from pinescript to AFL

Hello

I am struggling with basic pinescript to AFL conversion... can anyone see the problem with my code?

Below is original pinescript ..

high_cur = 0.0
high_cur := is_newbar('W') ? high : max(high_cur[1], high)

HV = 0.0
HV := is_newbar('W') ? high_cur[1] : HV[1]

And my version of equivalent AFL is below.. does this do same as the pinescript?

TimeFrameSet(inWeekly);
HV= LastValue(Ref(H,-1));
TimeFrameRestore();

Or maybe this?

HV = HHV(H,7);

Thanks in advance

You just need single line of code:

HV = TimeFrameGetPrice("H", inWeekly,-1);

As aside your upper one is incorrect.
Instead:

TimeFrameSet(inWeekly);
HV = Ref(H,-1);
TimeFrameRestore();
HV = TimeFrameExpand(HV, inWeekly, expandFirst);

Recommended careful reading:

2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.