Discussing the strategy VECTORIAL DAX (M5)

Viewing 15 posts - 31 through 45 (of 1,264 total)
  • Author
    Posts
  • #92752 quote
    Balmora74
    Participant
    Veteran

     

    Hi Gianluca. What is the unit of the variable “c” ? is it un degree ?

    #92785 quote
    auvergnat
    Participant
    Veteran

    Hello everybody

    I am a bit disappointed with my last tests because I have only good results with dax index in 5TF, nothing good on nasdaq or cac and results are not strong on doji.

    Angle input does not seem to be adaptable ….easly

    Tof

    #92938 quote
    Zebra
    Participant
    Average

    Quick question as I’m pretty new to this:

    It seems like the only way the current position is closed is either via trailing stop (position is already in profit) or stop loss. However, I do get also smaller losses in the backtest which I can’t really pin to any part of the code. I’ve tried the modified version including Pauls suggestions.

    #92968 quote
    Balmora74
    Participant
    Veteran

    Hi Zebra. There is a other possibility for a position to be closed automatically. This is when the code detects a reverse position at the current position. Then the current position is closed and a other position is opened in the opposite direction. This can explain what you see in the backtest.

    Zebra thanked this post
    #92969 quote
    Zebra
    Participant
    Average

    Ah right, overlooked that as most of the strategies on the platform have a check for current open positions before they open a position to the opposite site. Thanks for the hint Balmora !

    #92985 quote
    Balmora74
    Participant
    Veteran

    To avoid this you can add condition in buy and sell conditions. For example IF NOT ONMARKET / IF NOT SHORTONMARKET / IF NOT LONGONMARKET

    but with my versus can you have a dynamic stop loss…

    #93394 quote
    winnie37
    Participant
    Veteran

    Hello,

    How could the strategy code be modified to have increasing lots taking into account reinvested profits?

    Thanks!

    #93399 quote
    Vonasi
    Moderator
    Master

    Hello, How could the strategy code be modified to have increasing lots taking into account reinvested profits? Thanks!

    Type ‘Money management’ in the search box and plenty of coding ideas will be available or try some of the Lot Size code snippets that can be found here:

    https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit#gid=0

    #93403 quote
    GraHal
    Participant
    Master

    Just for info … Cell G1 of the above sheet has the link given as

    Snippet Link Library  … if you ever need it Vonasi or anybody. 

    capgros thanked this post
    #93404 quote
    Vonasi
    Moderator
    Master

    Just for info … Cell G1 of the above sheet has the link given as

    Snippet Link Library … if you ever need it Vonasi or anybody.

    Way beyond my intelligence level – I just typed ‘Snippet Library’ in the search box!

    #93657 quote
    winnie37
    Participant
    Veteran

    I just don’t know how to code it… Could someone could add this to the paul version? Thanks

    #94166 quote
    winnie37
    Participant
    Veteran

    @ Jebus89 – did you try to run another optimization?

    #94176 quote
    Vonasi
    Moderator
    Master

    I just don’t know how to code it… Could someone could add this to the paul version? Thanks

    Here you go. It has three forms of position sizing and also a risk based position size multiplier that means size is increased more rapidly as profits increase. You can select all this by changing settings in lines 10 to 14.

    MoneyManagement =  Set to 0 for level stakes. Set to 1 for increasing stake size as profits increase and decreasing stake size as profits decrease. Set to 2 for increasing stake size as profits increase with stake size never being decreased.
    RiskManagement =      0 = risk management off and 1 = risk management on. I do not recommend using this it can blow up your account very easily!
    Capital =                         Starting capital
    MinBetSize =                 The minimum bet size allowed for the instrument.
    RiskLevel =                    A factor that changes how fast position size increases as profit increases. Only relevant if Risk Management is turned on.

    //ROBOT VECTORIAL DAX
    // M5
    // SPREAD 1.5
    // by BALMORA 74 - FEBRUARY 2019
    //Money Management added by Vonasi
    
    DEFPARAM CumulateOrders = false
    DEFPARAM Preloadbars = 50000
    
    MoneyManagement = 2
    RiskManagement = 0
    Capital = 10000
    MinBetSize = 1
    RiskLevel = 20
    
    Equity = Capital + StrategyProfit
    
    IF MoneyManagement = 1 THEN
    PositionSize = Max(MinBetSize, Equity * (MinBetSize/Capital))
    ENDIF
    
    IF MoneyManagement = 2 THEN
    PositionSize = Max(LastSize, Equity * (MinBetSize/Capital))
    LastSize = PositionSize
    ENDIF
    
    IF MoneyManagement <> 1 and MoneyManagement <> 2 THEN
    PositionSize = MinBetSize
    ENDIF
    
    IF RiskManagement THEN
    IF Equity > Capital THEN
    RiskMultiple = ((Equity/Capital) / RiskLevel)
    PositionSize = PositionSize * (1 + RiskMultiple)
    ENDIF
    ENDIF
    
    PositionSize = Round(PositionSize*100)
    PositionSize = PositionSize/100
    
    //VARIABLES
    CtimeA = time >= 080000 and time <= 220000
    CtimeB = time >= 080000 and time <= 220000
    ONCE BarLong = 950   //EXIT ZOMBIE TRADE LONG
    ONCE BarShort = 650  //EXIT ZOMBIE TRADE SHORT
    
    // TAILLE DES POSITIONS
    PositionSizeLong = 1 * positionsize
    PositionSizeShort = 2 * positionsize
    
    
    //STRATEGIE
    
    //VECTEUR = CALCUL DE L'ANGLE
    ONCE PeriodeA = 10
    ONCE nbChandelierA= 15
    MMA = Exponentialaverage[PeriodeA](close)
    ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierA
    ANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTE
    CondBuy1 = ANGLE >= 45
    CondSell1 = ANGLE <= - 37
    
    
    //VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILE
    ONCE PeriodeB = 20
    ONCE nbChandelierB= 35
    lag = 5
    MMB = Exponentialaverage[PeriodeB](close)
    pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierB
    trigger = Exponentialaverage[PeriodeB+lag](pente)
    CondBuy2 = (pente > trigger) AND (pente < 0)
    CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)
    
    
    
    //ENTREES EN POSITION
    CONDBUY = CondBuy1 and CondBuy2 and CTimeA
    CONDSELL = CondSell1 and CondSell2 and CtimeB
    
    
    //POSITION LONGUE
    IF CONDBUY THEN
    buy PositionSizeLong contract at market
    SET TARGET %PROFIT 4.25
    ENDIF
    
    //POSITION COURTE
    IF CONDSELL THEN
    Sellshort PositionSizeShort contract at market
    SET TARGET %PROFIT 1.25
    ENDIF
    
    //VARIABLES STOP SUIVEUR
    ONCE trailingStopType     = 1    // Trailing Stop - 0 OFF, 1 ON
    ONCE trailingstoplong     = 7.5    // Trailing Stop Atr Relative Distance
    ONCE trailingstopshort    = 4    // Trailing Stop Atr Relative Distance
    
    ONCE atrtrailingperiod    = 25  // Atr parameter Value
    ONCE minstop              = 0    // Minimum Trailing Stop Distance
    
    
    // TRAILINGSTOP
    //----------------------------------------------
    atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000
    trailingstartl = round(atrtrail*trailingstoplong)
    trailingstartS = round(atrtrail*trailingstopshort)
    if trailingStopType = 1 THEN
    TGL =trailingstartl
    TGS=trailingstarts
    if not onmarket then
    
    MAXPRICE = 0
    MINPRICE = close
    PREZZOUSCITA = 0
    ENDIF
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close)
    if MAXPRICE-tradeprice(1)>=TGL*pointsize then
    if MAXPRICE-tradeprice(1)>=MINSTOP then
    PREZZOUSCITA = MAXPRICE-TGL*pointsize
    ELSE
    PREZZOUSCITA = MAXPRICE - MINSTOP*pointsize
    ENDIF
    ENDIF
    ENDIF
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    if tradeprice(1)-MINPRICE>=TGS*pointsize then
    if tradeprice(1)-MINPRICE>=MINSTOP then
    PREZZOUSCITA = MINPRICE+TGS*pointsize
    ELSE
    PREZZOUSCITA = MINPRICE + MINSTOP*pointsize
    ENDIF
    ENDIF
    ENDIF
    if onmarket and PREZZOUSCITA>0 then
    EXITSHORT AT PREZZOUSCITA STOP
    SELL AT PREZZOUSCITA STOP
    ENDIF
    ENDIF
    
    //EXIT ZOMBIE TRADE
    IF POSITIONPERF<0 THEN
    IF shortOnMarket AND BARINDEX-TRADEINDEX(1)>= barshort THEN
    EXITSHORT AT MARKET
    ENDIF
    ENDIF
    
    IF POSITIONPERF<0 THEN
    IF LongOnMarket AND BARINDEX-TRADEINDEX(1)>= barlong THEN
    SELL AT MARKET
    ENDIF
    ENDIF
    
    winnie37 thanked this post
    #94190 quote
    Vonasi
    Moderator
    Master

    I hadn’t looked at this strategy much until I added my money management code to it in the last post. Whilst doing this it became obvious that there is one massive curve fit that makes performance look better than it is – and that is doubling the position size for short trades compared to long trades. The last 100K bars show that on the DAX there has been a definite down trend so this doubling of position size fits these bars just right but imagine what could happen if the next 100K bars have a definite up trend. You would be losing twice as much as you are winning. I would personally remove this position size doubling from the code.

    [attachment file=94191]

    Screenshot_1-1.png Screenshot_1-1.png
    #94193 quote
    Vonasi
    Moderator
    Master

    As a follow up to my last post – notice how it has failed to make any profit at all in what has been a strong recent up trend.

    [attachment file=”94194″]

    swedshare and kbot2021 thanked this post
    Screenshot_2-1.png Screenshot_2-1.png
Viewing 15 posts - 31 through 45 (of 1,264 total)
  • You must be logged in to reply to this topic.

Discussing the strategy VECTORIAL DAX (M5)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Balmora74 @balmora74 Participant
Summary

This topic contains 1,263 replies,
has 125 voices, and was last updated by VinzentVega
1 year ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/24/2019
Status: Active
Attachments: 470 files
Logo Logo
Loading...