CCI setup

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #47027 quote
    camaleocamaleo
    Participant
    Junior

    Hello everyone

    i am trying to write a simple setup using CCI

    Everything is fine, except the exit orders…

    i would like to close positions on the CLOSE of the bar on the first day in profit.

    For now lets put a 5% stop

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = CCI[72]
    indicator2 = Average[5](CCI[72])
    indicator3 = BollingerDown[21](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    c2 = (close[3] > indicator3[3])
    c3 = (close[2] <= indicator3[2])
    c4 = (close[1] <= indicator3[1])
    
    
    
    IF c1 AND c2 AND c3 AND c4 THEN
    BUY 1 SHARES AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    c5 = (close > 0)   ????????????????????????
    
    IF c5 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator1 = CCI[72]
    indicator2 = Average[5](CCI[72])
    indicator3 = BollingerUp[21](close)
    c6 = (indicator1 CROSSES UNDER indicator2)
    c7 = (close[3] < indicator3[3])
    c8 = (close[2] >= indicator3[2])
    c9 = (close[1] >= indicator3[1])
    
    
    
    IF c6 AND c7 AND c8 AND c9 THEN
    SELLSHORT 1 SHARES AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    c10 = (close > 0)    ???????????????????????????
    
    IF c10 THEN
    EXITSHORT AT MARKET
    ENDIF

     

    Thank you everyone

    #47041 quote
    DespairDespair
    Blocked
    Master

    You can not sell on the close with PRT.

    #47044 quote
    JC_BywanJC_Bywan
    Moderator
    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! <<

    #47171 quote
    camaleocamaleo
    Participant
    Junior

    thank you for your answers

    if i cannot exit on close on PRT, i can set a time 5 minutes before close…

    the question is:

    How to set a condition to exit if the trade is in profit ?

    Thank you.

    #47176 quote
    OscJohOscJoh
    Participant
    Average

    Some ideas:

    Time based end of day exit (adjust to your market’s close)

    DefParam FlatAfter = 173000

    How to see if your current position is in gain, but it does not take transaction cost/slip into consideration as far as I know.

    IF PositionPerf(0) > 0.001 THEN
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

CCI setup


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
camaleo @camaleo Participant
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by OscJohOscJoh
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/23/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...