lmatl

Position management strategy framework [LM]

Hi Traders,

This is backtest framework for position management of indicators based on systems that are used for position management of gambling systems. All examples describes situation that position unit is 100$ of given asset. For tracking there are used pinescript arrays. In all strategies I have built some max extremes for given strategy(not originaly part of the strategies but i think nice to have) and in case of reaching that threshold counts it will reset to initial state


Martingale is a simple system that when you loose then with another position you multiply previous one by 2, It should be mentioned that it is also a very aggressive system, which is relatively capital intensive.

Step Position Cummulative W/L Win/Loss
1 100 0 loss
2 200 -100 loss
3 400 -300 loss
4 800 -700 loss
5 1600 -1500 win
6 100 100 win

Martingale has also more agresive variant called Gran martingale that when you loose you multiply the position as in Martingale and add another position

Step Position Cummulative W/L Win/Loss
1 100 0 loss
2 300 -100 loss
3 700 -400 loss
4 1500 -1100 loss
5 3100 -2600 win
6 100 500 win

D‘ Alembert strategy is very simple everytime you lose add 1 position unit more to previous position and everytime you win you substract one position unit. It's named after Jean le Rond D‘ Alembert who died in 1783 in Paris(author of integrals)

Step Position Cummulative W/L Win/Loss
1 100 0 loss
2 200 -100 loss
3 300 -300 loss
4 400 -600 loss
5 500 -1000 win
6 400 -500 win

Fibonacci strategy is based on the Fibonacci series has the following, infinite form: 1, 1, 2, 3, 5, 8, 13, 21, 34,… to infinity ... position is created by adding previous two positions and in case of win you remove those to numbers from the serie and in case of loss you add last position to number serie

Step Position Cummulative W/L Win/Loss
1 100 0 loss
2 200 -100 loss
3 300 -300 loss
4 500 -600 loss
5 800 -1100 win
6 300 -300 win

Labouchere strategy is one of the oldest systems created for roulette. In this strategy is configured serie 1, 2, 3 so position is created with adding first and last position multiplier. I case of win you remove the firs and last from the serie and in case of loss you add the last multiplier to at the end of the serie.

Step Position Cummulative W/L Win/Loss Serie Mult
1 400 0 loss 1,2,3
2 500 -400 loss 1,2,3,4
3 600 -900 loss 1,2,3,4,5
4 700 -1500 loss 1,2,3,4,5,6
5 800 -2200 win 1,2,3,4,5,6,7
6 800 -1400 win 2,3,4,5,6


Oscar's grind strategy is a relatively new system, which became famous during the beginning of the first computers. In 1965, the system was subjected to a simulation test of 280000 roulette moveson an IBM 790 computer. The system passed the test with success. Let's add, however,that large financial reserves and the "iron nerves" of the computer were a prerequisite.

In case you loose than position is remaining the same but in case of win you add 1 to positon multipler in casethat the position would be lower than cumulative loss than you lower position to loss + 1 position unit amount


Step Position Cummulative W/L Win/Loss Multiplier
1 100 0 loss 1
2 100 -100 loss 1
3 100 -200 loss 1
4 100 -300 win 1
5 200 -200 win 2
6 100 0 win 1
7 100 100 win 1


Strategy for entries and exits is used TD sequential(it's not clean TD sequential according to Demarks rules, only interested in setup phases) it is used for demonstartion only and it can be replaced by any strategy

Long:
entry: if long setup is 2 and is above 1st setup
exit success: if long setup is 9 or if any candle during setup phase switches to short setup but the closing price is above position entry price
exit failed: if any candle switches from long setup to short and price is below the entry price

Short:
entry: if short setup is 2 and is above 1st setup
exit success: if short setup is 9 or if any candle during setup phase switches to long setup but the closing price is below position entry price
exit failed: if any candle switches from short setup to long and price is below the entry price


I hope you enjoy this strategy as I enjoyed to code it

Lukas
オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードの公開物での再利用には、ハウスルールに準拠する必要があります。お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?

コメント

MAN....Ive got to learn arrays. Its one of the only things I cannot wrap my head around yet. Though I have not REALLY tried to break it down yet.
Great job my friend, Bravo. Im VERY impressed!!!
返信
lmatl ChasinAlts
Hi @ChasinAlts, they are not difficult to learn. Once you write one indicator others are easy. I would also welcome hash map implementation in Pine to make code cleaner.
返信
Thank you so much. Really amazing work. !!
返信
lmatl Rigelintelligence
@Rigelintelligence, thank you it's fun only but it can be used to backtest your strategies with some position management framework of your choosing
返信
Hi Guys, This strategy is intended just for educational purposes and don't recommend it for live trading
返信