Now, after my next AFL practice, I wanted to learn how to create plugins, so I downloaded the ADK to do some experimentation and practice.
I've read the CallFunction MACD example from the Sample in the ADK which states:
First you need to fill-in arguments table.
like this
AmiVar arg[ 2 ];
arg[ 0 ].type = VAR_FLOAT;
arg[ 0 ].val = 12;
arg[ 1 ].type = VAR_FLOAT;
arg[ 1 ].val = 26;
Then can callfunction MACD like this
AmiVar result = gSite.CallFunction( "macd", 2, arg );
return result;
If I'm going to try CallFunction TimeFrameGetPrice what do i have to do
Can I do this, for example?
AmiVar arg[ 3 ];
arg[ 0 ].type = VAR_STRING;
arg[ 0 ].val = 'H';
arg[ 1 ].type = VAR_STRING;
arg[ 1 ].val = "inDaily";
arg[2].type = VAR_FLOAT;
arg[2].val = -1 ;
AmiVar result = gSite.CallFunction( "TimeFrameGetPrice",3,arg);
return result;
If I'm wrong, is there any way to replace it?
Thank you all very much.
Tomasz
June 23, 2022, 10:58am
2
You can, but you shouldn't. DLLs are not meant to just call built-in functions. They are meant to provide their OWN functions that do something useful and expose NEW functionality instead of just calling already existing functions for sole purpose of hiding what you are doing.
Since this subject returns over and over I would like to summarize all that I wrote previously about why you should not write DLLs and should stay with AFL for most of your AmiBroker programming.
AFL is way simpler. Writing DLL plugins in C++ is orders of magnitude more complex and error prone than writing in AFL. It would take you at least 10x more time to write anything in C++ (DLL)
When you write in AFL, AmiBroker protects against out-of-bound array access. When you write in C++ you are out…
1 Like
Thanks Tomasz, I'll try it in another way.
I will send the price from the TimeFrameGetpricefunction in AFL.
for calculations in plugins
and then return result back to AFL
thank you very much