is it possible to use a different deviation BB as a stop loss instrument. Say I want to enter short above the upper band of a standard BB with a target of crossing the middle line (average) and implimenting a close above a +3 deviation BB for a stop loss.
Hope that makes sense.
JSParticipant
Senior
Hi@LivJoJade
That’s possible…
DefParam CumulateOrders=False
n=20 //20 Days
xAvg=Average[n](Close)
xStd=Std[n](Close)
xBB2Up=xAvg+2*xStd
xBB3Up=xAvg+3*xStd
xBB2Down=xAvg-2*xStd
xBB3Down=xAvg-3*xStd
If Close Crosses Over xBB2Up then
SellShort 1 contract at Market
Set Target pProfit (xBB2Up-xAvg)
Set Stop pLoss(xBB3Up-xBB2Up)
EndIf
If Close Crosses Under xBB2Down then
Buy 1 contract at Market
Set Target pProfit (xBB2Down-xAvg)
Set Stop pLoss(xBB3Down-xBB2Down)
EndIf
JSParticipant
Senior
Hi@Livjojade
To avoid negative values, you must take the absolute values for the Stop Loss and the Take Profit… (or immediately fill in the right values… 😉 )
DefParam CumulateOrders=False
//n=20 //20 Days
xAvg=Average[n](Close)
xStd=Std[n](Close)
xBB2Up=xAvg+2*xStd
xBB3Up=xAvg+3*xStd
xBB2Down=xAvg-2*xStd
xBB3Down=xAvg-3*xStd
If Close Crosses Over xBB2Up then
SellShort 1 contract at Market
Set Target pProfit abs(xBB2Up-xAvg)
Set Stop pLoss abs(xBB3Up-xBB2Up)
EndIf
If Close Crosses Under xBB2Down then
Buy 1 contract at Market
Set Target pProfit abs(xBB2Down-xAvg)
Set Stop pLoss abs(xBB3Down-xBB2Down)
EndIf