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

[amibroker] Help with reentry after stopped out



PureBytes Links

Trading Reference Links

Hi 
I'm having a tough time coding a reentry after a protective stop was 
triggered.
Lets assume that my Buy signal was too early or the price moved 
against me ( I was stopped out)but then moved in my direction
however the 'system' already fired and I do not get a new buy.
I would like to reneter once my current price > initial BuyPrice
For example lets use 

 Buy = Cross( MACD(), 0 );
SellSig = Cross( 0, MACD() );
Buy = Ref(Buy, -1);
BuyPrice = Open; //defining what value the buy occurs at
Bp = ValueWhen(Buy, BuyPrice); //???is this the buy price?

protBStopLev=Bp-0.2;
protBStop=Cross(protBStopLev,C);
Sell=protBStop OR SellSig;
SellPrice=protBStopLev; //??? is this the sellPrice?
Sp = ValueWhen(Sell, SellPrice);//??? or this is the SellPrice?

Now here I get into trouble :)
Assuming that MACD() >0 and "current price (be taht the Close price 
of current bar)" is > Buyprice
how do i code the "new" buy?
like this?
Buy =Cross(C,Bp)AND MACD()>0; //

Filter=True ; 

AddColumn(Buy,"Buy ",1.2); 
AddColumn(Bp,"Bp  ",1.2); 
AddColumn(protBStop,"protBStop",1.0); 
AddColumn(protBStopLev,"protBStopLev",1.2); 
AddColumn(Sell,"Sell ",1.0); 
AddColumn(Sp,"Sp  ",1.2); 
AddColumn(Close,"Close",1.2); 
AddColumn(High,"High",1.2); 
AddColumn(Low," Low",1.2);

Am i missing something?

OR i should not bother with all this and just go by macd and 
protective stop?
However some short term back tests reveal that MACD >0 only gives 
more winning trades but with reentry I get a lot less winning trades 
but a much bigger profit

This is my first attempt of really doing something in AB with AFL on 
my own.. and I'm goin nuts.
See the "//???" above in the code where I'm kind of confused :)
So far I used only "canned" Indicators/Systems ot from this great 
board.
thanks
adrian

Any input greatly appreciated




Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/