Hi Nicolas, i would like to put a antimartingala, if i win add 1 quantity if i lose i decrease /2 quantity, can you help me?
thanks anyway
Vincenzo
This code snippet will help you achieve this:
defparam preloadbars=0
//dummy strategy !
longcondition = RSI[14] crosses over 50
if not longonmarket and longcondition then
if positionperf(1)<0 then
positionsize = positionsize-1
else
positionsize = positionsize+1
endif
size = max(1,positionsize)
BUY size SHARE AT MARKET
endif
SET TARGET PPROFIT 10
set stop ploss 20
graph size
graph positionperf(1)
Not tested but it should work as intended. Here I assume that “1” SHARE is the minimum lot possible for the traded instrument of the trading strategy. Let us know if it’s ok for you.
Thanks Nicolas, but it doesn t work, this is the code of TS on BUND with TF 4h, can you put the anti-martingala ? if i win increase +1, if i lose decrease 2
thanks
Vincenzo
// STRATEGY BYE BYE BYE BUND
// IG MARKET - FGBL BUND 1 EUR - 4 H - SPREAD 2
DEFPARAM CumulateOrders = false
PositionSize = 1
indicator1, ignored = CALL "PRICE ACTION BUND"
c1 = (indicator1 >= 1)
indicator1, ignored = CALL "PRICE ACTION BUND"
c2 = (indicator1 <=- 1)
indicator1, ignored = CALL "PRICE ACTION BUND"
c3 = (indicator1 crosses over 0)
IF c1 or c2 or c3 AND CurrentDayOfWeek <> 1 THEN
BUY POSITIONSIZE CONTRACT AT MARKET
ENDIF
// TRAILING STOP LOGIK BY KENNETH KVISTAD MODIFIED FOR LONG AND SHORT POSITION
TGL =66
if not onmarket then
MAXPRICE = 0
EXITPRICE = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
EXITPRICE = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if onmarket and EXITPRICE>0 then
SELL AT EXITPRICE STOP
ENDIF
SET STOP PLOSS 350
SET TARGET PPROFIT 500
Yes it works, I think you can add it yourself to the code with ease 🙂