PureBytes Links
Trading Reference Links
|
Hi there !
Boy-o-boy did this one have many gremlins or what, got it all figured
out and working quite well... :-)
Cheers
Louw
--- In amibroker@xxxxxxxxxxxxxxx, "louwcoetzer" <lcoetzer@xxxx> wrote:
> HI guys, sorry for this but I really am baffled by this one. I
> attach here my script as it has developed with your help and some
> other ideas. See the REMARKS for details.
>
> Basically it seems to be working fine now, the only problem is
> because I do not know how to catch the price when an EXIT was
> triggered by a applyStoploss feature. I have set it in the
settings
> to exit at the particular level it was triggerd as that is the
price
> I would get when trading and NOT the close price.
>
> This makes it difficult for me, because I want the EXIT price shown
> in the Exploration results. So I tried to create a variable for it
> as per the attached script. It would appear however that this
price
> differs from the price when I do a BACKTEST...so I am assuming that
I
> am not correctly calculating the EXIT price manually.
>
> Is there a way to trap the EXIT price for an applyStop trigger ?
>
> Kind regards and thanks for the patience !
>
> Louw
>
> // Code Starts here ...
> /*
> I want to test the following:
> 1.) If yesterday's high was breached by today's INTRADAY high, then
> BUY.
> 2.) If bought, did the trade eventually reach the target profit in
> points ?
> 3.) If it did, what was the lowest the price dipped against the
> position since the entry until the
> target was reached? ( almost like a trade drawdown ... )
>
> Once I get this right, adding SHORT sales will be easy enough.
>
> The main problem now is that when I backtest the formula, I get the
> same entry prices and times, BUT
> different SELL prices ???
>
> */
>
> targetpoints = 0.1; // My profit target in points used
> by "stopTypeProfit".
> TickSize=0.01;
> NumContracts = 1;
> PointValue =1000;
> PositionSize = NumContracts * MarginDeposit;
>
> BuyPrice = TimeFrameGetPrice( "H", inDaily, -1 ); // Finds
> Yesterday's HIGH.
> SellPrice= IIf(H-BuyPrice >
targetpoints,BuyPrice+targetpoints,C); /*
> Problem are, need this for the Exploration
> as I do NOT know How to Code the ApplyStop Exit Value into the
> Columns. */
>
> DayEnd = DateNum()!=Ref(DateNum(),-1) ;
> Buycond = H > TimeFrameGetPrice( "H", inDaily, -1 )AND Hour() <
> 17; // I do not want trades after 17H00 hrs.
>
> ApplyStop( stopTypeProfit, stopModePoint, targetpoints,
> 1,False,28 ); // Take profit at certain level.
> ApplyStop( stopTypeLoss, stopModePoint, 0.3,
> True,False,28 ); //Close position at S/L level.
> Sell = TimeNum()==170000;//H-BuyPrice > targetpoints OR
> Buy = ExRem(Buycond,Dayend);
>
> //==================================================================
==
> ====
> // Exploraration Code !!!
> //==================================================================
==
> ====
> Equity(1);
> Low1= IIf( H-BuyPrice > targetpoints, ValueWhen( Sell>0,LLV
> (L,BarsSince(Buy))),O); /* Calculates the Lowest the price went
> before reaching my target ... or closed out */
> TargetReached = IIf(H-BuyPrice > targetpoints,1,False);
>
> Filter=Buy;
> NumColumns=4;
> Column0Name="Draw Down";
> Column0=BuyPrice - Low1;
> Column0Format=1.2;
> Column1Name="Buy Price";
> Column1 = BuyPrice;
> Column2Name="Sell Price";
> Column2=SellPrice;
> Column3Name="Reached";
> Column3=targetreached;
>
> // Code end here .......
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|