GBPUSD 4H Force_Indicator Strategy

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #136156 quote
    Maurizio A.Maurizio A.
    Participant
    Average

    Hello everyone, this is my first strategy, based on the FORCE INDICATOR applied to GBPUSD timeframe 4H.
    The code is a draft that provides entry rules, trailing stops and money management.
    I submit it to your attention for corrections and integrations of improvements and suggestions.

    // Force indicator Strategy - GBPUSD timefrsme 4H
    // Concept Indicator by jebus89
    // Coding Indicator by Vonasi
    // Strategy by Maurizio Angius
    
    DEFPARAM CumulateOrders = false
    DEFPARAM Preloadbars = 1000
    
    //************************************************************************
    
    // Indicator
    //p = period used for the average
    //AveType = 0 to 6 --- 0=SMA 1=EMA 2=WMA 3=Wilder 4=Triangular 5=End point 6=Time series
    //STDstart = first STD of average to be used
    //STDmax = maximum STD of average to be used
    //STDstep = Step levels of STD used
    
    STDstart = 0.1
    STDmax= 10
    STDstep = 0.1
    
    if close > Average[p, AveType](close) then
    a = STDstart
    force = 0
    while a <= STDmax
    if close > Average[p, AveType](close) + a*std[p](close) then
    force = force + 1
    a = a + STDstep
    else
    break
    endif
    wend
    endif
    
    if close < Average[p, AveType](close) then
    a = -STDstart
    force = 0
    while a >= -STDmax
    if close < Average[p, AveType](close) + a*std[p](close) then
    force = force - 1
    a = a - STDstep
    else
    break
    endif
    wend
    endif
    
    ONCE NbBarLimit = 10
    
    //************************************************************************
    
    // Money Management
    
    Capital = 1000
    Risk = 0.01
    StopLoss = SL
    equity = Capital + StrategyProfit
    maxrisk = equity * Risk
    MinSize = 1
    PositionSize = max(MinSize, (maxrisk/StopLoss))
    
    //************************************************************************
    
    // entry long condition
    
    l1 = force[2] = 0
    l2 = force[1] > force[2]
    
    IF l1 and l2 THEN
    MyLimitBuy = high
    MyIndex = Barindex
    ENDIF
    
    IF BarIndex >= MyIndex + NbBarLimit THEN
    MyLimitBuy = 0
    ENDIF
    
    IF MyLimitBuy > 0 AND NOT LongOnMarket THEN
    BUY PositionSize CONTRACT AT MyLimitBuy STOP
    Set Stop Loss abs(close - lowest[20](low))
    SL = abs(close - lowest[20](low))/POINTSIZE
    
    ENDIF
    
    //************************************************************************
    
    // entry short condition
    
    s1 = force[2] = 0
    s2 = force[1] < force[2]
    
    IF s1 and s2 THEN
    MyLimitSell = low
    MyIndex = Barindex
    ENDIF
    
    IF BarIndex >= MyIndex + NbBarLimit THEN
    MyLimitSell = 0
    ENDIF
    
    IF MyLimitSell > 0 AND NOT ShortOnMarket THEN
    SELLSHORT PositionSize CONTRACT AT MyLimitSell STOP
    Set Stop Loss abs(close - highest[20](high))
    SL = abs(close - highest[20](high))/POINTSIZE
    ENDIF
    
    //************************************************************************
    
    //trailing stop function
    
    trailingstart = Tstart //trailing will start @trailinstart points profit
    trailingstep = 5 //trailing step to move the "stoploss"
    
    //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
    
    //************************************************************************
    GraHal, swedshare and keewee thanked this post
    schermata-alle-1592314266p84cl.png schermata-alle-1592314266p84cl.png Schermata-2020-06-16-alle-13.40.56.png Schermata-2020-06-16-alle-13.40.56.png Schermata-2020-06-16-alle-13.42.11.png Schermata-2020-06-16-alle-13.42.11.png Schermata-2020-06-16-alle-13.41.49.png Schermata-2020-06-16-alle-13.41.49.png Schermata-2020-06-16-alle-13.41.25.png Schermata-2020-06-16-alle-13.41.25.png Schermata-2020-06-16-alle-13.40.56-1.png Schermata-2020-06-16-alle-13.40.56-1.png Schermata-2020-06-16-alle-13.41.25-1.png Schermata-2020-06-16-alle-13.41.25-1.png Schermata-2020-06-16-alle-13.41.49-1.png Schermata-2020-06-16-alle-13.41.49-1.png Schermata-2020-06-16-alle-13.42.11-1.png Schermata-2020-06-16-alle-13.42.11-1.png
    #136438 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Thank you for sharing.

    I think it will be of interest to many of us in this community.

    #136462 quote
    GraHalGraHal
    Participant
    Master

    Seems very adaptable to Instruments and Timeframes.

    Results attached for DJI 15 mins, spread = 4.

    Didn’t have time to wait for full backtest, so attached is over 10k bars only.

    M.png M.png M2.png M2.png
Viewing 3 posts - 1 through 3 (of 3 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

GBPUSD 4H Force_Indicator Strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Maurizio A. @mau973 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/18/2020
Status: Active
Attachments: 6 files
ProRealCode ProRealCode
Loading...