PureBytes Links
Trading Reference Links
|
Beachie,
I didn't read into your code and so maybe I'm missing something from
your description, but is there relly a need to do this in a loop ?
Assuming you don't have any superfluous buys then I would think
something to the effect of
Sell = C < Ref(L, -BarsSince(Buy));
would do it for you ... Note I didn't syntax check the above.
--- In amibroker@xxxxxxxxxxxxxxx, "Beachie" <beachie41@xxxx> wrote:
> OK, I've posting one more time, in case *someone* out there can at
least show me how to do
> this using loops. Otherwise I'll use the rem.dll. that someone was
kind enough to point
> out to me off list.
> Why is it so difficult to implement the simplest of trading rules
i.e sell if a succeeding
> close is below the low of the entry bar? Does everyone mainly use
the canned stops?
> I can't really explain what I'm trying to do any simpler than what
I have in the previous
> posts.
> The code below won't work because I get the "Condition in IF,
WHILE, FOR statements has
> to be Numeric or Boolean type.You can not use array here, please
use [] (array subscript
> operator) to access array elements" error msg.
> I *do not know* how to work around this?!?!?
>
> BuyPrice= 0;
>
> Sellstop = 0;
>
> Buy = Ref(trig,-1); // buy condition triggered prev bar allowing me
to set buyprice to
> open which is equivalent to Buy on Open Delay 1
>
> BuyPrice = Open;
>
> for( i = 0; i < BarCount; i++ )
>
> {
>
> if( BuyPrice == 0 && Buy[ i ] )
>
> BuyPrice = O; //Buyprice set to open
>
> Sellstop = Low - filter; // Low of entry bar minus x.xxx points.
This is the filter. If a
> succeeding close drops below this level the trade is stopped out
>
> }
>
>
>
> iif(Close < Sellstop) //test to see if close less than stop. If
not, then drop down to
> next iif statement
>
> {
>
> Sell [i] =1;
>
> SellPrice[i] = Sellstop;
>
> Sellstop = 0;
>
> BuyPrice = 0;
>
> }
>
> if( ApplyStop(stopTypeProfit,stopModePoint,0.005, 1) == 1 ) //test
to see if Profit stop
> hit.
> {
>
> Sell[i] = 1;
>
> SellPrice[i] = ApplyStop(stopTypeProfit,stopModePoint,0.005, 1);
>
> Sellstop = 0;
>
> BuyPrice = 0;
>
> }
>
> else
>
> Sell[i] = 0;
>
> }
> ----- Original Message -----
> From: "Beachie" <beachie41@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Sunday, November 07, 2004 7:29 AM
> Subject: [trading] Re: [amibroker] Loop help please!
>
>
> >
> > ......and here's me thinking it was crystal clear :)
> > Ok, so what I'm trying to do is:
> > Entry is on "Open, Delay 1" after the trigger which is "Ref(H,-2)
> Ref(H,-3) AND
> > Ref(H,-3) > Ref(H,-4)"
> > There are 2 sell options:
> > Use the built in "StopmodeProfit" or sell if close of bar is
x.xxx amount below the
> > entry
> > bar low
> >
> > Loop through the code testing each buy/sell signal.
> >
> > thanks
> >
> >
> > ----- Original Message -----
> > From: "ed nl" <ed2000nl@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Sunday, November 07, 2004 6:54 AM
> > Subject: Re: [trading] Re: [amibroker] Loop help please!
> >
> >
> >>
> >> maybe try to ask a clear question first. Your code makes no
sense at all. Maybe try to
> >> explain in 3 lines what you want to do. Your code makes no
sense. If people see it they
> >> just move on. Really, I don't even know what the question is....
> >>
> >> ed
> >>
> >>
> >> ----- Original Message -----
> >> From: Beachie
> >> To: amibroker@xxxxxxxxxxxxxxx
> >> Sent: Saturday, November 06, 2004 8:45 PM
> >> Subject: Re: [trading] Re: [amibroker] Loop help please!
> >>
> >>
> >> No one?
> >>
> >> ----- Original Message -----
> >> From: "Beachie" <beachie41@xxxx>
> >> To: <amibroker@xxxxxxxxxxxxxxx>
> >> Sent: Saturday, November 06, 2004 11:45 PM
> >> Subject: [trading] Re: [amibroker] Loop help please!
> >>
> >>
> >> >
> >> > OK, even my jellied brain saw the logic flaw in the previous
pseudo code re:
> >> > Valuewhen(Buy
> >> > etc etc). Have corrected.
> >> >
> >> >
> >> >
> >> > trig= Ref(H,-2) > Ref(H,-3) AND Ref(H,-3) > Ref(H,-4) ;//AND
Ref(L,-2) >= Ref(L,-3)
> >> AND
> >> > Ref(L,-3) >= Ref(L,-4)
> >> >
> >> > sl = Optimize("sl", 0.006, 0.001, 0.015, 0.0005);
> >> >
> >> > profit = ApplyStop(stopTypeProfit, stopModePoint,Optimize
( "max. profit stop level",
> >> > 0.002, 0.001, 0.015, 0.0005 ), 1,True );
> >> >
> >> > profit = 0;
> >> >
> >> > BuyPrice= 0;
> >> >
> >> > Sellstop = 0;
> >> >
> >> > Buy = trig;
> >> >
> >> > for( i = 0; i < BarCount; i++ )
> >> >
> >> > {
> >> >
> >> > if( BuyPrice == 0 && Buy[ i ] == 1 ) // A buy is signalled
> >> >
> >> > BuyPrice = Open[i+1] ; // read *next* value of array after
buy signal to get the
> >> "Buy
> >> on
> >> > open, delay 1 " value
> >> >
> >> > Low_of_entrybar = Low[i+1] - sl; //entry bar low value minus
the 0.00x filter
> >> >
> >> > Sellstop = Cross(Low-Of_entrybar,C); //sell if close less
then Low_of_entrybar value
> >> >
> >> >
> >> > if(Sellstop == 1 OR profit == 1) // test to see if either a
sellstop or profit stop
> >> > value
> >> > true
> >> >
> >> > {
> >> >
> >> > Sell [i] =1;
> >> >
> >> > SellPrice[i] = IIf(Sellstop,ValueWhen(Cross(Low-
Of_entrybar,L), profit); //choose
> >> which
> >> > value to assign to Sellprice
> >> >
> >> > Sellstop = 0; //reset values to 0
> >> >
> >> > BuyPrice = 0;
> >> >
> >> > }
> >> >
> >> > else
> >> >
> >> > Sell[i] = 0;
> >> >
> >> >
> >> >
> >> > ----- Original Message -----
> >> > From: "Beachie" <beachie41@xxxx>
> >> >
> >> >>
> >> >> OK,
> >> >>
> >> >> have kept at it, but just can't get my head around it. Below
is the pseudo code as
> >> my
> >> >> logic sees it. Obviously it doesn't work. Help appreciated.
> >> >>
> >> >> trig= Ref(H,-2) > Ref(H,-3) AND Ref(H,-3) > Ref(H,-4) ;//AND
Ref(L,-2) >= Ref(L,-3)
> >> AND
> >> >> Ref(L,-3) >= Ref(L,-4)
> >> >>
> >> >> sl = Optimize("sl", 0.006, 0.001, 0.015, 0.0005);
> >> >>
> >> >> profit = ApplyStop(stopTypeProfit, stopModePoint,Optimize
( "max. profit stop
> >> level",
> >> >> 0.002, 0.001, 0.015, 0.0005 ), 1,True );
> >> >>
> >> >> profit = 0;
> >> >>
> >> >> BuyPrice= 0;
> >> >>
> >> >> Sellstop = 0;
> >> >>
> >> >> Buy = trig;
> >> >>
> >> >> for( i = 0; i < BarCount; i++ )
> >> >>
> >> >> {
> >> >>
> >> >> if( BuyPrice == 0 && Buy[ i ] == 1 ) // A buy is signalled
> >> >>
> >> >> BuyPrice = ValueWhen(Buy[i+1],O); // read *next* value of
array after buy signal to
> >> get
> >> >> the "Buy on open, delay 1 " value
> >> >>
> >> >> Low_of_entrybar = ValueWhen(Buy [i+1], L) - sl; //entry bar
low value minus the
> >> 0.00x
> >> >> filter
> >> >>
> >> >> Sellstop = Cross(Low-Of_entrybar,C); //sell if close less
then Low_of_entrybar
> >> value
> >> >>
> >> >>
> >> >> if(Sellstop == 1 OR profit == 1) // test to see if either a
seelstop or profit stop
> >> >> value true
> >> >>
> >> >> {
> >> >>
> >> >> Sell [i] =1;
> >> >>
> >> >> SellPrice[i] = IIf(Sellstop,ValueWhen(Cross(Low-
Of_entrybar,L), profit); //choose
> >> which
> >> >> value to assign to Sellprice
> >> >>
> >> >> Sellstop = 0; //reset values to 0
> >> >>
> >> >> BuyPrice = 0;
> >> >>
> >> >> }
> >> >>
> >> >> else
> >> >>
> >> >> Sell[i] = 0;
> >> >>
> >> >> }
> >>
> >
> >
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/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/
|