Accelerate Volume DAX 4H (v0.1)

Category: Strategies By: 4everTrading Created: June 11, 2018, 7:59 AM
June 11, 2018, 7:59 AM
Strategies
4 Comments

Hello community,

My purpose of this code is created a mix strategy between the indicator I developed over the volume indicator, which is already posted in my profile and the awesome strategy that everyone could see in this fórum, the amazin pathfinder system (Thanks.).

Basiclly, i keep the position size management and money management, i modified the parameters the entry long and short at the market.

  • Conditions for long entry.
    • a = AverageVolumeBuy CROSSES OVER AverageVolumeSell
    • b = AverageVolumeBuy > AverageVolumeBuy[1]
    • c = MACDVolume > AverageVolumeSell
  • Conditions for short entry.
    • d = AverageVolumeSell CROSSES OVER AverageVolumeBuy
    • e = AverageVolumeSell > AverageVolumeSell[1]
    • f= MACDVolume > AverageVolumeBuy

It is just a initial idea which is neccesary to analyze much deeper, moreover  I don’t have too much volume data so if someone wants to join to help it’s welcome.

Please pleople, commento below if you know how to improve and together we can build a better strategy.

Regards

Xusto

//Created by Xusto
//v0.1
//date: 201806
//Capital: 5000
// IG Market: 2 points of spread

//Acelerate Volume in candles of 4H, code in based of Pathfinder System (Check the topic in the forum of ProRealTime).

//The conditions of entry and exit from the market is in base of the acelerate volume, the other conditions (position sizy, and money management) were taken in the Pathfinder System, which is awesome.

// ProOrder code parameter
DEFPARAM CUMULATEORDERS       = False // cumulate orders if not turned off
DEFPARAM PRELOADBARS          = 10000

// define intraday trading window
startTime                    = 90000  // start time of trading window in CET
endTime                      = 220000 // end time of trading window in CET



// define position and money management parameter
// size calculation: size = positionSize * trendMultiplier * saisonalPatternMultiplier
positionSize                 = 1    // default start size
trendMultiplier              = 2   // >1 with dynamic position sizing; 1 without
maxPositionSizePerTrade      = 9    // maximum size per trade
maxPositionSizeLong          = 9    // maximum size for a long position
maxPositionSizeShort         = 9    // maximum size for a short position

stopLossLong                 = 3.5    //3.5 in %
stopLossShort                = 2.5  // in %
takeProfitLong               = 3.5   // in %
takeProfitShort              = 3.5    //1.5 in %

trailingStartLong            = 1.5  //1.25 in %
trailingStartShort           = 0.75 //0.5 in %
trailingStepLong             = 0.5  // in %
trailingStepShort            = 0.5  // in %

maxCandlesLongWithProfit     = 16   //15 take long profit latest after x candles
maxCandlesShortWithProfit    = 5    // take short profit latest after x candles
maxCandlesLongWithoutProfit  = 75   //70 limit long loss latest after x candles
maxCandlesShortWithoutProfit = 70   // limit short loss latest after x candles

// define saisonal position multiplier for each month 1-15 / 16-31 (>0 - long / <0 - short / 0 no trade)
January1                     = 1 //1
January2                     = 0 //2 0
February1                    = 3 //3
February2                    = 1 //1
March1                       = 3 //3 1
March2                       = 3 //3
April1                       = 3 //2 3
April2                       = 3 //3
May1                         = 1 //1
May2                         = 3 //3
June1                        = 1 //1
June2                        = 3 //3
July1                        = 3 //3
July2                        = 0 //0
August1                      = 1 //1
August2                      = 1 //0 x
September1                   = 2 //2
September2                   = 0 //0
October1                     = 2 //3
October2                     = 2 //2
November1                    = 0 //0
November2                    = 3 //3
December1                    = 2 //2
December2                    = 2 //2

// dynamic position sizing based on weekly performance
profitLastWeek = 0
IF DayOfWeek <> DayOfWeek[1] AND DayOfWeek = 1 THEN
IF StrategyProfit > profitLastWeek + 1  THEN
positionSize = MIN(trendMultiplier, positionSize + 1) // increase risk
ELSE
positionSize = MAX(1, positionSize - 1) // decrease risk
ENDIF
profitLastWeek = strategyProfit
ENDIF

