[amibroker] Re: Is there any way to get the last signal (buy or sell) and the last order price?

 

Hi Dave,


If you want to see the results of the operation, use AddColumn along with Filter = 1;

Filter = 1;
...Set Buy and Sell arrays...
tradePrices = ValueWhen(Buy OR Sell, BuyPrice, 2);
AddColumn(tradePrices, "Price of last buy or sell");

Use the Explore button with this code to see the values being returned
by ValueWhen() above.

If you then want to write code which modifies your buy/sell arrays based on previous buy/sell prices, you can compare current prices to tradePrices. Whether you use a loop or an IIF() would depend on how
sophisticated your operation is. For something simple like adding new signals to the array you could use an IIF() like this,

buy = IIF(C < 0.99*tradePrices, True, buy);
sell = IIFC > 1.01*tradePrices, True, sell); 

For more complicated things, you can write a loop,
for (bar = 0; bar < BarCount, bar++) {
     ,,,,business logic comparing
     ... sell[bar], buy[bar] and tradePrices[bar]
}

For the most complicated things with more introspection of
past trade results, you would need to write a low-level custom
backtester, which is described in the documentation.

Does this get at your questions?

__._,_.___

Posted by: rosenberggregg@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___

Related Posts


EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv