Dear Amibroker forum, I've been trying for a whole week to figure out how to convert this Metastock code into AFL. I must sadly admit that I'm stuck
The code I would like help to converted is as follows:
(Metastock non-logical language)
Lower line = If(LinearReg(C,13)>PREV,If(LinearReg(C,13)-(ATR(13)*2.5)>PREV,LinearReg(C,13)-(ATR(13)*2.5),PREV),LinearReg(C,13));
This is supposed to draw a line under the price as a kind of visual stoploss line, but not trigger the stoploss function (only as a visual guidance).
I'm currently stuck, mostly because of the fact that I'm a novice regarding coding langauge. I don't understand the Metastock formula function. I've read through knowledge base and searched members forum ( and read Metastock reference guide formula primer) and narrowed the solution (perhaps ) to these to answers:
- As Tomasz writes: https://forum.amibroker.com/t/convert-metastock-indicator-to-afl/7131/4
- but I cant figure out how to "breakdown" the Metastock formula like mentioned above.
- Or does the code need to converted into a loop like this example:
/* a sample low-level implementation of max-loss stop in AFL: */
priceatbuy=0;
for( i = 0; i < BarCount; i++ )
{
if( priceatbuy > 0 AND Low[ i ] < 0.98 * priceatbuy )
{
Sell[ i ] = 1;
SellPrice[ i ] = 0.98 * priceatbuy;
priceatbuy = 0;
}
else
Sell[ i ] = 0;
if( priceatbuy == 0 AND Buy[ i ] )
priceatbuy = BuyPrice[ i ];
}
I just can't fully understand the loop function and how "breakdown" the Metastock code.
Thanks in advance!
Kind regards