// Cumulating positions deactivated
DEFPARAM CumulateOrders = False
// money management
ONCE Capital = 5000
ONCE Risk = 0.01
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
// 3 bar triangle
timeframe(daily, updateonclose)
// Skip Sundays
IF OpenDayOfWeek = 0 THEN
myHigh = High[1] //store friday high if Sunday
ELSE
myHigh = High //else we store high
ENDIF
IF OpenDayOfWeek = 0 THEN
myLow = Low[1] //store friday high if Sunday
ELSE
myLow = Low //else we store high
ENDIF
// Mark out triangle
IF myHigh < myHigh[2] and myLow > myLow[2] THEN
BOhigh = myHigh
BOlow = myLow
ENDIF
graphonprice BOhigh COLOURED(100,149,237) AS "BOhigh"
graphonprice BOlow COLOURED(100,149,237) AS "BOlow"
timeframe(default)
// Stoploss and position size
StopLossL = abs(close - LOWEST[16](low))
PositionSizeL = abs(round((maxrisk/StopLossL)/PointValue)*pipsize)
StopLossS = abs(close - HIGHEST[16](high))
PositionSizeS = abs(round((maxrisk/StopLossS)/PointValue)*pipsize)
// Long
IF Not ONMARKET AND close > BOhigh AND close[1] < BOhigh THEN
BUY PositionSizeL PERPOINT AT MARKET
SET STOP LOSS StopLossL
ENDIF
// short
IF Not ONMARKET AND close < BOlow AND close[1] > BOlow THEN
SELLSHORT PositionSizeS PERPOINT AT MARKET
SET STOP LOSS StopLossS
ENDIF