PureBytes Links
Trading Reference Links
|
Graham,
below is also a way how it can be done (didn't check it in detail but the idea is there). But probably this is not what you are after. Anyway I think if you want to silve this using array-based calculation it is impossible,
ed
o yeah, watch them colours!!! hehehe I use white a lot because my background is black
procedure sell_proc(Buy,BuyPrice,exitLevel,open,high,low,close,per) {
global Sell;
global SellPrice;
global BuyAdjusted;
global exitLevelAdjusted;
// initialise arrays
Sell = SellPrice = 0;
BuyAdjusted = exitLevelAdjusted = Sell;
exitLevelAdjusted = O[ 0 ];
for (i = per; i < BarCount; i++) {
exitLevelAdjusted[ i ] = exitLevelAdjusted[ i - 1 ];
//
if (Buy[ i ] == 1) {
BuyAdjusted[ i ] = 1;
exitLevelAdjusted[ i ] = exitLevel[ i ];
// find a sell position + sellprice
for (j = i + 1; j < BarCount; j++) {
if (exitLevel[ j ] > exitLevelAdjusted[ j - 1]) {
exitLevelAdjusted[ j ] = exitLevel[ j ];
} else {
exitLevelAdjusted[ j ] = exitLevelAdjusted[ j - 1];
}
// test if profit stop is hit
if (Close[ j ] < exitLevelAdjusted[ j ]) {
Sell[ j ] = 1;
SellPrice[ j ] = Close[ j ];
// enter i-loop past the last sell
i = j;
// escape from j-loop
j = BarCount;
} else if (j == BarCount - 1) {
i = BarCount;
}
}
}
}
} // end procedure
SetBarsRequired(10000,10000);
// set period
per = 14;
Buy = Day()%5==0;
BuyPrice = C;
exitLevel = H-3*ATR(per);
sell_proc(Buy,BuyPrice,exitLevel,open,high,low,close,per);
Buy = BuyAdjusted;
Plot(C,"",colorwhite,64);
//Plot(exitLevel,"",colorwhite,1);
PlotShapes(shapeUpArrow*Buy,colorwhite,0,BuyPrice,0);
PlotShapes(shapeDownArrow*Sell,coloryellow,0,BuyPrice,0);
Plot( exitLevelAdjusted, "Exitprice", colorWhite,1);
Filter = 1;
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( exitLevelAdjusted , "ExitPriceAdjusted", 1.3);
AddColumn( exitLevelAdjusted<Ref(exitLevelAdjusted,-1) AND Buy==0, "check", 1);
----- Original Message -----
From: kaveman perth
To: amibroker@xxxxxxxxxxxxxxx
Sent: Friday, October 22, 2004 1:31 PM
Subject: Re: [amibroker] Exrem and Equity
Thanks, I was working on something similar, but if you get a sell on
the same day as a buy the buy registers although no signal is given.
This the next buy signal is not made.
On Fri, 22 Oct 2004 14:44:43 +1000, Scott Cong <scong@xxxxxxxxxx> wrote:
>
> kaveman perth wrote:
>
> >I guess if I just whited out everything I would not notice
> >discrepancies as well.
> >
> >I will try to explain myself again
> >
> >The exitprice acts like a trailing stop which is what it should do,
> >and the sell signal occurs when the price crosses below the exitprice.
> >The exitprice is based on the highest value of a variable after the
> >buy signal occurs. Any additional UNWANTED buy signals should be
> >removed by exrem or equity.
> >But when a variable like Exit as I have shown that is based on values
> >since a buy signal are not changed to just the first buy signal. They
> >keep being affected by the subsequent extra buy signals.
> >In the explore rersults below I have listed the buy/sell signals and
> >the Exitprice. The last column is a check on where the exitprice
> >dropped without an actual buy, just a buy that was exremmed. See
> >20/09/2004.
> >
> >Ticker Date/Time Buy Sell ExitPrice check
> >BSL 10/09/2004 1 0 7.984 0
> >BSL 13/09/2004 0 0 8.163 0
> >BSL 14/09/2004 0 0 8.163 0
> >BSL 15/09/2004 0 0 8.163 0
> >BSL 16/09/2004 0 0 8.163 0
> >BSL 17/09/2004 0 0 8.163 0
> >BSL 20/09/2004 0 0 8.088 1
> >BSL 21/09/2004 0 0 8.125 0
> >BSL 22/09/2004 0 0 8.184 0
> >BSL 23/09/2004 0 0 8.194 0
> >BSL 24/09/2004 0 0 8.293 0
> >BSL 27/09/2004 0 0 8.311 0
> >BSL 28/09/2004 0 0 8.311 0
> >BSL 29/09/2004 0 0 8.311 0
> >BSL 30/09/2004 0 0 8.322 0
> >BSL 1/10/2004 0 0 8.354 0
> >BSL 4/10/2004 0 0 8.439 0
> >BSL 5/10/2004 0 0 8.508 0
> >BSL 6/10/2004 0 0 8.508 0
> >BSL 7/10/2004 0 0 8.508 0
> >BSL 8/10/2004 0 0 8.512 0
> >BSL 11/10/2004 0 0 8.512 0
> >BSL 12/10/2004 0 0 8.512 0
> >BSL 13/10/2004 0 0 8.512 0
> >BSL 14/10/2004 0 1 8.512 0
> >
> >On Fri, 22 Oct 2004 05:29:41 +0200, ed nl <ed2000nl@xxxxxxx> wrote:
> >
> >
> >>Graham,
> >>
> >>I tested your code (changed some colours). I get exactly what one would expect. See all the arrows. Clearly the exit price falls because of Cross( Exit, C ); So when the exit line crosses above the close you sell (or when the close crosses BELOW the exit line).
> >>
> >>I don't understand why you wouldn't see the arrows. I use the latest beta version and no problems,
> >>
> >>rgds, Ed
> >>
> >>SetBarsRequired(10000,10000);
> >>Buy = Day()%5==0;
> >>Exit = HighestSince( Buy, H-3*ATR(14) );
> >>Sell = Cross( Exit, C );
> >>
> >>//Buy = ExRem( Buy, Sell );
> >>//Sell = ExRem( Sell, Buy );
> >>Equity(1);
> >>
> >>Plot(C,"",colorwhite,64);
> >>PlotShapes(shapeUpArrow*Buy,colorwhite,0,L,-10);
> >>PlotShapes(shapeDownArrow*Sell,coloryellow,0,L,-10);
> >>Plot( Exit, "Exitprice", colorWhite,1);
> >>
> >>
> >>
> >>Filter = 1;
> >>AddColumn( Buy, "Buy", 1 );
> >>AddColumn( Sell, "Sell", 1 );
> >>AddColumn( Exit , "ExitPrice", 1.3);
> >>AddColumn( exit<Ref(exit,-1) AND Buy==0, "check", 1);
> >>
> >> ----- Original Message -----
> >> From: kaveman perth
> >> To: amibroker@xxxxxxxxxxxxxxx
> >> Sent: Friday, October 22, 2004 12:32 AM
> >> Subject: [amibroker] Exrem and Equity
> >>
> >> I have a formula that uses the exit price based on
> >> HighestSince(Buy,H-xxx). I have noticed that using exrem or equity the
> >> buy signals don't show in explore or on charts, but any value based on
> >> them is affected
> >> I notice that the exit price which by its definition should only ever
> >> rise, not fall, until the sell signal occur. But at subsequent buy
> >> signals the exit price does fall even though these are not shown when
> >> you are using equity(1) or exrem(buy,sell)
> >> Has anyone come across this, and has a method to actually remove the
> >> unwanted signals
> >> Here is a small sample code to demonstrate
> >>
> >> Buy = Day()%5==0;
> >> Exit = HighestSince( Buy, H-3*ATR(14) );
> >> Sell = Cross( Exit, C );
> >>
> >> //Buy = ExRem( Buy, Sell );
> >> //Sell = ExRem( Sell, Buy );
> >> Equity(1);
> >>
> >> Plot(C,"",colorBlack,styleBar);
> >> PlotShapes(shapeUpArrow*Buy,colorGreen,0,L,-10);
> >> PlotShapes(shapeDownArrow*Sell,colorRed,0,L,-10);
> >> Plot( Exit, "Exitprice", colorViolet,styleDots|styleNoLine|styleNoRescale);
> >>
> >> Filter = 1;
> >> AddColumn( Buy, "Buy", 1 );
> >> AddColumn( Sell, "Sell", 1 );
> >> AddColumn( Exit , "ExitPrice", 1.3);
> >> AddColumn( exit<Ref(exit,-1) AND Buy==0, "check", 1);
> >>
> >> --
> >> Cheers
> >> Graham
> >> http://e-wire.net.au/~eb_kavan/
> >>
> >> Check AmiBroker web page at:
> >> http://www.amibroker.com/
> >>
> >> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> >>
> >>
> >> Yahoo! Groups Sponsor
> >> ADVERTISEMENT
> >>
> >>------------------------------------------------------------------------------
> >> Yahoo! Groups Links
> >>
> >> a.. To visit your group on the web, go to:
> >> http://groups.yahoo.com/group/amibroker/
> >>
> >> b.. To unsubscribe from this group, send an email to:
> >> amibroker-unsubscribe@xxxxxxxxxxxxxxx
> >>
> >> c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> >>
> >>
> >>[Non-text portions of this message have been removed]
> >>
> >>
> >>
> >>
> >>
> >>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
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> Graham,
>
> Here is a bit clumsy code.
>
> Entry = Day()%5==0;
> Exit1 = HighestSince( Entry, H - 3*ATR(14) );
> Stop = Cross(Exit1, C);
>
> Sequ = sign(BarsSince(Stop) - BarsSince(Entry));
>
> Buy = Entry AND Ref(Sequ, -1) < 0;
> Exit = HighestSince( Buy, H - 3*ATR(14) );
> Sequ = sign(BarsSince(Cross(Exit, C)) - BarsSince(Buy));
> Sell = Cross(Exit, C) AND Ref(Sequ, -1) > 0;
>
> //Buy = ExRem( Buy, Sell );
> //Sell = ExRem( Sell, Buy );
> //Equity(1);
>
> Plot(C,"",colorBlack,styleBar);
> PlotShapes(shapeUpArrow*Buy,colorGreen,0,L,-10);
> PlotShapes(shapeDownArrow*Sell,colorRed,0,H,-10);
> Plot( Exit, "Exitprice", colorViolet,styleDots|styleNoLine|styleNoRescale);
>
> Filter = 1;
> AddColumn( Buy, "Buy", 1 );
> AddColumn( Sell, "Sell", 1 );
> AddColumn( Exit , "ExitPrice", 1.3);
> AddColumn( exit<Ref(exit,-1) AND Buy==0, "check", 1);
>
> GraphXSpace = 5;
>
>
> 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
>
>
>
>
>
--
Cheers
Graham
http://e-wire.net.au/~eb_kavan/
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
b.. To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/
|