Australian (ASX) Stock Market Forum

Joined
22 February 2022
Posts
7
Reactions
5
I have been having trouble finding a way to save previous values on afl.
Eg.

A = AA == AB;
A_Price = valuewhen(A,C);

How do i get the previous A_Price values?
 
I have been having trouble finding a way to save previous values on afl.
Eg.

A = AA == AB;
A_Price = valuewhen(A,C);

How do i get the previous A_Price values?
Hi @WooBack,

I'm not strong on afl but see if the suggestion below works any better.

A_Price = ValueWhen(A,C,2);

ValueWhen - get value of the array when condition met
SYNTAXValueWhen(EXPRESSION, ARRAY, n = 1)
EXAMPLEvaluewhen( cross( close, ma(close,5) ) ,macd(),

Cheers, Rob
 
I have been having trouble finding a way to save previous values on afl.
Eg.

A = AA == AB;
A_Price = valuewhen(A,C);

How do i get the previous A_Price values?
Not entirely clear on what you're trying to achieve so apologies if my response is wrong.

To get previous A_Price value you can declare it as an array and then simply call ref(APrice, -n), where -n is the "lookback bar count" for how far back you want to retrieve the value of A_Price
 
Hi @WooBack,

I'm not strong on afl but see if the suggestion below works any better.

A_Price = ValueWhen(A,C,2);

ValueWhen - get value of the array when condition met
SYNTAXValueWhen(EXPRESSION, ARRAY, n = 1)
EXAMPLEvaluewhen( cross( close, ma(close,5) ) ,macd(),

Cheers, Rob
Thanks Rob this helped!
 
Not entirely clear on what you're trying to achieve so apologies if my response is wrong.

To get previous A_Price value you can declare it as an array and then simply call ref(APrice, -n), where -n is the "lookback bar count" for how far back you want to retrieve the value of A_Price
Thanks!
 
First off, im not sure if this is the right place to post this question. If it belongs somewhere else please move it.

for you who are using Amibroker, after you have placed your buys, how do you keep track of when to sell in Amibroker?
the issue i have is that i run an Exploration, find my buys but im not sure on how to keep track of them. I have a trailing stoploss and a max stoploss but for some reason the stoploss plot doesnt always show up on the chart. If i run the Exploration only one in a few show, in a backtest scan with the same rules the stoploss shows up more often than not. Im guessing there is a better way t keep track of your buys. Maybe code everything in an Exploration including the stoploss triggers, that way, all i need to do is run an Exploration and i can have all the info there, no need to look at the charts.
what are your thoughts on this?
Wondering if anyone can help with the above issue. Thanks in advance to the helpful Amibroker lot.
 
Top