How to use this site



There is NO BUG. Don’t blame tools for sole purpose that you don’t know how to use them.

I copy pasted your code into AFL editor, applied Code Prettify and copy pasted it back here
and everything is indented.

BTW: don’t you have better things to do than picking would be ‘bugs’ in open source software Discourse ? Even if there was a bug I would not be able to fix it because: a) I did not write that software, b) I don’t have time

if( Status( "action" ) == actionPortfolio )
    bo = GetBacktesterObject();
    // Run default backtest procedure without generating the trade list
    // Initialize accumulation variables
    sumATRPnL =  countATRPnL = 0;
    sumATRPnLWin = countATRPnLWin = 0;
    sumATRPnLLoss = countATRPnLLoss = 0;
    maxATRPnL = minATRPnL = 0;

    // Iterate through closed trades
    for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
        ATRPnL = AddATRPnL( trade );

    // Iterate through open positions
    for( trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos() )
        ATRPnL = AddATRPnL( trade );

    // Generate trade list

    // Custom Statistics on ATR PnL
    avgATRPnL = IIf( countATRPnL < 1, 0.0, SumATRPnL / countATRPnL );
    avgATRPnLWin = IIf( countATRPnLWin < 1, 0.0, SumATRPnLWin / countATRPnLWin );
    avgATRPnLLoss = IIf( countATRPnLLoss < 1, 0.0, SumATRPnLLoss / countATRPnLLoss );
    bo.AddCustomMetric( "Avg Trade (ATR)", avgATRPnL );
    bo.AddCustomMetric( "Avg Win (ATR)", avgATRPnLWin );
    bo.AddCustomMetric( "Avg Loss (ATR)", avgATRPnLLoss );
    bo.AddCustomMetric( "ATR Profit Factor", -avgATRPnLWin / avgATRPnLLoss );
    bo.AddCustomMetric( "Best Trade (ATR)", maxATRPnL );
    bo.AddCustomMetric( "Worst Trade (ATR)", minATRPnL );




I’m not sure if it was mentioned before, but I have noticed, that there might be a difference between using </> and [code][/code] or three back-ticks in some cases, which might be one of the reasons why some users paste codes not being properly formatted.

For example the line below is formatted properly only when using three back-ticks or [code][/code] tags. It looks like this:

HitTexts = "Great job ,Not bad ,Great!,Piece of cake!,Bull's eye!,Hit!,Excellent!,Target acquired!,Walk in the park!,Oh Yes!,You shoot like a pro!,You're the man,Terminated!,Damn you're good!";

… but when using </> it looks like this:

HitTexts = "Great job ,Not bad ,Great!,Piece of cake!,Bull's eye!,Hit!,Excellent!,Target acquired!,Walk in the park!,Oh Yes!,You shoot like a pro!,You're the man,Terminated!,Damn you're good!";

… and makes the rest of the code looking bad.



… after doing some more tests, I see that </> toolbar button in the example above, sometimes work as expected, sometimes not. For example if I leave a blank line above the string variable it may format the text properly, but not always - it depends on where I place the cursor. If the string variable is the only line it doesn’t create this window with a slider. Probably it is by design - I use </> to mark shorter excerpts of the code (and it works properly), but in case of longer and more complex codes, I’d rather choose the two other options.

When I was pasting the code of the Buttons’ Hunter Game (which is rather complex), I wasn’t able to do this properly using </> toolbar button.

Anyway I don’t understand the people who paste their codes improperly (even though they were trying to do so), because before submitting it, everyone can see how it will look like in the preview window. So they can format it properly before clicking Reply.


Frankly, I just use three back ticks ``` at the beginning and at the end. And they work always plus they are super easy and quick to use. And from what I see (looking at post “source”), people simply did not use ANY formatting on their posts and that is why they are “improperly formatted”. They are in fact NOT formatted at all.


Just FYI: from now on, every new user, when starting a new topic for 3 first times will see the following:



Tomasz - that’s a very good idea!

Additionally maybe you consider including information about the possibility of editing posts within the first 10 minutes (personally I would opt for at least 15 minutes). Apparently it is not clear for many users who don’t correct some compelling mistakes (i.e. editing problems) or reply to their first post after a couple of minutes.


Yes, I have modified the notice to include info about editing. Also made search and hamburger menu icons lighter (more visible) in dark color scheme.


Edit time limit has been increased to 15 minutes



Is there any way Discource can prevent users from Posting a question before they have done a certain number of minutes of reading?

Perhaps it could direct them to the “How to use this site” and/or give them a message that they need to read/search before posing their question.


As shown in my previous posts, new users already see the ‘education’ message when they start new thread for their first 3 posts.

Preventing repeatition of trade in LiveAutoTrading

The forum settings are now changed and to create new topic the user has to be on Trust Level 1 or higher,
which means that new user who just signed up must read the forum for at least 10 minutes before creating new topics. Replying in existing topic does not have this limitation.


Very good move Tomasz! I was going to suggest here a similar solution, but I was thinking about even stricter rules - for example 1h or at least 30 minutes read time AND at least 50 posts read. If I understand correctly - it’s very easy to reach 10 minutes read time - it’s enough to log in to the forum, click on a first post and do nothing for 10 minutes. If it was required to read at least 50 posts, and spend on it at least 30 min, it should allow such user to see how properly composed and formatted posts look like. If they don’t see and read enough posts, they might even not know, that there’s something wrong with theirs.

In my opinion users who don’t bother using search option first or spend 30 seconds to compose a sloppy/messy post, don’t correct some obvious mistakes within the first 15 minutes (just like they didn’t care) and in exchange expect detailed answers with ready to use solutions, disrespect other members of this forum.


10 minute read time is a default Discourse threshold for gaining trust level 1. I guess that Discourse authors (who previously created StackExchange) based their choice on their experience and I think it represents more or less correct balance between no restriction and over-the-top restriction. And no, reading detection requires something more than ‘doing nothing’


Hi Tomasz,
I was directed here when I sent an email to the Amibroker support about my AFL script on deleting in-active symbols from database. I couldn’t find any button to start a new thread. Is there any restriction for new member like me ?


You can start new thread once you read the site for 10 minutes. 10 minutes is a time just enough to familiarize with “How to use this site”. I can see that you have met this requirement already and posted a new thread.


Programs posted are increasing in length and, as we often want to refer to a specific line or block of code, would it be possible to add line numbers between ...

This would make discussing the code easier.

Best regards,


Discourse does not support that.


Make sure to trim and/or optimize your picture for size before uploading. From now on, the forum will NOT accept uploads greater than 1MB and 5megapixels in size. Do NOT use phone camera to take screenshots. This is not photo hosting site like Instagram. User proper tools, like Windows built-in Snipping tool (at minimum).