Hi Jonhausd,

I'm sorry I could not provide data source interface at that time. It will be 
available soon.

This is a working backtest code in VB.Net. A matter of taste. C# is cleaner. 

Imports AmiBroker
Imports AmiBroker.Utils

Namespace AmiBroker.Samples

    Public Class VBSample
        Inherits IndicatorBase

        Public Sub Sample7()

            Dim trade As Trade
            Try
                Dim bo As Backtester = AFTools.GetBacktesterObject()
                bo.Backtest()

                Dim totalProfitPercent As Double = 0
                Dim tradeNum As Integer = 0

                ' iterate through all closed trades
                trade = bo.GetFirstTrade()
                While (Not trade Is Nothing)
                    ' sum up profit % 
                    totalProfitPercent = totalProfitPercent + 
trade.GetPercentProfit()
                    tradeNum = tradeNum + 1
                    trade = bo.GetNextTrade()
                End While

                ' iterate through open positions
                trade = bo.GetFirstOpenPos()
                While (Not trade Is Nothing)
                    ' sum up profit % 
                    totalProfitPercent = totalProfitPercent + 
trade.GetPercentProfit()
                    tradeNum = tradeNum + 1
                    trade = bo.GetNextOpenPos()
                End While

                ' calc expectency %
                Dim expectancy As Single = (totalProfitPercent / tradeNum)

                ' Adding custom metric to the report
                bo.AddCustomMetric("Expectancy %", expectancy, False, False, 4)

            Catch e As Exception
                ' present error message on indicator panel and the Log-Trace 
window
                YException.Show("Error while executing indicator.", e)
            End Try

        End Sub

    End Class

End Namespace

Regards,

Y


--- In [email protected], "janhausd" <janhaus.dres...@...> wrote:
>
> Hi JozsefT,
> 
> I tried out your SDK the moment it came out in beta, so I have some idea as 
> to how it works. I would have to say one major factor for me is that yours is 
> not free, and Koistya's is :) Asides from that, your SDK doesn't support data 
> plug-ins, which is crucial for me, maybe not for others. If you dl Koistya's 
> sdk you will see that just about all the functions there are also represented 
> as a managed class or method, so in regards to this it's pretty much the same 
> from the user's point of view. With a little more work I bet you could hide 
> every bit of ummanaged code in his as you do in yours, but at its current 
> state, it's fine with me and I don't have to work with pointers either.
> 
> Granted, your code and interfaces are cleaner to work with, and prob have 
> improved since your latest beta release, so I'm definitely not disputing your 
> weeks of work :) I put in some work with Koistya's SDK as well and at this 
> point I'm much more comfortable using that, so I thought I'd mention it on 
> the forums for anybody else who might want to use a .NET language with AB, 
> and need to build a data plug-in.
> 
> Also, although hacking .NET IL is not strictly supported by MS, one 
> potentially huge advantage of Koistya's solution is that theoretically you 
> can use ANY .NET language to create an AB plug-in, not just C# but also VB, 
> etc. :) Not that this matters to me, but this opens up a solution for others 
> who are more comfortable with VB.
> 
> 
> --- In [email protected], "JozsefT" <jtoth100@> wrote:
> >
> > Hi All,
> > 
> > Janhausd, what is a better solution to you may be a bad solution to others!
> > 
> > As my SDK (http://sites.google.com/site/dotnetsdkforab/) was mentioned in a 
> > little bit negative context let me clear up a few things.
> > 
> > If you compare my ".Net SDK for AmiBroker" with Koistya's "AmiBroker 
> > Plugins with C#", there are number of differences apart from being 
> > commercialized and from free/open source...
> > 
> > My SDK aimes to be a complete "replacement" of AFL. You can use AFL or use 
> > C#. Everything in AFL (object, array operators, built-in methods) is 
> > available in my SDK as .Net MANAGED CLASS, or METHOD. I try to provide a 
> > programming environment equivalent of AFL. The aim was to make it as simple 
> > as possible. You can write the same stuff in C# by using the same number 
> > code line as in AFL. This includes backterter code, array/indicator 
> > calculations, loops, array indexing, etc. etc. Developers do not have to 
> > cope with the low level of AmiBroker's C interface. Programmers do not have 
> > to use pointers, and unsafe code at all. They do not have to cope with the 
> > traps of the interop layer. They can focus on the trading logic as much as 
> > in AFL. (This is the beauty of AFL.)
> > 
> > With regards to Koistya, I think his stuff is a low level interop layer 
> > around AmiBroker's C interface. Koistya must be a knowledgable, skilled 
> > developer. His stuff is for the alikes. 
> > 
> > I would recommend his stuff for those who don't mind wasting time to cope 
> > with interop issues, handling pointers, learning function table, ADK, etc, 
> > etc. For those who are able to write unsafe code and who are able to debug 
> > and solve issues with these low level layers. And who has time to retest 
> > all these low level stuff in each "inhouse" project...
> > 
> > Apart from the aims, there are technical differences. (I have spent no more 
> > than 20 minutes with Koistya's code. So excuse me if I'm wrong. I expect 
> > Koistya to help clear up things.) Here are a few:
> > 
> > My solution use only supported technics. Exporting managed functions are 
> > not supported by MS, afaik.
> > 
> > My plugin assemblies are pure managed assemblies. They could work with AB's 
> > x64 version with no change as a rusult of the above (x64 version of the SDK 
> > is not available yet).
> > 
> > My SDK tries to solve versioning issues. If you build an assembly now, and 
> > an AB built-in function changes in a future release of AB than you have to 
> > fix and recompile it in Koistya's case. In my case 
> > you just keeps AB and the SDK version in sync. All versioning issues are 
> > managed by my SDK. All your code even those that you sold and are deployed 
> > across the pond on someone else's PC will work with the new AB versions. 
> > All the user has to do is to keep AB version and the SDK version is sync.
> > 
> > I provide array operators. You do not have to write loops. You do not have 
> > to debug (and use pointers and unsafe code) why your C# results are 
> > different from AFL as long as you use array. These are written in ASM for 
> > high performance, they are compatible with AB. (.Net use different float 
> > precision than AB, so expect differencies and suprises.)
> > 
> > My stuff hides the AB's C interface and abstract interfacing problems to a 
> > higher and simpler level. E.g. to create an optimizer plugin you just 
> > create a project of single class that overrides functions of the base 
> > class. To make a function available in AFL you just add some attributes...
> > 
> > I use very low level interop code to provide better performance and use 
> > mashalling much less (for the techies :)).
> > 
> > My stuff is not open source. However, I provide a lot of samples and case 
> > studies. Anyone holding a developer license can get most of the source code 
> > (hosting/interop code is not available.)
> > 
> > My stuff is not free. Sorry. My stuff is not 4-5 weeks of work.
> > 
> > My stuff aims those who want to develop trading systems efficiently.
> > 
> > Regards,
> > 
> > Jozsef
> >
>


Reply via email to