Relative buy signal (Bollinger)

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #82968 quote
    CJMolin
    Participant
    New

    Hello!

    I’m a rookie when it comes to trading but I’m very interested in evolving within this area.

    I just started to use PRT and I would like to find a good automatic strategy (don’t we all?). The way I’m trying to configure my strategy isnt really working because I need to enter the code-console and modify the code to be a little bit more complex than the regular UI allows me to build.

    Is there any kind soul out there that would bother to help me with the code?

    Criterias (see attached picture for number examples [1224.35] / [1227.00]):

    • EXAMPLE: Go long WHEN; [Price (X)] / [Bolinger – (Y)] <= 0,99
    • EXAMPLE: Go short WHEN; [Price (X)] / [Bolinger + (Z)] >= 1,01

     

    I would very much appreciate help solving this!

    Thanks in advance,

    CJ

    CFD_BOLLINGER.png CFD_BOLLINGER.png
    #82974 quote
    Nicolas
    Keymaster
    Master

    I assume Y and Z are in points/pips?

    Do you want a simple indicator that plot the signals on the price chart or a complete automatic trading system?

    #82976 quote
    CJMolin
    Participant
    New

    Hello Nicolas,

     

    Y and Z are points yes. Im trying to use this for backtesting as a start. I’ve tried to write some code by my own but it doesnt seem to do that I want.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    GoLong = close/BollingerDown[20](close)
    
    c1 = (GoLong >= 0.9984)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    
    GoShort = close/BollingerUp[20](close)
    c2 = (GoShort <= 1.001)
    
    IF c2 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 4
    SET TARGET pPROFIT 6
    #82977 quote
    Nicolas
    Keymaster
    Master

    For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<

    Well, firstly did you try to graph your conditions?

    graph c1 as "buy condition"
    graph c2 as "sell condition"

    So that you see clearly when a condition is met or not.

    #82981 quote
    CJMolin
    Participant
    New

    Oh thank you. I will do that in the future.

    Yes I have tried to backtest it. currently im trying out the long-position.

    As you can see in the attached picture you can see the code. Im trying to get -> IF price / bollinger down, in this example bollinger down is 1185 and price is 1183. 1183 / 1185 = 0,998. In the code im trying to specify so that take LONG position if the quote of price / bollinger down < 0.999 which would then go long in this example.. but it doesnt! Any clue why? Thank you for your fast replies btw!

    GoLong = close/BollingerDown[20](close)
    
    c1 = (GoLong < 0.999)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    goldlong.png goldlong.png
    #82988 quote
    Nicolas
    Keymaster
    Master

    Got hundreds of positions when I try your strategy. What timeframe and instrument did you test?

    order-trigger-bollinger-bands-width.png order-trigger-bollinger-bands-width.png
    #83045 quote
    CJMolin
    Participant
    New

    Hello,

    I was trying to apply it on Gold 15  min. But although my attached example above was not triggered.. So it seem to be something wrong with my code, dont you think when looking at the example above? Thank you for trying out the code in your system!

    #83062 quote
    CJMolin
    Participant
    New

    Hi again Nicolas,

     

    Basically what I want to do is a) Measure the difference between PRICE (not closing price) and BOLLDOWN. If the quota of these two variables (PRICE / BOLLDOWN) are for example <= 0,97 THEN I would like to go long with 1 contract. It feels like my code should do the work but when validating it by taking samples it doesnt take positions where I want it to.

     

    Thank you,

    CJ

    goldexample6.png goldexample6.png
    #83084 quote
    Nicolas
    Keymaster
    Master

    Ok, I modify the logic of your code, I made 2 settings for the orders to trigger if the Close exceed the Bollinger Down (for a buy order) or the Bollinger Upper band (for a short order). The triggers are in percentage.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    buypercent = 0.1
    sellpercent = 0.1
    
    bc = (bollingerdown[20]-close)/bollingerdown[20]
    sc = (close-bollingerup[20])/bollingerup[20]
    
    if bc>=buypercent/100 then 
    buy at market 
    endif 
    
    if sc>=sellpercent/100 then
    sellshort at market 
    endif 
    
    set target pprofit 10
    set stop ploss 20
    #83167 quote
    CJMolin
    Participant
    New

    Thank you very much. It does what I want it to 🙂 Very very much appreciated! you’re a pro!

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

Relative buy signal (Bollinger)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
CJMolin @cjmolin Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by CJMolin
7 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/17/2018
Status: Active
Attachments: 4 files
Logo Logo
Loading...