Hi friends,
Here are some simple AFL's for the three types of stoploss - Initial, Breakeven and Trailing stoploss.
1. Initial stoploss
/****************************************************
Initial Stoploss - lowest "low" of the last n bars
*****************************************************/
lookbackPeriod = Param("Lookback period", 2, 2, 30);
Plot(LLV(L,lookbackPeriod), "Testing", ParamColor( "Long", colorGrey40));
2. Breakeven stoploss
/*******************************************************
Breakeven Stoploss - Open + brokerage% of open
********************************************************/
brokeragePercentage = Param("Brokerage Percentage", 1, 0.1, 5, 0.1);
Plot(O + O*(brokeragePercentage/100) , "Testing", ParamColor( "Long", colorYellow ));
3. Trailing stoploss
/****************************************************
Trailing Stoploss - a% below nth highest high
*****************************************************/
lookbackPeriod = Param("Lookback period", 10, 2, 30);
stoplossPercentage = Param("Stoploss Percentage", 5, 0.2, 10, 0.2);
Plot(HHV(H,lookbackPeriod) - HHV(H,lookbackPeriod) * (stoplossPercentage / 100), "Bullish SL", ParamColor( "Long", colorGrey40));
Plot(LLV(L,lookbackPeriod) + LLV(L,lookbackPeriod) * (stoplossPercentage / 100), "Bearish SL", ParamColor( "Short", colorGrey40));
I will post the AFL's as and when I come up with any new ones.
Thanks,
Praveen.
Here are some simple AFL's for the three types of stoploss - Initial, Breakeven and Trailing stoploss.
1. Initial stoploss
/****************************************************
Initial Stoploss - lowest "low" of the last n bars
*****************************************************/
lookbackPeriod = Param("Lookback period", 2, 2, 30);
Plot(LLV(L,lookbackPeriod), "Testing", ParamColor( "Long", colorGrey40));
2. Breakeven stoploss
/*******************************************************
Breakeven Stoploss - Open + brokerage% of open
********************************************************/
brokeragePercentage = Param("Brokerage Percentage", 1, 0.1, 5, 0.1);
Plot(O + O*(brokeragePercentage/100) , "Testing", ParamColor( "Long", colorYellow ));
3. Trailing stoploss
/****************************************************
Trailing Stoploss - a% below nth highest high
*****************************************************/
lookbackPeriod = Param("Lookback period", 10, 2, 30);
stoplossPercentage = Param("Stoploss Percentage", 5, 0.2, 10, 0.2);
Plot(HHV(H,lookbackPeriod) - HHV(H,lookbackPeriod) * (stoplossPercentage / 100), "Bullish SL", ParamColor( "Long", colorGrey40));
Plot(LLV(L,lookbackPeriod) + LLV(L,lookbackPeriod) * (stoplossPercentage / 100), "Bearish SL", ParamColor( "Short", colorGrey40));
I will post the AFL's as and when I come up with any new ones.
Thanks,
Praveen.