A simple Buy/Sell signal and backtesting

#1
Hello

Iam new to back-testing in amibroker. I used to back-test in VB. Friends here tell me that it wud be much better to learn testing in AFL. Apparently, iam new to C syntax and i find it difficult to understand back-testing codes in AFL.

Just to gain more understanding, can someone plz help by writing a back-testing code for the following simple BUY/Sell argument. This shud be fairly simple for mediumly experienced in AFL coders.

local Hw;
Hw=(Ref(H,-2)+Ref(L,-2))/2; // this is entry price
Buy= Ref(C,-3)<Ref(O,-3) AND Ref(C,-2)>Ref(O,-2) AND Ref(C,-1)>Ref(O,-1) AND Ref(C,-1)>Ref(C,-2) AND L<=(Hw+0.05);
Sell=Ref(C,-3)>Ref(O,-3) AND Ref(C,-2)<Ref(O,-2) AND Ref(C,-1)<Ref(O,-1) AND Ref(C,-1)<Ref(C,-2) AND H>=(Hw-0.05);
For Long Trades:
SL < Ref(L,-2)
Profit = Ref(H,-2) + 0.05(entry filter) + brokerage(in terms of pts)

For Short Trades:
SL > Ref(H,-2)
Profit = Ref(L,-2) - 0.05(entry filter) - brokerage(in terms of pts)

Brokerage = Qty * entry price * 2 * 0.025%

Thanx
NTM :)
 
#2
anyone pls help me out guys

hope this is not so very complex for u guys

other guys like who are zero in backtesting coding in AFL will learn to start from here.....

pls help us all :)
 
#4
go to amibroker->open analysis->select formula editor->paste the formula in the pop up window->then select tools from pop up->from drop down select backtest->dont forget to select all symbols & all quotations in automatic analysis window.
Tc............
i understand that

but the above code requires more tweak interms of writing the exact code for Buy price, SL and profit exits. And there are other settings in Auto analyser window to be done. Iam not able to get how those things are done, so my query...

Hope someone respond :thanx:
 
#5
i understand that

but the above code requires more tweak interms of writing the exact code for Buy price, SL and profit exits. And there are other settings in Auto analyser window to be done. Iam not able to get how those things are done, so my query...

Hope someone respond :thanx:
menu
Analysis/Automatic analysis
-settings...
- tab Trades

then you can select Buy Price
 

myamit

Well-Known Member
#9
Hello,

I really could not understand what exactly you need help for. You already have all syntax written.

Do let me know your exact requirement & I will try to help.

Regards,
 
#10
Hello,

I really could not understand what exactly you need help for. You already have all syntax written.

Do let me know your exact requirement & I will try to help.

Regards,

ohh my bad....i didnt see ur msg at all

Amit..what i need is that how to put those SL and profit order requirements into proper AFL code,

As u can see, i have given only the entry condition in proper code (i suppose so!)

I want to incorporate the following lines into AFL so that i can backtest and get a proper report out from Amibroker

For Long Trades:
SL < Ref(L,-2)
Profit = Ref(H,-2) + 0.05(entry filter) + brokerage(in terms of pts)

For Short Trades:
SL > Ref(H,-2)
Profit = Ref(L,-2) - 0.05(entry filter) - brokerage(in terms of pts)

Brokerage = Qty * entry price * 2 * 0.025%

the above lines are to be read along with my code quote in my first post

sincerely hope u wud help me out

thanks again

NTM :thumb:
 

Similar threads