How to make an anti martingale code?
- This topic has 3 replies, 2 voices, and was last updated 8 years ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
Forums › ProRealTime English forum › ProOrder support › How to make an anti martingale code?
This code snippet will help you achieve this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
// 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 |