// calculate acelerate volume
PeriodFast = 4   //PeriodFast --> Bar numbers used for fast period calculations (Value Recomended 4)
PeriodSlow = 10   //PeriodSlow --> Bar numbers used for slow period calculations (Value Recomended 10)

//Candle Sections
//Full Range
a = high-low
//Green Candle
b = open-low
c = high-close
//Red Candle
d = high-open
e = close-low

//Unitary volume (Buy&Sell)
volUniBuy = volume/(a+b+c)     //Green Candle
volUniSell = volume/(a+d+e)   //Red Candle
//Volume calculated by candle
VolBuyGreen=a*volUniBuy          //Buy volume on green candle
VolBuyRed=(d+e)*volUniSell      //Buy volume on red candle
VolSellGreen=(b+c)*volUniBuy    //Sell Volume on green candle
VolSellRed=a*volUniSell        //Sell Volume on red candle
if close>=open then
VolBuyGreen = VolBuyRed
VolSellGreen = 0
else
VolSellRed = VolSellGreen
VolBuyRed = 0
endif

//Averages
AverageVolBuy1=ExponentialAverage[PeriodFast](VolBuyGreen)
AverageVolSell1=ExponentialAverage[PeriodFast](VolSellRed)
AverageVolBuy2=Average[PeriodSlow](VolBuyGreen)
AverageVolSell2=Average[PeriodSlow](VolSellRed)

AverageVolumeBuy=AverageVolBuy1-AverageVolBuy2
AverageVolumeSell=AverageVolSell1-AverageVolSell2

//MACD calculated over volume
MMFast = exponentialAverage[4](volume)
MMSlow = exponentialAverage[10](volume)
MACDVolume = MMFast - MMSlow

// trade only in defined trading window
IF Time >= startTime AND Time <= endTime THEN

// set saisonal multiplier
currentDayOfTheMonth = OpenDay
midOfMonth = 15
IF CurrentMonth = 1 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = January1
ELSE
saisonalPatternMultiplier = January2
ENDIF
ELSIF CurrentMonth = 2 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = February1
ELSE
saisonalPatternMultiplier = February2
ENDIF
ELSIF CurrentMonth = 3 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = March1
ELSE
saisonalPatternMultiplier = March2
ENDIF
ELSIF CurrentMonth = 4 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = April1
ELSE
saisonalPatternMultiplier = April2
ENDIF
ELSIF CurrentMonth = 5 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = May1
ELSE
saisonalPatternMultiplier = May2
ENDIF
ELSIF CurrentMonth = 6 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = June1
ELSE
saisonalPatternMultiplier = June2
ENDIF
ELSIF CurrentMonth = 7 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = July1
ELSE
saisonalPatternMultiplier = July2
ENDIF
ELSIF CurrentMonth = 8 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = August1
ELSE
saisonalPatternMultiplier = August2
ENDIF
ELSIF CurrentMonth = 9 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = September1
ELSE
saisonalPatternMultiplier = September2
ENDIF
ELSIF CurrentMonth = 10 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = October1
ELSE
saisonalPatternMultiplier = October2
ENDIF
ELSIF CurrentMonth = 11 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = November1
ELSE
saisonalPatternMultiplier = November2
ENDIF
ELSIF CurrentMonth = 12 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = December1
ELSE
saisonalPatternMultiplier = December2
ENDIF
ENDIF



// long position conditions
a = AverageVolumeBuy CROSSES OVER AverageVolumeSell
b = AverageVolumeBuy > AverageVolumeBuy[1]
c = MACDVolume > AverageVolumeSell

// short position conditions
d = AverageVolumeSell CROSSES OVER AverageVolumeBuy
e = AverageVolumeSell > AverageVolumeSell[1]
f= MACDVolume > AverageVolumeBuy

// long entry with order cumulation
IF ( a AND b and c ) THEN

// check saisonal booster setup and max position size
IF saisonalPatternMultiplier > 0 THEN
numberContracts = MIN(maxPositionSizePerTrade, positionSize * saisonalPatternMultiplier)
IF (COUNTOFPOSITION + numberContracts) <= maxPositionSizeLong THEN
IF SHORTONMARKET THEN
EXITSHORT AT MARKET
ENDIF
BUY numberContracts CONTRACT AT MARKET
ENDIF
ELSIF saisonalPatternMultiplier <> 0 THEN
numberContracts = MIN(maxPositionSizePerTrade, positionSize)
IF (COUNTOFPOSITION + numberContracts) <= maxPositionSizeLong THEN
IF SHORTONMARKET THEN
EXITSHORT AT MARKET
ENDIF
BUY numberContracts CONTRACT AT MARKET
ENDIF
ENDIF

