start trading 09:00:00 – CCI trading strategy

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #12208 quote
    groen200
    Participant
    Veteran

    this is my code trade the cci strategy

    but i will start directly at 09:00:00 in the same direction from the cci , when the price below the cci -100 we start short, when the price above the 100

    we start long.

    tks

    luc

     

    // Definition of code parameters
    //"START CCI "
    //X MINIMAL VALUE 14  MAXIMAL VALUE 70 STEP 2
    //ORDER FEE =2.5€
    //starting date = 18 jul 20116 01:00:00
    //ending date = real time date
    
    DEFPARAM CumulateOrders = true// Cumulating positions deactivated
    
    DEFPARAM FLATBEFORE=090000
    DEFPARAM FLATAFTER=120000
    dayprofitmax=1500
    daylossmax=195
    
    if intradaybarindex=0 then
    trading=1
    lastdayprofit=strategyprofit
    endif
    
    if trading=1 then
    if (not onmarket and (strategyprofit > lastdayprofit+dayprofitmax or strategyprofit < lastdayprofit-daylossmax)) or (longonmarket and (strategyprofit+((close-tradeprice)/pointsize*countoflongshares*pointvalue) > lastdayprofit+dayprofitmax or strategyprofit+((close-tradeprice)/pointsize*countoflongshares*pointvalue) < lastdayprofit-daylossmax)) or (shortonmarket and (strategyprofit+((tradeprice-close)/pointsize*countofshortshares*pointvalue) > lastdayprofit+dayprofitmax or strategyprofit+((tradeprice-close)/pointsize*countofshortshares*pointvalue) < lastdayprofit-daylossmax)) then
    trading=0
    //sell at market
    //exitshort at market
    QUIT
    endif
    endif
    // Conditions to enter long positions
    indicator1 = CCI[50]
    c1 = (indicator1 CROSSES OVER -100)
    //c11 = (indicator1 CROSSES OVER 100)
    IF c1   THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator2 = CCI[50]
    c2 = (indicator2 CROSSES UNDER 100)
    //c21 = (indicator2 CROSSES UNDER -100)
    IF c2  THEN
    SELL  AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator3 = CCI[50]
    c3 = (indicator3 CROSSES UNDER 100)
    //c31 = (indicator3 CROSSES UNDER -100)
    IF c3  THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator4 = CCI[50]
    c4 = (indicator4 CROSSES OVER -100)
    //c41 = (indicator4 CROSSES OVER 100)
    IF c4  THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // Stops and targets
    //SET STOP $LOSS 100
    //set stop $loss 100 trailing 50
    //if strategyprofit < -150 then
    //quit
    //endif
    //if strategyprofit > 1000 then
    //quit
    //endif
    //set stop trailing 12
    Germany-30-Cash-EUR-5-Mini-Contract-.png Germany-30-Cash-EUR-5-Mini-Contract-.png
    #12215 quote
    Nicolas
    Keymaster
    Legend

    So if I understand well your request, you want to directly open trade in the direction of the CCI at 09:00:00? You don’t want to wait a cross over or under the 100/-100 CCI value?

    #12221 quote
    groen200
    Participant
    Veteran

    yes, you make also this code entry for the supertrend

    #12222 quote
    groen200
    Participant
    Veteran
    / Definitie van code parameters
    DEFPARAM CumulateOrders = false// Opstapelen posities gedeactiveerd
    DEFPARAM FLATBEFORE=090000
    DEFPARAM FLATAFTER=120000
    
    dayprofitmax=1500
    daylossmax=190
    
    if intradaybarindex=0 then
    trading=1
    lastdayprofit=strategyprofit
    endif
    
    if trading=1 then
    if (not onmarket and (strategyprofit > lastdayprofit+dayprofitmax or strategyprofit < lastdayprofit-daylossmax)) or (longonmarket and (strategyprofit+((close-tradeprice)/pointsize*countoflongshares*pointvalue) > lastdayprofit+dayprofitmax or strategyprofit+((close-tradeprice)/pointsize*countoflongshares*pointvalue) < lastdayprofit-daylossmax)) or (shortonmarket and (strategyprofit+((tradeprice-close)/pointsize*countofshortshares*pointvalue) > lastdayprofit+dayprofitmax or strategyprofit+((tradeprice-close)/pointsize*countofshortshares*pointvalue) < lastdayprofit-daylossmax)) then
    trading=0
    //sell at market
    //exitshort at market
    QUIT
    endif
    endif
    //indi
    st = SuperTrend[2.8,5]
    //resetting variable
    once lasttrade = 0
    
    IF LONGONMARKET then
    lasttrade = 1
    elsif SHORTONMARKET then
    lasttrade = -1
    elsif hour<9 OR hour>12 then
    lasttrade = 0
    endif
    
    // Condities om long posities te openen
    IF close>st AND lasttrade<>1 THEN
    EXITSHORT AT MARKET
    if trading>0 then
    BUY 1 LOT AT MARKET nextbaropen
    endif
    ENDIF
    
    // Condities om long posities te sluiten
    IF close<st AND lasttrade<>-1 THEN
    SELL AT MARKET
    if trading>0 then
    SELLSHORT 1 lot at market nextbaropen
    endif
    ENDIF
    //set stop $loss 100 trailing 50
    //SET STOP $TRAILING 50
    SET STOP $loss 100
    

    yes, you make also this code entry for the supertrend

    #12239 quote
    Nicolas
    Keymaster
    Legend

    Replace the line 30 of your code with:

    c1 = indicator1 > 100

    and the line 46 with:

    c3 = indicator3 < -100

    Now the CCI cross is no longer used. We only test if the CCI is above or below the threshold levels you defined.

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

start trading 09:00:00 – CCI trading strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
groen200 @groen200 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Nicolas
10 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/25/2016
Status: Active
Attachments: No files
Logo Logo
Loading...