PureBytes Links
Trading Reference Links
|
Right, that's what I felt too. Thanks
----- Original Message -----
From: "Graham" <kavemanperth@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, January 08, 2006 9:25 PM
Subject: Re: [amibroker] Struggling again... advice requested
> This is a personal thing but I never use applystop as I find it too
> limiting. I always use loops instead.
> A applystop only ever uses H for short or L for long
> B you cannot plot the values of the exit without creating the loop, so
> may as well use the loop, it only takes a couple more lines
> C have to use Equity(1 or 2) to create sell values of applystop so
> they can be plotted as arrows, but find equity so often messes up what
> else I am trying to do in the overall code
>
> I will use it when writing for others if it is suitable for the
> aplication and the other requirements as above are not required
>
> --
> Cheers
> Graham
> AB-Write >< Professional AFL Writing Service
> Yes, I write AFL code to your requirements
> http://e-wire.net.au/~eb_kavan/ab_write.htm
>
>
> On 1/9/06, cstrader <cstrader232@xxxxxxxxxxxx> wrote:
>> OK Graham... I'm going to work on the loops. I have the following example
>> from the help file which is going to either kill me or take me to the
>> next
>> level. Is this what you were referring to?
>>
>> Do you use applystop for all of your backtesting? Have you found it a
>> good
>> way to do scaling? Do you think it would work OK for auto-trading? I'm
>> concerned that it is a bit of a black box -- that I won't really
>> understand
>> what it is doing.
>>
>> Thanks again so much.
>>
>> chuck
>>
>>
>> Example 4: partial exit (scaling out) on profit target stops
>>
>> Example of code that exits 50% on first profit target, 50% on next profit
>> target and everything at trailing stop:
>>
>> Buy = Cross( MA( C, 10 ), MA( C, 50 ) );
>> Sell = 0;
>>
>> // the system will exit
>> // 50% of position if FIRST PROFIT TARGET stop is hit
>> // 50% of position is SECOND PROFIT TARGET stop is hit
>> // 100% of position if TRAILING STOP is hit
>>
>> FirstProfitTarget = 10; // profit
>> SecondProfitTarget = 20; // in percent
>> TrailingStop = 10; // also in percent
>>
>> priceatbuy=0;
>> highsincebuy = 0;
>>
>> exit = 0;
>>
>> for( i = 0; i < BarCount; i++ )
>> {
>> if( priceatbuy == 0 AND Buy[ i ] )
>> {
>> priceatbuy = BuyPrice[ i ];
>> }
>>
>> if( priceatbuy > 0 )
>> {
>> highsincebuy = Max( High[ i ], highsincebuy );
>>
>> if( exit == 0 AND
>> High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) * priceatbuy )
>> {
>> // first profit target hit - scale-out
>> exit = 1;
>> Buy[ i ] = sigScaleOut;
>> }
>>
>> if( exit == 1 AND
>> High[ i ] >= ( 1 + SecondProfitTarget * 0.01 ) * priceatbuy )
>> {
>> // second profit target hit - exit
>> exit = 2;
>> SellPrice[ i ] = Max( Open[ i ], ( 1 + SecondProfitTarget *
>> 0.01 )
>> * priceatbuy );
>> }
>>
>> if( Low[ i ] <= ( 1 - TrailingStop * 0.01 ) * highsincebuy )
>> {
>> // trailing stop hit - exit
>> exit = 3;
>> SellPrice[ i ] = Min( Open[ i ], ( 1 - TrailingStop * 0.01 ) *
>> highsincebuy );
>> }
>>
>> if( exit >= 2 )
>> {
>> Buy[ i ] = 0;
>> Sell[ i ] = exit + 1; // mark appropriate exit code
>> exit = 0;
>> priceatbuy = 0; // reset price
>> highsincebuy = 0;
>> }
>> }
>> }
>>
>> SetPositionSize( 50, spsPercentOfEquity );
>> SetPositionSize( 50, spsPercentOfPosition * ( Buy == sigScaleOut ) ); //
>> scale out 50% of position
>>
>>
>>
>> ----- Original Message -----
>> From: "Graham" <kavemanperth@xxxxxxxxx>
>> To: <amibroker@xxxxxxxxxxxxxxx>
>> Sent: Sunday, January 08, 2006 8:55 PM
>> Subject: Re: [amibroker] Struggling again... advice requested
>>
>>
>> > You do not need Osaka for this, the loops are not that hard once you
>> > get the hang of them. It is more the logic you need to step through in
>> > detail, and include at each step what has to be remembered and passed
>> > on to each bar
>> >
>> >
>> > --
>> > Cheers
>> > Graham
>> > AB-Write >< Professional AFL Writing Service
>> > Yes, I write AFL code to your requirements
>> > http://e-wire.net.au/~eb_kavan/ab_write.htm
>> >
>> >
>> >
>> >
>> >
>> > On 1/9/06, Keith McCombs <kmccombs@xxxxxxxxxxxx> wrote:
>> >> Link for osaka:
>> >> http://www.amibroker.org/3rdparty/
>> >>
>> >>
>> >> cstrader wrote:
>> >>
>> >> Right but the problem is that this line:
>> >>
>> >> Bought = Flip(Buy, Sell,);
>> >>
>> >> won't execute because sell is not yet (cannot yet be) defined.
>> >>
>> >> Do you have a link for the osaka plugin? I can't seem to track it
>> >> down.
>> >> Did see some posts about array "persistency" which is what I think I'm
>> >> looking for.
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> ----- Original Message -----
>> >> From: Graham
>> >> To: amibroker@xxxxxxxxxxxxxxx
>> >> Sent: Sunday, January 08, 2006 7:06 PM
>> >> Subject: Re: [amibroker] Struggling again... advice requested
>> >>
>> >>
>> >> flip starts on the first bar with 1 and ends last bar with 0, so
>> >>
>> >> Buyprice = Valuewhen (Buy and ref(Bought,-1)==0);
>> >>
>> >>
>> >> --
>> >> Cheers
>> >> Graham
>> >> AB-Write >< Professional AFL Writing Service
>> >> Yes, I write AFL code to your requirements
>> >> http://e-wire.net.au/~eb_kavan/ab_write.htm
>> >>
>> >>
>> >> On 1/9/06, cstrader <cstrader232@xxxxxxxxxxxx> wrote:
>> >> >
>> >> >
>> >> >
>> >> > Hi Herman:
>> >> >
>> >> >
>> >> >
>> >> > Those are both excellent ideas. They may be what I need. Perhaps
>> >> > I'm
>> >> > making too much of it, but I am indeed in a quagmire. Let me try to
>> >> > be
>> >> > clearer.
>> >> >
>> >> >
>> >> >
>> >> > I want to get in and out of trades as the day goes on (not simple
>> >> > reversals, but in and out of trades). To set my exits I need to
>> >> > remember the initial buyprice of the entry. In actual trading I
>> >> > can
>> >> > get this entry price from the TWS, but I can't do that during
>> >> > development. I need also need to ignore later extraneous buy
>> >> > signals.
>> >> >
>> >> >
>> >> >
>> >> > Ideally the code would look something like that below. However, it
>> >> > is
>> >> > not possible, because you need to know the value of Sell in line 2
>> >> > in
>> >> > order to determine whether you are at the real (first) buypoint
>> >> > rather
>> >> > than a later extraneous one. However Sell cannot be defined until
>> >> > line 4 (after buyprice is determined)
>> >> >
>> >> >
>> >> >
>> >> > A possibility is to set buyprice as static rather than array. As I
>> >> > mentioned earlier, this is a solution, but not a very good one.
>> >> >
>> >> >
>> >> >
>> >> > What am I missing?
>> >> >
>> >> >
>> >> >
>> >> > Chuck
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ///1
>> >> >
>> >> > Buy = buyconditions;
>> >> >
>> >> >
>> >> >
>> >> > ///2 We're in a buy now, until we get a sell signal
>> >> >
>> >> > Bought = Flip(Buy, Sell,);
>> >> >
>> >> >
>> >> >
>> >> > ///3 Where did we enter? Need to remember first buyprice and to
>> >> > ignore
>> >> > subsequent buy signals (e.g. signals where we are already in a buy)
>> >> >
>> >> > Buyprice = Valuewhen (Buy and !Bought);
>> >> >
>> >> >
>> >> >
>> >> > ///4 Now we go flat
>> >> >
>> >> > Sell = C > Buyprice + 2 or C < Buyprice - 2;
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ----- Original Message -----
>> >> > From: Herman van den Bergen
>> >> > To: amibroker@xxxxxxxxxxxxxxx
>> >> > Sent: Sunday, January 08, 2006 5:41 PM
>> >> > Subject: RE: [amibroker] Struggling again... advice requested
>> >> >
>> >> >
>> >> > Perhaps this will give you more ideas...
>> >> >
>> >> > In the past i have "attached" text, signals, trade information, etc.
>> >> > to
>> >> > bars by using staticvariables named with the bar's time appended.
>> >> > For
>> >> > text example you could use:
>> >> > staticvarsettext("Bar"+TimeNumber, "your info to attach"); Where the
>> >> > TimeNumber is SelectedValue(TimeNum()). You can also use
>> >> > StaticvarSet("Bar"+TimeNumber, Numericalvalue) to attach signals.
>> >> > This
>> >> > method will work if you only want to tag a limited number of bars
>> >> > (up
>> >> > to a few hundred). You can loop through the bars displayed and plot
>> >> > numbers or show/recall text from selected bars.
>> >> >
>> >> > I presume you have looked at using a table? Look at the OSAKA
>> >> > plugin.
>> >> >
>> >> > If you do not need to save data after shutdown you can, instead of
>> >> > using a text file, save long strings (same as file) in a
>> >> > StaticvarSetText(), easier?
>> >> >
>> >> > Chuck, i think you may be making is more complicated than it needs
>> >> > be...if you can describe exactly what your need perhaps we can help
>> >> > you
>> >> > better....
>> >> >
>> >> > herman
>> >> >
>> >> >
>> >> > -----Original Message-----
>> >> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
>> >> > Behalf Of cstrader
>> >> > Sent: Sunday, January 08, 2006 12:54 PM
>> >> > To: amibroker@xxxxxxxxxxxxxxx
>> >> > Subject: Re: [amibroker] Struggling again... advice requested
>> >> >
>> >> >
>> >> > Thanks again Herman.
>> >> >
>> >> > I basically do that too, although it isn't really the issue I have.
>> >> >
>> >> > My thinking is now here: What I need is a new type of variable --
>> >> > it
>> >> > is static in the sense that it holds its value across bars, but
>> >> > dynamic
>> >> > in the sense that it can change over time. The problem with static
>> >> > variables is that when you set them at, say 14:00, they change their
>> >> > value back at say 10:00 as well.
>> >> >
>> >> > In essence, what I want is a Hold() function where the length of the
>> >> > hold is determined dynamically rather than statically. Doesn't
>> >> > (yet)
>> >> > exist!
>> >> >
>> >> > What I think what I'm going to try (anyone else ever done this?) is
>> >> > to
>> >> > create a "history" text file. At the end of every bar I will write
>> >> > (append) the current status to a text file, along with the current
>> >> > barindex. This can be done realtime or by running the cursor across
>> >> > the chart. Then I'll read in from that history file as time goes
>> >> > on.
>> >> > This will allow me to know what my positions were at say 10:31, even
>> >> > when it's 14:01.
>> >> >
>> >> > I'm thinking this might help me,? although you've probably guessed
>> >> > by
>> >> > now that I really have no idea what I'm doing... :)
>> >> >
>> >> > chuck
>> >> >
>> >> > ----- Original Message -----
>> >> > From: Herman van den Bergen
>> >> > To: amibroker@xxxxxxxxxxxxxxx
>> >> > Sent: Sunday, January 08, 2006 11:50 AM
>> >> > Subject: RE: [amibroker] Struggling again... advice requested
>> >> >
>> >> >
>> >> > In real trading you can use LastPrice = Lastvalue(C) or
>> >> > GetRTData("Last");
>> >> >
>> >> > During developement I often use LastPrice = SelectedPrice(C); This
>> >> > allows me to step my cursor over the bars (or just click on the
>> >> > chart
>> >> > to select a bar) on the chart and trigger trades. Of course this is
>> >> > ONLY to test the mechanics of your system and profits and fills do
>> >> > not
>> >> > reflect real prices. Limit orders tend to fill only one way because
>> >> > the
>> >> > selectedprice can be far away from the market price seen by the TWS.
>> >> >
>> >> > For initial testing I find this much easier/faster than working with
>> >> > simulators or the DEMO TWS.
>> >> >
>> >> > herman
>> >> >
>> >> >
>> >> > -----Original Message-----
>> >> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
>> >> > Behalf Of cstrader
>> >> > Sent: Sunday, January 08, 2006 11:20 AM
>> >> > To: amibroker@xxxxxxxxxxxxxxx
>> >> > Subject: Re: [amibroker] Struggling again... advice requested
>> >> >
>> >> >
>> >> > Herman....right but this assumes that you are real time and live or
>> >> > paper trading. But what do you do when you are developing the
>> >> > system?
>> >> >
>> >> > ----- Original Message -----
>> >> > From: Herman van den Bergen
>> >> > To: amibroker@xxxxxxxxxxxxxxx
>> >> > Sent: Sunday, January 08, 2006 11:15 AM
>> >> > Subject: RE: [amibroker] Struggling again... advice requested
>> >> >
>> >> >
>> >> > In simple system you can check the positionsize:
>> >> >
>> >> > IBPosSize = ibc.GetPositionSize( Ticker );
>> >> >
>> >> >
>> >> > assuming you got full fills you don't want to go short if you are
>> >> > already short, or long if you are already long.
>> >> >
>> >> > For this type of trading you could/should be using minute bars and
>> >> > limit trades to one per minute.
>> >> >
>> >> > If trading a reversal system you can also maintain your own Static
>> >> > position indicator...
>> >> >
>> >> > hreman
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > -----Original Message-----
>> >> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
>> >> > Behalf Of cstrader
>> >> > Sent: Sunday, January 08, 2006 11:04 AM
>> >> > To: amibroker@xxxxxxxxxxxxxxx
>> >> > Subject: Re: [amibroker] Struggling again... advice requested
>> >> >
>> >> > Sorry, I think my post wasn't that clear. I am trading intraday,
>> >> > and I
>> >> > want
>> >> > to get in and out of trades frequently during the day. The trouble
>> >> > I'm
>> >> > having is determining whether I should open a new trade, because I
>> >> > don't
>> >> > know yet whether I've gotten out of the old one. That is, you want
>> >> > to
>> >> > use
>> >> > Exrem() to avoid repeated buy signals, but you can't do that because
>> >> > you
>> >> > have to use the sell conditions to define the buy conditions. Am I
>> >> > making
>> >> > any sense?
>> >> >
>> >> >
>> >> > ----- Original Message -----
>> >> > From: "Tradingbasis" <tzg@xxxxxxxxxxxxxxxx >
>> >> > To: <amibroker@xxxxxxxxxxxxxxx>
>> >> > Sent: Sunday, January 08, 2006 10:56 AM
>> >> > Subject: RE: [amibroker] Struggling again... advice requested
>> >> >
>> >> >
>> >> > > Hi,
>> >> > >
>> >> > > try this one:
>> >> > >
>> >> > > Setup = your buy condition;
>> >> > > Tradedate = ValueWhen(setup,DateNum(),1);
>> >> > > LastTradedate = Ref(Tradedate,-1);
>> >> > > Otpd = Tradedate > Lasttradedate;//only one trade per day
>> >> > >
>> >> > > Buy = Setup;
>> >> > >
>> >> > >
>> >> > > - - - - - - - - - - - - - - - - - - - -
>> >> > > Best regards
>> >> > >
>> >> > > Thomas
>> >> > > www.tradingbasis.com
>> >> > > support@xxxxxxxxxxxxxxxx
>> >> > > - - - - - - - - - - - - - - - - - - - -
>> >> > >
>> >> > > -----Original Message-----
>> >> > > From: amibroker@xxxxxxxxxxxxxxx [mailto:
>> >> > > amibroker@xxxxxxxxxxxxxxx]
>> >> > > On
>> >> > > Behalf
>> >> > > Of cstrader
>> >> > > Sent: Sunday, January 08, 2006 4:48 PM
>> >> > > To: amibroker@xxxxxxxxxxxxxxx
>> >> > > Subject: [amibroker] Struggling again... advice requested
>> >> > >
>> >> > > I am struggling (again!), and would like to request some advice.
>> >> > >
>> >> > >
>> >> > >
>> >> > > My new systems take more than one trade in a day. This creates
>> >> > > what
>> >> > > I
>> >> > > call
>> >> > > the Catch-22 problem. You can't anymore use arrays to mark the
>> >> > > trades
>> >> > > because the entry is dependent on the exit which is dependent on
>> >> > > the
>> >> > > entry... So now what do I do?
>> >> > >
>> >> > >
>> >> > >
>> >> > > One possibility is to code with loops. I hate that idea because
>> >> > > it's
>> >> > > complicated and because I thought that AB was all about avoiding
>> >> > > loops.
>> >> > >
>> >> > >
>> >> > >
>> >> > > Another possibility is to mark the entry price with a static
>> >> > > variable
>> >> > > and
>> >> > > hold it until the exit. This will (maybe) work OK in actual
>> >> > > trading
>> >> > > and
>> >> > > in
>> >> > > AA but it is hard to tell what is happening because the buy and
>> >> > > sell
>> >> > > arrows
>> >> > > on the chart display are no longer accurate (because later static
>> >> > > variable
>> >> > > assignments mess up the display of earlier ones).
>> >> > >
>> >> > >
>> >> > >
>> >> > > This seems like such a basic problem that someone else must have
>> >> > > dealt
>> >> > > with
>> >> > > it and found the solution.
>> >> > >
>> >> > >
>> >> > >
>> >> > > Thanks!
>> >> > >
>> >> > >
>> >> > >
>> >> > > chuck
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > > Please note that this group is for discussion between users only.
>> >> > >
>> >> > > To get support from AmiBroker please send an e-mail directly to
>> >> > > SUPPORT {at} amibroker.com
>> >> > >
>> >> > > For other support material please check also:
>> >> > > http://www.amibroker.com/support.html
>> >> > >
>> >> > >
>> >> > > Yahoo! Groups Links
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > > Please note that this group is for discussion between users only.
>> >> > >
>> >> > > To get support from AmiBroker please send an e-mail directly to
>> >> > > SUPPORT {at} amibroker.com
>> >> > >
>> >> > > For other support material please check also:
>> >> > > http://www.amibroker.com/support.html
>> >> > >
>> >> > >
>> >> > > Yahoo! Groups Links
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> > >
>> >> >
>> >> >
>> >> >
>> >> > Please note that this group is for discussion between users only.
>> >> >
>> >> > To get support from AmiBroker please send an e-mail directly to
>> >> > SUPPORT {at} amibroker.com
>> >> >
>> >> > For other support material please check also:
>> >> > http://www.amibroker.com/support.html
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > SPONSORED LINKS
>> >> > Investment management software Real estate investment software
>> >> > Investment property software
>> >> > Software support Real estate investment analysis software Investment
>> >> > software
>> >> >
>> >> > ________________________________
>> > YAHOO! GROUPS LINKS
>> >> >
>> >> >
>> >> > Visit your group "amibroker" on the web.
>> >> >
>> >> > To unsubscribe from this group, send an email to:
>> >> > amibroker-unsubscribe@xxxxxxxxxxxxxxx
>> >> >
>> >> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>> >> > Service.
>> >> > To unsubscribe from this group, send an email to:
>> >> > amibroker-unsubscribe@xxxxxxxxxxxxxxx
>> >> >
>> >> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>> >> > Service.
>> >> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>> >> > Service.
>> >> >
>> >> > ________________________________
>> >
>> >>
>> >>
>> >>
>> >>
>> >> Please note that this group is for discussion between users only.
>> >>
>> >> To get support from AmiBroker please send an e-mail directly to
>> >> SUPPORT {at} amibroker.com
>> >>
>> >> For other support material please check also:
>> >> http://www.amibroker.com/support.html
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> ________________________________
>> > YAHOO! GROUPS LINKS
>> >>
>> >>
>> >> Visit your group "amibroker" on the web.
>> >>
>> >> To unsubscribe from this group, send an email to:
>> >> amibroker-unsubscribe@xxxxxxxxxxxxxxx
>> >>
>> >> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>> >> To unsubscribe from this group, send an email to:
>> >> amibroker-unsubscribe@xxxxxxxxxxxxxxx
>> >>
>> >> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>> >> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>> >>
>> >> ________________________________
>> >
>> >
>> >
>> > Please note that this group is for discussion between users only.
>> >
>> > To get support from AmiBroker please send an e-mail directly to
>> > SUPPORT {at} amibroker.com
>> >
>> > For other support material please check also:
>> > http://www.amibroker.com/support.html
>> >
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>>
>>
>> Please note that this group is for discussion between users only.
>>
>> To get support from AmiBroker please send an e-mail directly to
>> SUPPORT {at} amibroker.com
>>
>> For other support material please check also:
>> http://www.amibroker.com/support.html
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Try Online Currency Trading with GFT. Free 50K Demo. Trade
24 Hours. Commission-Free.
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~->
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
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/
<*> 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/
|