stopLoss = stopLossLong
takeProfit = takeProfitLong

ENDIF

// short entry with order cumulation
IF ( d AND e AND f ) THEN

// check saisonal booster setup and max position size
IF saisonalPatternMultiplier < 0 THEN
numberContracts = MIN(maxPositionSizePerTrade, positionSize * ABS(saisonalPatternMultiplier))
IF (ABS(COUNTOFPOSITION) + numberContracts) <= maxPositionSizeShort THEN
IF LONGONMARKET THEN
SELL AT MARKET
ENDIF
SELLSHORT numberContracts CONTRACT AT MARKET
ENDIF
ELSIF saisonalPatternMultiplier <> 0 THEN
numberContracts = MIN(maxPositionSizePerTrade, positionSize)
IF (ABS(COUNTOFPOSITION) + numberContracts) <= maxPositionSizeShort THEN
IF LONGONMARKET THEN
SELL AT MARKET
ENDIF
SELLSHORT numberContracts CONTRACT AT MARKET
ENDIF
ENDIF

stopLoss = stopLossShort
takeProfit = takeProfitShort

ENDIF

// stop and profit management

// time exit
posProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsize
numberCandles = (BarIndex - TradeIndex)

m1 = posProfit > 0 AND numberCandles >= maxCandlesLongWithProfit
m2 = posProfit > 0 AND numberCandles >= maxCandlesShortWithProfit
m3 = posProfit < 0 AND numberCandles >= maxCandlesLongWithoutProfit
m4 = posProfit < 0 AND numberCandles >= maxCandlesShortWithoutProfit

// take profit after max candles
IF LONGONMARKET AND (m1 OR m3) THEN
SELL AT MARKET
ENDIF
IF SHORTONMARKET AND (m2 OR m4) THEN
EXITSHORT AT MARKET
ENDIF

if (1=1) then
// trailing stop function (convert % to pips)
trailingStartLongInPoints = tradeprice(1) * trailingStartLong / 100
trailingStartShortInPoints = tradeprice(1) * trailingStartShort / 100
trailingStepLongInPoints = tradeprice(1) * trailingStepLong / 100
trailingStepShortInPoints = tradeprice(1) * trailingStepShort / 100

// 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) >= trailingStartLongInPoints * pipsize THEN
newSL = tradeprice(1) + trailingStepLongInPoints * pipsize
stopLoss = stopLossLong * 0.1
takeProfit = takeProfitLong * 2

ENDIF
// next moves
IF newSL > 0 AND close - newSL >= trailingStepLongInPoints * pipsize THEN
newSL = newSL + trailingStepLongInPoints * pipsize
ENDIF
ENDIF

// manage short positions
IF SHORTONMARKET THEN
// first move (breakeven)
IF newSL = 0 AND tradeprice(1) - close >= trailingStartShortInPoints * pipsize THEN
newSL = tradeprice(1) - trailingStepShortInPoints * pipsize

ENDIF
// next moves
IF newSL > 0 AND newSL - close >= trailingStepShortInPoints * pipsize THEN
newSL = newSL - trailingStepShortInPoints * pipsize
ENDIF
ENDIF

// stop order to exit the positions
IF newSL > 0 THEN
IF LONGONMARKET THEN
SELL AT newSL STOP
ENDIF
IF SHORTONMARKET THEN
EXITSHORT AT newSL STOP
ENDIF
ENDIF
endif

// superordinate stop and take profit
SET STOP %LOSS stopLoss
SET TARGET %PROFIT takeProfit

ENDIF

 

Download
Filename: Market.png
Downloads: 188
Download
Filename: Dashboard2.png
Downloads: 176
Download
Filename: Dashboard.png
Downloads: 323
Download
Filename: Acelerate-Volume-Dax-4H-v0.1.itf
Downloads: 613
4everTrading Senior
Operating in the shadows, I hack problems one by one. My bio is currently encrypted by a complex algorithm. Decryption underway...
Author’s Profile

Comments

Logo Logo
Loading...