Any similar function like Python’s built-in ‘append()’ function?

Hello, everyone. Just a simple question. In Python there is a built in function called ‘append()’. This function is used to add an item to the end of a list. The append() method is a member of the list object, and it is used to modify the contents of an existing list by adding a new element to the end of the list. Is there any similar or equivalent function available in Amibroker? I need this function in to append new pivot point to my list of the peak or trough pivots whenever trend changes the direction. Thanks

How have you implemented your list in AFL?

via a function ( not in built one) I derive pivots of alternating peaks and troughs.

AFL does not have a data structure equivalent to a list in other languages. So are you saving your pivots in an array, a matrix, something else?

If you or anyone knows Python then I can share the code. I asked my friend to code my strategy which I use manually, but he doesn’t know Amibroker’s language, he coded it and its working well, he is using Jupiter notebook and excel to trade, so he was able to code the idea only in Python. He is very happy with the code as it’s working well for the strategy. The only problem is that here in the forum I can’t post it asking for translation, because it’s against the forum rules. And I don’t want to violate any forum rule.

You asked a very specific question (does AFL have an "append" function?), which led me to believe that you already had an AFL implementation of your strategy. It now sounds like that is not the case. If you're not willing/able to create an AFL version of your strategy yourself, then your best option is probably to hire someone who can.

1 Like

I hope that if Mr. Tomaz happen to read this post then perhaps he will built such a function in the future addition of Amibroker. Meanwhile I will keep working on leaning AFL in order to find a way around to code my strategy.

You have not shared any details of what you're trying to accomplish, but it's very likely that you can use an AmiBroker array to achieve your goal. Also, proficiency with arrays is essential to implementing almost anything in AFL, so that would be a good place to focus your efforts as you go through the online help, tutorials, and any other learning resources that you might be using.

1 Like

You can have list, simply using string. Then appending is just a matter of using + operator.

There are hundreds of examples of using such lists in the manual.

// The example below shows how to use negative item
// references (Version 5.20 AND up only!)

tickers = "AAPL,MSFT,INTC";

"The last item is " + StrExtract( tickers, -1 );
printf("listing from the end of the list:n");

for( item = -1; ( sym = StrExtract( tickers, item ) ) != ""; item-- )
  printf( sym + "\n" );

Then appending is

function Append( list, ticker )
    if( list != "" ) list += ",";
    return list + ticker;

Users' Guide:

For what it is worth, you don't need to use comma as separator. Separator can be any character for example '|'

Using such technique you can store both strings and numbers (See NumToStr / StrToNum). Alternatively as @mradkte told you you can use Matrices, Arrays or Maps. There is plenty of types to choose from.
Problem is that your question is lacking information. Please follow this advice: How to ask a good question

One general comment at the end. People trying to translate from Python to AFL are making HUGE mistake. Python is inefficient, Python does NOT have array processing. The programming concepts that Python are not proper concepts for efficient AFL programming. Applying "Python thinking" to AFL is not good idea. You have to learn in terms of ARRAYS and ARRAY processing Understanding how AFL works