Pause system X time after Y losses

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #203853 quote
    SnorreDK
    Participant
    Junior

    Hi.

    I need help to make this possible for a 6min-algo

    Pause system X time after Y losses

     

    X= variable in minutes , bars or hours

    Y=variable count of losses (1-10)

    #203856 quote
    SnorreDK
    Participant
    Junior

    See picture.

    #203866 quote
    SnorreDK
    Participant
    Junior

    This one did not work:

    positionperf2 = positionperf(1)
    graph positionperf
    graph positionperf(1) coloured (255,0,0)
    
    if positionperf2<positionperf2[1] then
    if (positionperf2 > 0) then
    lossrunno = 0
    buysignal = barindex
    winrunno = (winrunno + 1)
    endif
    
    if (positionperf2 < 0) then
    winrunno = 0
    lossrunno = (lossrunno + 1)
    endif
    endif
    
    if lossrunno=1 then
    distancebuysignal=(Barindex-buysignal)
    endif
    
    if lossrunno=1 and (distancebuysignal > x)  then
    lossrunno=0
    endif
    
    if (lossrunno=0) then
    If MyConditionLong  then 
    Buy PositionSize CONTRACTS AT MARKET
    SET STOP %LOSS sll
    ENDIF
    If MyConditionShort then
    sellshort PositionSize CONTRACTS AT MARKET
    SET STOP %LOSS sls
    ENDIF
    endif
    #203873 quote
    robertogozzi
    Moderator
    Master

    There you go:

    ONCE MaxLosses = 2     //Y losses
    ONCE PauseBars = 30    //X bars to pause
    ONCE Losses    = 0
    ONCE BarStart  = 0
    MyLongConditions  = close CROSSES OVER  average[20,0](close) AND Not OnMarket
    MyShortConditions = close CROSSES UNDER average[20,0](close) AND Not OnMarket
    IF StrategyProfit > StrategyProfit[1] THEN
       Losses   = 0
       BarStart = 0
    ELSIF StrategyProfit < StrategyProfit[1] THEN
       Losses   = Losses + 1
       IF Losses = MaxLosses THEN
          BarStart = BarIndex
          Losses   = 0
       ENDIF
    ENDIF
    IF (BarIndex - BarStart) >= PauseBars THEN
       BarStart = 0
    ENDIF
    IF MyLongConditions  AND BarStart = 0 THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    IF MyShortConditions AND BarStart = 0 THEN
       SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    SET STOP   pLOSS   100
    SET TARGET pPROFIT 300
    SnorreDK thanked this post
    #203896 quote
    SnorreDK
    Participant
    Junior

    Thanks robberto. it seems to work on the trades of same direction but not the oposit direction:

    See attached

     

    ONCE MaxLosses = 1     //Y losses
    ONCE PauseBars = x    //X bars to pause
    ONCE Losses    = 0
    ONCE BarStart  = 0
    
    IF StrategyProfit > StrategyProfit[1] THEN
    Losses   = 0
    BarStart = 0
    ELSIF StrategyProfit < StrategyProfit[1] THEN
    Losses   = Losses + 1
    IF Losses = MaxLosses THEN
    BarStart = BarIndex
    Losses   = 0
    ENDIF
    ENDIF
    IF (BarIndex - BarStart) >= PauseBars THEN
    BarStart = 0
    ENDIF
    
    
    if BarStart =0 then
    If MyLongCond then
    Buy PositionSize CONTRACTS AT MARKET
    SET STOP %LOSS sll
    ENDIF
    If MyShortCond  then
    sellshort PositionSize CONTRACTS AT MARKET
    SET STOP %LOSS sls
    ENDIF
    endif

    I even tried this:

    If MyLongCond and BarStart =0 then
    Buy PositionSize CONTRACTS AT MARKET
    SET STOP %LOSS sll
    ENDIF
    If MyShortCond and  BarStart =0 then
    sellshort PositionSize CONTRACTS AT MARKET
    SET STOP %LOSS sls
    ENDIF
    #204018 quote
    robertogozzi
    Moderator
    Master

    This one works like a charm:

    ONCE MaxLosses = 3     //Y losses
    ONCE PauseBars = 30    //X bars to pause
    ONCE Losses    = 0
    ONCE BarStart  = 0
     
    MyLongCond  = close CROSSES OVER  average[20,0](close) AND Not OnMarket
    MyShortCond = close CROSSES UNDER average[20,0](close) AND Not OnMarket
    
    IF StrategyProfit > StrategyProfit[1] THEN
    Losses   = 0
    BarStart = 0
    ELSIF StrategyProfit < StrategyProfit[1] THEN
    Losses   = Losses + 1
    IF Losses = MaxLosses THEN
    BarStart = BarIndex
    Losses   = 0
    ENDIF
    ENDIF
    IF (BarIndex - BarStart) >= PauseBars THEN
    BarStart = 0
    ENDIF
     
     
    if BarStart = 0 then
    If MyLongCond then
    Buy 1 CONTRACTS AT MARKET
    SET STOP %LOSS 0.1
    ENDIF
    If MyShortCond  then
    sellshort 1 CONTRACTS AT MARKET
    SET STOP %LOSS 0.1
    ENDIF
    endif
    graph Losses
    graph BarStart
    graph StrategyProfit < StrategyProfit[1] coloured("Red")
    graph StrategyProfit > StrategyProfit[1] coloured("Green")
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Pause system X time after Y losses


ProOrder support

New Reply
Author
author-avatar
SnorreDK @snorredk Participant
Summary

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

Topic Details
Forum: ProOrder support
Language: English
Started: 11/09/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...