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

[amibroker] Re: Set Stop for Low of Trade Bar



PureBytes Links

Trading Reference Links

below is an example that must help you with applystoploss

Stephane

_SECTION_BEGIN("ApplySTOP_StopLoss_Profit_Equity");
Title=Name() + " ApplyStop" ;
/* 
uncheck active stop immediat permet de sortir au prix des stops
si check alors la sortie est au close 
*/
BarsToTest = 1000;
Trade      = IIf((BarIndex() > (LastValue(BarIndex()) - 
BarsToTest)),1,0);
Buy= DayOfWeek()==5 AND Trade AND BarIndex()>9;
// ajout de barindex(period) pour eviter les buy signals alors que le 
stop n'est pas actif par ex atr(10) nec 10 bars
Sell=0;// exit on applystop
BuyPrice= C ;

ApplyStop (stopTypeProfit, stopModePoint, 2*ATR
(10) ,exitatstop=True,volatile=False,ReEntryDelay=1) ;
/* 
3eme param doit etre une valeur defini par 2eme param(stopmodepoint) 
à deduire de buyprice pour obtenir le niveau de stop.
4eme param si False, alors exit se fait sur le close price, si True 
alors exit se fait sur stop level à partir de High Low.
5eme param si False alors le stop basé sur ATR reste le meme pendant 
le trade, si True alors le stop varie pendant le trade.
6eme Param defini le nbre de bars nec pour une rentry
*/
ApplyStop (stopTypeLoss, stopModePoint, BuyPrice - (LLV
(L,1)),True,False,1) ; 

Equity(1,0);

Plot(Close,"close",IIf( Buy, colorGreen, IIf(Sell , 
colorRed ,1 )),64);
PlotShapes(IIf(Buy,
shapeUpArrow,shapeNone),colorGreen,0,C,-30); 
PlotShapes(IIf(Sell,
shapeDownArrow,shapeNone),colorRed,0,H,-30);

Plot(ValueWhen(Buy,BuyPrice+2*ATR(10)),"",colorBlue,1);
Plot(ValueWhen(Buy,LLV(L,1)),"",colorRed,1);


 
_SECTION_END();

> There must be a way of setting a stop to equal the low of the bar 
at 
> which a trade signal is given but I can't quite figure out how to 
put 
> the AFL functions together to achieve this.
> 
> I'm using    "Short = ExRem(Short,Cover);"  to restrict the 
> number of trade signals given and a normal applystop function that
> limits uses a 1% stop loss:
> 
> ApplyStop(stopTypeLoss,stopModePercent, 
>          Optimize( "Stop Loss ", 1, 1, 2, 1 ), 
>          True ); 
>  
> How would I set the loss at the value of the high of the bar at 
which 
> the short signal was generated. (or reverse for a buy)
> 
>   
> As Always - thanks for any suggestions or pointers.
> 
> 
> Regards to all
> 
> 
> Dean Hodgins




------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/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/