Using the [ ] Identifier on amibroker

#1
Hello,

I am a french trader and user of amibroker( former TS user ) ,and I always have the same problems with array identifiers.

On TS, you simply use a variables between the brackets, but on ami, it seems like you have to put [barcount - var]...

Anyone can help me and tell where the error is in this code. It's a simple mov avg system referring to the past value of the mov avg:

Amount = Param( "dollz", 10000, 50, 1000000, 50 );
defMAL = Param("MAL", 10, 2, 200, 10 );
defR = Param( "Recul", 30, 2, 30, 2 );

MAL = Optimize( "MAL", defMAL, 2, 100, 5 );
R = Optimize( "Recul", defR, 1, 20, 2 );

PositionSize = Amount;

MyMA = MA( Close, MAL );

Buy = MyMA > MyMA[BarCount - R];
Sell = MyMA < MyMA[BarCount - R];

Short = MyMA < MyMA[BarCount - R];
Cover = MyMA > MyMA[BarCount - R];


Thanks for your help.
 
#4
Please, is there someone to help me here? They just said me that the question has been asked before on yahoogroups.There is like thousands of threads. I didn't find it.

Please tell me a guy with sufficient knowledge. I will send him a private message.

Thanks a lot
 

murthymsr

Well-Known Member
#6
Hello,

I am a french trader and user of amibroker( former TS user ) ,and I always have the same problems with array identifiers.

On TS, you simply use a variables between the brackets, but on ami, it seems like you have to put [barcount - var]...

Anyone can help me and tell where the error is in this code. It's a simple mov avg system referring to the past value of the mov avg:

Amount = Param( "dollz", 10000, 50, 1000000, 50 );
defMAL = Param("MAL", 10, 2, 200, 10 );
defR = Param( "Recul", 30, 2, 30, 2 );

MAL = Optimize( "MAL", defMAL, 2, 100, 5 );
R = Optimize( "Recul", defR, 1, 20, 2 );

PositionSize = Amount;

MyMA = MA( Close, MAL );

Buy = MyMA > MyMA[BarCount - R];
Sell = MyMA < MyMA[BarCount - R];

Short = MyMA < MyMA[BarCount - R];
Cover = MyMA > MyMA[BarCount - R];


Thanks for your help.
hi equityraiser,
i am not an expert on TA or AB, so not responded to your first post.

but i became inquisitive on your second post. i ran the AFL and the code ran without any errors after adding a few lines, required to running in explorer mode.

if you like, you may post some more information about what the code does, for a better understanding.

i am not sure if it helps or not, but i am posting the revised code and the exported csv files and the AFL code. (all files renamed to TXT extention)

all the best.
murthymsr
 
Last edited:

bvpraveen

Active Member
#7
Hello,

I am a french trader and user of amibroker( former TS user ) ,and I always have the same problems with array identifiers.

On TS, you simply use a variables between the brackets, but on ami, it seems like you have to put [barcount - var]...

Anyone can help me and tell where the error is in this code. It's a simple mov avg system referring to the past value of the mov avg:

Amount = Param( "dollz", 10000, 50, 1000000, 50 );
defMAL = Param("MAL", 10, 2, 200, 10 );
defR = Param( "Recul", 30, 2, 30, 2 );

MAL = Optimize( "MAL", defMAL, 2, 100, 5 );
R = Optimize( "Recul", defR, 1, 20, 2 );

PositionSize = Amount;

MyMA = MA( Close, MAL );

Buy = MyMA > MyMA[BarCount - R];
Sell = MyMA < MyMA[BarCount - R];

Short = MyMA < MyMA[BarCount - R];
Cover = MyMA > MyMA[BarCount - R];


Thanks for your help.
Hi,

I tried to write a better AFL, and came up with the one below. Let me know if
I'm wrong anywhere.

Amount = Param( "dollz", 10000, 50, 1000000, 50 );
defMAL = Param("MAL", 10, 2, 200, 10 );
defR = Param( "Recul", 30, 2, 30, 2 );

MAL = Optimize( "MAL", defMAL, 2, 100, 5 );
R = Optimize( "Recul", defR, 1, 20, 2 );

PositionSize = Amount;

MyMA = MA( Close, MAL );

for(i=R; i<BarCount; i++)
{
prevMA=MyMA[i-R];
}

Buy = Cross(MyMA, prevMA);
Sell = Cross(prevMA, MyMA);


Thanks,
Praveen.
 
#9
hello,
I am Ajith , I am new to this site.
Regards
Ajith
Hello Ajith,

Welcome to Traderji.

BTW, Ajith, there are different sections devoted for specific catergory. You can find them from the home page. Please try to post the messages in the respective sections so that you can get related replies.

All the best,
Praveen.
 

Similar threads