AFL help needed to plot lines

amitrandive

Well-Known Member
#71
added a version in which you can define a separate timeframe for the base pivots. For instance if you display 1 minute charts you can calculate the mase pivots in the 5 minute timeframe or 60 minute. This seems to filter out bad trades:

http://wisestocktrader.com/indicatorpasties/1426-gapfil


correction: http://wisestocktrader.com/indicatorpasties/1427-gapfil2
i still have to solve a few problems with this code. You have to fine tune it a bit for yourself. If you expect a gap zone and you do not see one then try to adjust the strength of the mini pivots to for instance 2 instead of 1 or adjust the Minimum gap factor to a lower number and see what works best

http://wisestocktrader.com/indicatorpasties/1428-gapfill3
Sir

Thanks a ton for these codes !!!
:clap::clap::clap:
 
#72
Do you mean from a C++ DLL? or C# DLL?
I would think C++ although I am told it is possible using IronPython.net but i think there is also code in C++ available that allows you to integrate Python in other applications. I would like to use Python function to work inside AFL

so if x and y are arrays in Amibroker

I want to be able to import the library I need, like:

import scipy.interpolate as inter

and then use a Python function like:

ss = inter.InterpolatedUnivariateSpline (x, y)

it would give Amibroker so much more possibilities.
 

mastermind007

Well-Known Member
#73
I would think C++ although I am told it is possible using IronPython.net but i think there is also code in C++ available that allows you to integrate Python in other applications. I would like to use Python function to work inside AFL

so if x and y are arrays in Amibroker

I want to be able to import the library I need, like:

import scipy.interpolate as inter

and then use a Python function like:

ss = inter.InterpolatedUnivariateSpline (x, y)

it would give Amibroker so much more possibilities.
The first thought that came to my mind upon reading the line
Code:
ss = inter.InterpolatedUnivariateSpline (x, y)
was "If it walks like a duck and quacks like a duck, it must be duck..."

There is hardly any difference in the above client-end afl code to a non-COM object, versus, afl code calling a valid COM object, except perhaps in making the instance. I don't recall seeing import keyword in Amibroker, but AFL's createobject does accomplish the almost identical purpose for it too returns the object that can be accessed similarly with the dot.syntax.

I have a code snippet that can be be wrapped around a python code to make it expose a legitimate COM object and can PM that to you if you want. Have not programmed in python but do understand the COM; was amongst the first bunch of those who jumped into the COM band-wagon in 1997-98.

A quick peek at the Boost libraries tutorial on how a Python function can be invoked from C++ reveals that it involves gaining handle to the object first.
See here.

In summary, accessing python from AFL can either be done by COM approach that is officially supported or by creating our own alternative framework in raw C++ to achieve the same. It is just that our framework will be a minimalist version of the COM
 
#74
The first thought that came to my mind upon reading the line
Code:
ss = inter.InterpolatedUnivariateSpline (x, y)
was "If it walks like a duck and quacks like a duck, it must be duck..."

There is hardly any difference in the above client-end afl code to a non-COM object, versus, afl code calling a valid COM object, except perhaps in making the instance. I don't recall seeing import keyword in Amibroker, but AFL's createobject does accomplish the almost identical purpose for it too returns the object that can be accessed similarly with the dot.syntax.

I have a code snippet that can be be wrapped around a python code to make it expose a legitimate COM object and can PM that to you if you want. Have not programmed in python but do understand the COM; was amongst the first bunch of those who jumped into the COM band-wagon in 1997-98.

A quick peek at the Boost libraries tutorial on how a Python function can be invoked from C++ reveals that it involves gaining handle to the object first.
See here.

In summary, accessing python from AFL can either be done by COM approach that is officially supported or by creating our own alternative framework in raw C++ to achieve the same. It is just that our framework will be a minimalist version of the COM
thanks.

i played a bit with the "AFL to COM link" code in the Amibroker library. What I understand is that COM is not suitable for multithreading and you get warnings in Amibroker. But I am a simple coder. I basically only used 4GL programming languages so that's why I asked if somebody worked on this since I am not going to implement this using C++ any time soon I expect :)

