using bollybands as a stop loss

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #206201 quote
    LivJoJade
    Participant
    New

    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.

    #206204 quote
    JS
    Participant
    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

    #206207 quote
    JS
    Participant
    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
    

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

using bollybands as a stop loss


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
LivJoJade @livjojade Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by JS
3 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/22/2022
Status: Active
Attachments: No files
Logo Logo
Loading...