PureBytes Links
Trading Reference Links
|
Hi,
You've actually touched upon a delicate area. If you need to *know for sure* that you have an open position, then your only choice is to write custom backtester code:
http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/
If you just want to visualize where you *might have taken* buy/sell signals, without *knowing for sure* that the positions were actually taken (as a result of restrictions due to number of open positions, availability of funds, etc.), then you can use the Flip function to store all 1's when in a buy and all 0's after a sell.
Have a look at the following code and read up on the functions used. It illustrates redundant signals (i.e. additional buys in blue after already receiving a buy in green, additional sells in orange after already receiving a sell in red) as well as an "in position" ribbon (green when holding, red when not).
Buy = !(Day() % 3); // Buy every day of month divisible by 3 Sell = !(Day() % 4); // Sell every day of month divisible by 4
FirstBuy = ExRem(Buy, Sell); // Remove redundant buys for charting FirstSell = ExRem(Sell, Buy); // Remove redundant sells for charting
InPos = Flip(FirstBuy, FirstSell); // Store all 1's while in position
Plot(Close, "Price", colorDarkGrey, styleBar); Plot(2, "In Pos", IIf(InPos, colorGreen, colorRed), styleArea | styleOwnScale | styleNoLabel); PlotShapes(shapeHollowUpArrow * Buy, colorBlue, 0, Low, -5); PlotShapes(shapeUpArrow * FirstBuy, colorGreen, 0, Low, -15); PlotShapes(shapeHollowDownArrow * Sell, colorOrange, 0, High, -5); PlotShapes(shapeDownArrow * FirstSell, colorRed, 0, High, -15);
Title = "Day: " + Day();
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "jens_lueckhof" <jens_lueckhof@xxx> wrote: > > Hi all, I try to convert some ProRealtime codes and I am struggeling with the following: > > I have some rules that depend on the position I have in the market, for example something like > > SELL = IF(LONGONMARKET) AND blabla > > How can I check if I am "Long on market". > > Many thanks for your help > J >
__._,_.___
**** 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/
__,_._,___
|