[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Translating a system from Tradestation



PureBytes Links

Trading Reference Links

strictly speaking, I havent consider the scenario when Barsince 
Entry is bigger than 1. The problem with using Barsince, as well as 
valuewhen is that, if a new buy signal appears before a exit signal 
from the original buy signal appears, then valuewhen, barssince will 
take from the new buy signal. and to be do that properly, you will 
need a loop that ignore all buy signal until a exit signal is in 
place

--- In amibroker@xxxxxxxxxxxxxxx, "Paul Ho" <paul.tsho@xxx> wrote:
>
> I'm no sure Buy next bar at Highest(H, 2) stop means 1 tick above 
> the High or equal to the high. I've made it one tick above it.
> But the following code will work.
> TickSize= 1; //or whatever else
> TrueHigh = max(H, ref(c, -1));
> TrueLow = min(L, ref(c, -1));
> tr = TrueHigh - TrueLow;
> Condition1 = tr < Ref(tr, -1) AND tr < Ref(tr, -2);
> Condition2 = C > Ref(C, -14) AND C < Ref(C, -2);
> Condition3 = C < Ref(C, -14) AND C > Ref(C, -2);
> longentrypoint = HHV(H, 2);
> Shortentrypoint = LLV(L, 2);
> buysetup = Condition1 AND Condition2;
> Shortsetup = Condition1 AND Condition3;
> Buy = Ref(buysetup, -1) AND H > Ref(Longentrypoint, -1);
> Short = Ref(shortsetup, -1) AND L < Ref(Shortentrypoint, -1);
> BuyPrice = Longentrypoint + TickSize;
> ShortPrice = Shortentrypoint - TickSize;
> Sell = C > ValueWhen(Buy, BuyPrice) AND Ref(Buy, -1);
> SellPrice = C;
> Cover = C < ValueWhen(Short, ShortPrice) AND Ref(Short, -1);
> CoverPrice = C;
> Your code generates only 1 trade because, you did not put in the 
one 
> bar delay that is needed before comparsions between prices are 
made.
> /Paul.
> --- In amibroker@xxxxxxxxxxxxxxx, "droskill" <droskill@> wrote:
> >
> > Paul - thanks for the code.  It's still generated only one trade 
> for
> > the SPY.
> > 
> > I'm wondering about two aspects - as to whether test lines of 
code
> > will actually work:
> > 
> > > > Buy = Condition1 AND Condition2;
> > > > BuyPrice = HHV(H,2);
> > > > 
> > > > Sell = C > BuyPrice AND BarsSince(Buy) >= 1;
> > 
> > Can I use BarsSince Buy this way?
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Paul Ho" <paul.tsho@> wrote:
> > >
> > > You can make some small changes to bring the definition of 
true 
> > > range to be in line how they are normally defined.
> > > TrueHigh = max(H, ref(c, -1));
> > > TrueLow = min(L, ref(c, -1));
> > > TrueRange = TrueHigh - TrueLow;
> > > /Paul.
> > > --- In amibroker@xxxxxxxxxxxxxxx, "droskill" <droskill@> wrote:
> > > >
> > > > Hey all - trying to translate a system but having some 
> issues.  
> > > Here's
> > > > the original EasyLanguage:
> > > > 
> > > > Input: StopPts  (30);  { Size of money management stop, 
> points }
> > > > Var:   TR       (0);   { True Range }
> > > > 
> > > > TR = TrueRange;
> > > > 
> > > > Condition1 = TR < TR[1] and TR < TR[2];
> > > > Condition2 = C > C[14] and C < C[2];
> > > > Condition3 = C < C[14] and C > C[2];
> > > > 
> > > > If Condition1 and Condition2 then
> > > >     Buy next bar at Highest(H, 2) stop;
> > > > 
> > > > If Condition1 and Condition3 then
> > > >     Sell short next bar at Lowest(L, 2) stop;
> > > > 
> > > > If MarketPosition = 1 and C > EntryPrice and BarsSinceEntry 
>= 
> 1 
> > > then
> > > >     Sell this bar at close;
> > > > 
> > > > If MarketPosition = -1 and C < EntryPrice and BarsSinceEntry 
> >= 1 
> > > then
> > > >     Buy to cover this bar at close;
> > > > 
> > > > If MarketPosition = 1 then
> > > >     Sell next bar at EntryPrice - StopPts stop;
> > > >  
> > > > If MarketPosition = -1 then
> > > >     Buy to Cover next bar at EntryPrice + StopPts stop;
> > > > 
> > > > 
> > > > -----------------------------------
> > > > Here's what I've got - it ain't working:
> > > > 
> > > > TR1 = abs(H-L);
> > > > TR2 = abs(H-Ref(C,-1));
> > > > TR3 = abs(Ref(C,-1)-L);
> > > > 
> > > > TRa = Max(TR1,TR2);
> > > > TRb = Max(TR2,TR3);
> > > > TR  = Max(TRa,TRb);
> > > > 
> > > > Condition1 = TR < Ref(TR,-1) AND TR < Ref(TR,-2);
> > > > Condition2 = C > Ref(C,-14) AND C < Ref(C,-2);
> > > > Condition3 = C < Ref(C,-14) AND C > Ref(C,-2);
> > > > 
> > > > Buy = Condition1 AND Condition2;
> > > > BuyPrice = HHV(H,2);
> > > > 
> > > > Sell = C > BuyPrice AND BarsSince(Buy) >= 1;
> > > > 
> > > > Short = Condition1 AND Condition3;
> > > > ShortPrice = LLV(L,2);
> > > > 
> > > > Cover = C < ShortPrice AND BarsSince(Short) >= 1;
> > > > 
> > > > ApplyStop(stopTypeLoss,stopModePoint,30,0);
> > > > 
> > > > ------------------------------
> > > > Any thoughts greatly appreciated.
> > > >
> > >
> >
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

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

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

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/