I did not work a lot with Python either but used similar languages so expect I could use it pretty quickly if there would be a good interface
 

mastermind007

Well-Known Member
#75
thanks.

i played a bit with the "AFL to COM link" code in the Amibroker library. What I understand is that COM is not suitable for multithreading and you get warnings in Amibroker. But I am a simple coder. I basically only used 4GL programming languages so that's why I asked if somebody worked on this since I am not going to implement this using C++ any time soon I expect :)

I did not work a lot with Python either but used similar languages so expect I could use it pretty quickly if there would be a good interface
I too encountered Multi-threading messages and the bare-bones solution used is to simply ensure that no COM function meant for Amibroker is re-entrant.

Solution (in C#) is to define a single static object and at the start of all the exposed function and consistently lock the dummy object.

Naturally, with more time and more resources, a far better solution can be devised, but this simple idea works, and this solution is able to protect Amibroker and COM object from tripping over each other.

Code:
class COMOBJECT {
internal class foo { } 
internal static _foo = new foo();

public .... SomeAmiMethod(...)
{
    try { lock(_foo) { ... } ... } 
    catch { ... } 
    finally { ... } 
}
}
 
Last edited:

extremist

Well-Known Member
#76
I would think C++ although I am told it is possible using IronPython.net but i think there is also code in C++ available that allows you to integrate Python in other applications. I would like to use Python function to work inside AFL

so if x and y are arrays in Amibroker

I want to be able to import the library I need, like:

import scipy.interpolate as inter

and then use a Python function like:

ss = inter.InterpolatedUnivariateSpline (x, y)

it would give Amibroker so much more possibilities.
fitting a spline is a great idea. i tried with my limited abilities of coding but always fail. got no way near.
but it was always on my mind.

If u make any progress please share it here. all will be benefited.

Thanks in advance...
 
#77
fitting a spline is a great idea. i tried with my limited abilities of coding but always fail. got no way near.
but it was always on my mind.

If u make any progress please share it here. all will be benefited.

Thanks in advance...
Amibroker basically allows you to program all these functions in C++ using ADK but all this stuff is already available in Python. I know Python has many additional math functions, more than you can dream of and also you can manipulate arrays far beyond the possibilities that Amibroker offers.

I am not sure it is possible to integrate Python successfully with Amibroker but a function like InterpolatedUnivariateSpline() allows you to for instance draw a function between chosen index points (not necessarily adjacent points) and it will interpolate all index points in between. When you try to program this in AFL it will take you weeks and pages of code. And implementing all these math functions in C++ using ADK will be a big task as well and many of these C++ codes are not free.

An other option would be to switch to Python altogether since for instance there are also libraries for interactive brokers that allow you to autotrade using Python. But doing everything in Python would be a large switch and a lot of work. It would be nice just to use Python inside Amibroker.
 

extremist

Well-Known Member
#78
It would be nice just to use Python inside Amibroker

I think only 2M (Mastermind ) or kelvinhand sir can help us now.

but any ways it will be way beyond my capabilities.

So i look up to u ( tools&tradingideas )only. after u get any help from them.

Though i remember some time ago Amibrokerfans have also posted some Extrapolated Fourier transform code for Future predicted curve for MT4.
 
Last edited:

KelvinHand

Well-Known Member
#79
Amibroker basically allows you to program all these functions in C++ using ADK but all this stuff is already available in Python. I know Python has many additional math functions, more than you can dream of and also you can manipulate arrays far beyond the possibilities that Amibroker offers.

I am not sure it is possible to integrate Python successfully with Amibroker but a function like InterpolatedUnivariateSpline() allows you to for instance draw a function between chosen index points (not necessarily adjacent points) and it will interpolate all index points in between. When you try to program this in AFL it will take you weeks and pages of code. And implementing all these math functions in C++ using ADK will be a big task as well and many of these C++ codes are not free.

An other option would be to switch to Python altogether since for instance there are also libraries for interactive brokers that allow you to autotrade using Python. But doing everything in Python would be a large switch and a lot of work. It would be nice just to use Python inside Amibroker.
Please evaluate this:
http://www.marketcalls.in/amibroker/integrating-amibroker-python-com-server.html
 
Last edited:

Similar threads