This is essentially the version 2 of Nonetheless (rif. 176142) with the max daily loss and split winning position (v.3.1).
[Test 200K: v3.1 on the right side]
//TS KD LowVolume v3.1 – DowJones 15 min – cfd 1 contract
//spread 4 points
DEFPARAM CUMULATEORDERS = false
PositionSize=1
//———————————————SETUP
avgHull11=average[45,7]
avgHull2=average[135,7]
avgHull3=average[145,7]
c1 = avgHull11>avgHull2 and avgHull2>avgHull3
lowVol = round(volume[4])
c2 = volume < lowVol
lowBars = 5
c3 = close>lowest[lowBars](low)
IF c1 and c2 AND c3 and tradeAllowed = 1 THEN
BUY PositionSize CONTRACTS AT MARKET
ENDIF
//———————————————————————
EZT = 1
if EZT then
IF longonmarket and (barindex-tradeindex(1)>= 640 and positionperf>0) or (barindex-tradeindex(1)>= 160 and positionperf<0) then
sell at market
endif
endif
//———————————————————————
myrsiM5=rsi[14](close)
if myrsiM5<30 and barindex-tradeindex>1 and longonmarket and close>positionprice then
sell at market
endif
if myrsiM5>70 and barindex-tradeindex>1 and shortonmarket and close<positionprice then
exitshort at market
endif
//—————————————————————-
maxDailyLoss = 200
realPosition=positionPerf*positionPrice/pointSize*pointValue
once tradeAllowed = 1
if intradayBarIndex=0 then
myProfit=strategyProfit
tradeAllowed=1
endif
if (strategyProfit+realPosition) <= (myProfit-maxDailyLoss) then
tradeAllowed=0
endif
//—————————————————————————————–
SET STOP %LOSS 0.9
SET TARGET %PROFIT 3.5
//—————————————————————————————–
once trailingstop = 1
if trailingstop then
trailingpercentlong = 0.29
once acceleratorlong = 0.035
once steppercentlong = (trailingpercentlong/10)*acceleratorlong
if onmarket then
trailingstartlong = positionprice*(trailingpercentlong/100)
trailingsteplong = positionprice*(steppercentlong/100)
endif
IF NOT ONMARKET THEN
newSL=0
ENDIF
IF LONGONMARKET THEN
IF newSL=0 AND high-tradeprice(1)>=trailingstartlong THEN
newSL = tradeprice(1)+trailingsteplong
ENDIF
IF newSL>0 AND high-newSL>trailingsteplong THEN
newSL = newSL+trailingsteplong
ENDIF
ENDIF
IF newSL>0 THEN
SELL AT newSL STOP
ENDIF
endif
//———————————————————————————————————————–
once partialcloseGain = 1
If partialcloseGain then
ONCE PerCent = 0.5 //close 1/2 size
ONCE PerCentGain = 0.023 //0.005 = 0.5%
ONCE MinLotSize = 0.5
ExitQuantity = abs(CountOfPosition) * PerCent
LeftQty = max(MinLotSize,abs(CountOfPosition) – ExitQuantity)
CloseQuantity = abs(CountOfPosition) – LeftQty
IF Not OnMarket THEN
Flag = 1
ENDIF
IF partialcloseGain AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain)) AND Flag THEN
SELL CloseQuantity Contracts AT Market
Flag = 0
endif
endif
//——————————————————————–