PSEUDOSTOCHASTIC TRADE

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #63754 quote
    Leo
    Participant
    Veteran

    Hi all,

    I got an idea thanks to GraHal in another conversation and I could not go to sleep without testing.

    After several attempts  I got very nice code.

    I do not even let it run complete but please test it wherever and at whichever time frame

    PSEUDOSTOCHASTIC-TRADE-v1.0.itf
    #63757 quote
    Leo
    Participant
    Veteran

    I call it Pseudo stochastic because I sue the same period for calculate the three variables that define the stochastic.

    //STOCHASTIC TRADE v1.0
    //Autor: LEO
    
    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    DEFPARAM PreLoadBars = 10000 //cargar informacion
    
    //VARIABLES TO BE OPTIMIZED
    //Ps=21 //preiod for stochastic values
    //Slevel= 20 //stochastic signal
    //Pactive=3 //bars after stochastic signals
    //Kp=2 // Profit target to Kp times the stop loss
    //Psma=200 //Period for a SimpleMoving Average
    
    
    maxrisk0=20 //pips per trade to risk
    
    n=1
    maxrisk=maxrisk0+(n-1)*2
    totalrisk=10*maxrisk*PIPVALUE //for stop the robot if things are going bad
    
    
    spread=0.7
    IF TIME < 060000 THEN //(germany time)
    spread=1.7*spread
    ELSIF TIME>214500 THEN //(germany time)
    spread=1.7*spread
    ENDIF
    
    //Robot Working Time (Germany)
    IF TIME>050000 and TIME < 220000 THEN
    ontime=1
    ELSE
    ontime=0
    ENDIF
    
    ////// RISK CONTROL IF THINGS ARE GOING WONDERFULL  //////
    //n = 1 + (strategyprofit / (77*pipvalue))
    //n = round(n * 100)
    //n = n / 100
    //n = max(1,n)
    
    //--------------------------------------------------------
    //>>>>>>>>>>>>>>>>>>     INDICATORS    <<<<<<<<<<<<<<<<<<<<<
    //--------------------------------------------------------
    
    
    SMA=average[Psma](close)
    TYPICALDAY=(DHIGH(1)+DLOW(1)+Dclose(1))/3
    
    mystoch=Stochastic[Ps,Ps](close)
    StochD=Average[Ps](myStoch)
    
    
    //--------------------------------------------------------
    //>>>>>>>>>>>>>>>>>>     TRADING     <<<<<<<<<<<<<<<<<<<<<
    //--------------------------------------------------------
    
    a0=myStoch crosses over StochD
    a1=highest[Pactive](a0)=1
    a2=lowest[Pactive+1](mystoch) < Slev
    a3=close > TYPICALDAY
    a4=close > SMA
    
    
    If a1 and a2 and a3 and a4 then
    IF NOT LongOnMarket AND ontime=1 and DayOfWeek <= 5 THEN
    //entrylong=high+0.5*spread*pipsize
    stoplosslong=(close-lowest[Ps](low))/pipsize+spread
    stoplosslong=min(stoplosslong,maxrisk)
    BUY n CONTRACTS AT market//entrylong STOP
    SET STOP pLOSS stoplosslong
    SET TARGET pPROFIT Kp*stoplosslong
    ENDIF
    ENDIF
    
    b0=myStoch crosses under StochD
    b1=highest[Pactive](b0)=1
    b2=highest[Pactive+1](mystoch) > 100-Slev
    b3=close < TYPICALDAY
    b4=close<SMA
    
    IF b1 and b2 and b3 and b4 then
    //entryshort=low-0.5*spread*pipsize
    stoplossshort= (highest[Ps](high)-close)/pipsize+spread
    stoplossshort= min(stoplossshort, maxrisk)
    IF NOT ShortOnMarket AND ontime=1 and DayOfWeek <= 5 THEN
    SELLSHORT n CONTRACTS AT market //entryshort STOP
    SET STOP pLOSS StopLossShort
    SET TARGET pPROFIT Kp*StopLossShort
    ENDIF
    ENDIF
    
    //---------------------------------------------------------
    //>>>>>>>>>>>>>>>>>>   EXIT POSITIONS    <<<<<<<<<<<<<<<<<<
    //---------------------------------------------------------
    
    mySAR=SAR[0.007,0.007,0.7]
    // ---> exit long
    IF longonmarket then
    
    IF close < lowest[Ps](low[1]) THEN
    SELL AT MARKET
    ENDIF
    
    IF close crosses under MySAR THEN
    SELL AT MARKET
    ENDIF
    
    IF b0 and close>POSITIONPRICE THEN
    SELL AT MARKET
    ENDIF
    
    IF close > (POSITIONPRICE+0.5*stoplosslong*pipsize) and close>mySAR then
    SET STOP pLOSS min((close-MySAR)/pipsize+2*spread, maxrisk)
    ENDIF
    
    IF TIME > 224500 and DayOfWeek=5 then
    SELL AT MARKET
    ENDIF
    endif
    
    // ---> exit long
    IF shortonmarket then
    
    IF close > highest[Ps](high[1])  THEN
    EXITSHORT AT MARKET
    ENDIF
    
    IF close crosses over MySAR THEN
    EXITSHORT AT MARKET
    ENDIF
    
    IF a0 and close < POSITIONPRICE then
    EXITSHORT AT MARKET
    ENDIF
    
    IF close < (POSITIONPRICE-0.5*StopLossShort*pipsize) and close<mySAR then
    SET STOP pLOSS min( (MySAR-close)/pipsize+2*spread , maxrisk)
    ENDIF
    
    IF TIME > 224500 and DayOfWeek=5 then
    EXITSHORT AT MARKET
    ENDIF
    endif
    
    //Quit the robot if things are going bad
    Q=MAX(Q,(STRATEGYPROFIT/pipvalue/n))
    R=Q-STRATEGYPROFIT/pipvalue/n
    IF R > totalrisk THEN
    QUIT
    ENDIF
    
    IF STRATEGYPROFIT < (-1*totalrisk) THEN
    QUIT
    ENDIF
    
    Eric and raphaelopilski thanked this post
    Screen-Shot-2018-02-23-at-22.32.08.png Screen-Shot-2018-02-23-at-22.32.08.png
    #63834 quote
    Leo
    Participant
    Veteran

    last version

    raphaelopilski thanked this post
    PSEUDOSTOCHASTIC-TRADE-v1.1.itf
    #63840 quote
    GraHal
    Participant
    Master

    @Leo

    Sorry for delay, I’ve been busy doing family jobs today, but I wish I’d set it going / optimising while I was doing other stuff! 🙂

    Even early results (over 90% yet to do) look good!!!

    Does v1.1 supercede V1.0 as I was going to run both to see the improvement, but I may as well kill v1.0 and optimise v1.1?

    Many Thanks
    GraHal

    #63846 quote
    GraHal
    Participant
    Master

    Attached V1.1 on eurusd @ 5 min over 100k bars @ £1 per point SB

    Just a couple of thoughts … most of the gain is made by 4 or 5 trades (out of 25 winning) and most of the losing trades don’t lose much … hence the long flattish periods.

    Maybe a time condition might help?

    More tomoz maybe

    Cheers
    GraHal

    Leo-4.jpg Leo-4.jpg Leo-5.jpg Leo-5.jpg
    #63888 quote
    Leo
    Participant
    Veteran

    Hi, GraHal,

    v1.1 use two average for filtering.

    I do not know what else to do for filter those losing trading

    #64047 quote
    GraHal
    Participant
    Master

    V1.1 on DJI @ 1Min TF over 100,000 bars.

    Clearly a lot of the gain was made during that big drop and retrace early Feb, but it was  both Long and Short during that time and volatile times could be here to stay for a while?

    I’ve set it Live but will monitor each trade as soon as it is triggered.

    Cheers
    GraHal

    PS variable settings can seen in the image

    Leo-6.jpg Leo-6.jpg
    #64077 quote
    Gertrade
    Participant
    Veteran

    I do not know what else to do for filter those losing trading

    I made some improvements that increase the ratio Gain / Loss and therefore the yield on DJI Indice.

    I used the TF28s, if that does not suit you an optimization of variables is possible with a TF1mn or other.

    cordially

    Gertrade

    GraHal thanked this post
    PSEUDOSTOCHASTIC-DJI-28s-v1.13.itf
    #64088 quote
    Leo
    Participant
    Veteran

    Gertrade your are becoming a legend in the 28 second time frame!

    I test exactly your code in EUR/USD and is also profitable.

    You have two set of variables, can you tell me please how is your method for optimising those variables

    Thanks

    Gertrade thanked this post
    #64090 quote
    Gertrade
    Participant
    Veteran

    You have two set of variables, can you tell me please how is your method for optimising those variables

    Thanks for the legend TF28s!
    For the variables I realized that the variables could be different when one is above or below the equity curve.
    To save time, I do not like you optimize all the variables together, I optimize each variable individually on 20,000 units (maximum history on TF28s).
    I am at your disposal if you have any other questions.

    cordially

    Gertrade

    #64173 quote
    Gertrade
    Participant
    Veteran

    Hi Leo,

    I just finished v1.14 for the EURUSD, I did some optimization of variables and I improved the code to increase the yield. I remain faithful to the TF28s to preserve the legend Gertrade.

    below the v1.14 on TF28s for the EURUSD.

    PSEUDOSTOCHASTIC-EU-28s-v1.14.itf
    #64177 quote
    GraHal
    Participant
    Master

    @Leo you’ve started something now! 🙂

    I thought at one point a few days ago I was just about steering Gertrade off the ‘maverick’ timeframe 28 Sec … but no chance now he’s the Legend! 🙂

    I see you’ve gone back to the (unrealistic)  eurusd 0.7 spread though Gertrade? I thought you’d convinced yourself that spread of 2 is more realistic on eurusd?

    #64179 quote
    Gertrade
    Participant
    Veteran

    I thought you’d convinced yourself that spread of 2 is more realistic on eurusd?

    This is an oversight, I am convinced that the Spread of 0.7 is not realistic, but as Leo had treated it with a piece of code, I left like that.

    I launched this v1.14 EURUSD strategy on ProOrder Demo Account, I wait to see the first results to make a comparison with the backtests.

    The DJI v1.13 strategy on ProOrder Demo Account is profitable and I am fully satisfied (I’m still waiting a few days to publish results).

    #64871 quote
    Gertrade
    Participant
    Veteran

    Hi everybody,

    Already 1 week have passed and I publish you my first results of the DJI v1.13 (on CFD Wall Street Cash 2 $) on ProOrder Demo Account. It is very encouraging to see this equity curve grow. Long live this strategy !!! She seems to me robust. I will post other results of the equity curve week after week.

    cordially
    Gertrade

    PSEUDOSTOCHASTIC-28-sec-V1.13-27-02-09-03-Stats-ProOrder.jpg PSEUDOSTOCHASTIC-28-sec-V1.13-27-02-09-03-Stats-ProOrder.jpg PSEUDOSTOCHASTIC-28-sec-V1.13-27-02-09-03-Equity-Curve-ProOrder-10000-units.jpg PSEUDOSTOCHASTIC-28-sec-V1.13-27-02-09-03-Equity-Curve-ProOrder-10000-units.jpg
    #64878 quote
    Leo
    Participant
    Veteran

    Cool! Looks very nice indeed!

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

PSEUDOSTOCHASTIC TRADE


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Leo @leito Participant
Summary

This topic contains 14 replies,
has 3 voices, and was last updated by Leo
7 years, 12 months ago.

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