Follow The Price, Dax 1h

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #83343 quote
    Gianluca
    Participant
    Master

    Hi, i tried to code this simple sistem, the idea was took from others forum post, the buy order is placed when 2 average are in the same direction and last period was in trend.
    I am searching for some idea to improve the sistem and found more winning trades.
    TF 1h, Dax Cash CFD

    //Gianluca Albino @ PRC
    //22/10/2018 Dax Cash 1h
    //Thank to PRC forum for many code and idea that i would never found anywhere
    
    DEFPARAM CUMULATEORDERS = FALSE
    //1////////////////////////////////////////////////////////
    once trailinstop= 1   //1 on - 0 off
    trailingstart = 125 //trailing will start @trailinstart points profit
    trailingstep = 65 //trailing step to move the "stoploss"
    //////////////
    once breakeaven = 0    //1 on - 0 off
    startBreakeven = 125 //how much pips/points in gain to activate the breakeven function?
    PointsToKeep = 100 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
    //////////////////////////////////////////////////////////
    //4/////////
    ONCE EXCURSION=0
    trailingstop = 90
    
    TIMEOK= TIME> 150000 AND TIME < 170000
    AVG=AVERAGE[40]
    avg2=exponentialaverage[5]
    gann=CALL "PRC_Gann HighLow Activator"
    CONDAVGSHORT=0
    CONDAVGLONG=0
    condavglong2=0
    CONDAVGshort2=0
    f=10
    
    FOR C = 1 TO f
    IF avg2[C-1] > AVG[C] THEN
    CONDAVGLONG2 = 1
    else
    condavglong2=0
    endif
    NEXT
    FOR C = 1 TO f
    IF avg2[C-1] < AVG[C] THEN
    CONDAVGshort2 = 1
    else
    CONDAVGshort2=0
    endif
    NEXT
    FOR C = 1 TO f
    IF AVG[C-1] > AVG[C] THEN
    CONDAVGLONG = 1
    else
    condavglong=0
    endif
    NEXT
    FOR C = 1 TO f
    IF AVG[C-1] < AVG[C] THEN
    CONDAVGshort = 1
    else
    CONDAVGshort=0
    endif
    NEXT
    
    
    C1=(CLOSE<gann) AND CONDAVGSHORT>0 AND CONDAVGSHORT2>0  //(CLOSE<AVG and avg<avg[1] and avg[1]<avg[2]) and
    C2=(CLOSE>gann)and  CONDAVGLONG>0 and  CONDAVGLONG2>0//CLOSE >AVG and avg>avg[1] and avg[1]>avg[2] and CLOSE>gann
    
    LO1=ABS((HIGH[1] - LOW[2]))
    LO2=ABS((HIGH[2]- LOW[3]))
    LO3=ABS((HIGH[3]- LOW[4]))
    AVGL=(LO1+LO2+LO3)/3
    NEXTMIN=HIGH-AVGL
    AV2=ABS(HIGH-LOW)
    AVGVOLS=(AV2[2]+AV2[1]+AV2)/3
    NEWMAX=NEXTMIN+AVGVOLS
    
    IF NOT ONMARKET THEN
    IF C1 AND TIMEOK THEN
    SELLSHORT 1 CONTRACT AT NEXTMIN-(10*PIPSIZE) STOP
    ENDIF
    ENDIF
    
    IF NOT ONMARKET THEN
    IF C2 AND TIMEOK THEN
    BUY 1 CONTRACT AT NEWMAX+(5*PIPSIZE) STOP
    ENDIF
    ENDIF
     
    
    SET TARGET PPROFIT 170
    SET STOP PLOSS 90
    
    if dayofweek=5 and time>210000 then
    exitshort at market
    sell at market
    endif
    ///2///////////////////////////////////////////////
    //reset the breakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    //3////////////////////////////
    //test if the price have moved favourably of "startBreakeven" points already
    if breakeaven>0 then
    IF onmarket AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
     
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    endif
    
    //************************************************************************
    //trailing stop function
    if trailinstop>0 then
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    endif
    ///////////////////////////
    
    
    
    
    
    //4// MFE EXCURSION////
    //trailing stop
    
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
    
    IF EXCURSION>0 THEN
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
    
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    ENDIF
    

    [attachment file=”83346″]

    Nicolas thanked this post
    PRC_Gann-HighLow-Activator.itf Follow-The-Price.itf FollowThe-Price.jpg FollowThe-Price.jpg
    #83384 quote
    Jan
    Participant
    Veteran

    Hi,

    If  you have a calculated Stop order on a limited hour graph on Friday 20:00 hr, garantueed by PRT, will this last during the whole weekend ?  There are more real trading hours after 20:00 before the weekend begins, and a calculated Stop last just one bar.

    KR Jan

    =========== APPENDIX   If needed, further explanation of my question ==============================================

    Pro Real Time offers the opportunity to set a auto trading stop live with a garantueed stops, see attachet JPEG file, see the tickbox “Use garantueed Stops”

    If you are using this, the garantueed stop is also applicable for the programmed trailing stops (see below), as far as I could see at my strategy, the garantueed stops moves up in a long position when the price moves higher.

    To my understanding the programmed STOP last only one bar, after each bar it needs to be set again by calculating a new STOP on the next bar, which is done in the code below.

    If you limit the trading time in PRT, the bars in the graph will be less than the actual trading bars  :  for example set trading time in the graph 8:00 hr till 22:00 hr for the DAX means that the hourly bars in the graph are less then in actual trading.

    If you are using graph trading times, will the last programmed STOP of the day / before the weekend remains till the next graph based calculated STOP or erased by the next trading bar ?

    Example Calculated stop Friday 22:00 hr = 11.100 garantueed by PRT , will this last during the whole weekend ?

    Next calculated stop Monday 8:00 hr = 11.000

     

    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
     
    IF EXCURSION>0 THEN
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
     
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
     
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    ENDIF
    Autotrading-with-garantueed-stop.jpg Autotrading-with-garantueed-stop.jpg
    #83386 quote
    Gianluca
    Participant
    Master

    The stop guarantee by prt (but in real by ig) works also during the weekend. I’ve forgot the in order to use the srtategy you have to set the time of the instrument from 07:00 to 21 gt+2

    #83505 quote
    Gianluca
    Participant
    Master

    i checked with the rules of guarantee stop, and that is not possibile with a code like that kind of trailing, but only with commands “set stop ploss”

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

Follow The Price, Dax 1h


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Gianluca @altares Participant
Summary

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

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