martingale, need little help
Forums › ProRealTime English forum › ProOrder support › martingale, need little help
- This topic has 20 replies, 3 voices, and was last updated 7 years ago by JohnScher.
-
-
02/05/2017 at 1:28 PM #23981
Looking for a little help with martingale
Martingale Pyramid should be stop at last at reached final a fixed profit of (maybe) 100 dollar
small strategie before integrate the martingale
IF TEMA [1) crosses over TEMA [4] then
buy 1 contract at market
Endif
Set target $profit 100
Set stop $loss 10
And now the martingale to integrate (not correct code lines, sure, i m absolute beginner, hope you can understand what i want to use)
Target StrategyProfit 100 Dollar
at first Set StrategyProfit = 0
If after first trade strategyprofit <0 then// (after first trade = – 10)
set positionsize new = corrrect postionsize to get: the Target StratgegyProfit + the loss from first trade (100+10)
then start trade again
If second trade loss so do again
find correct positionsize to get : the Target StratgegyProfit + the loss from first + loss from second trade (100+10+10)
and so again again until
IF StrategyProfit = 100 or StrategyProfit = – 100 Then
Quit //strategy
In this way above you win sometime 100 Dollar or you losse 100 Dollar (but not more, and the danger of martingale is limited
result: + 100 dollar you have won
result: – 100 dollar you strategy isn´t quite good
all numbers above are examples to variabel at any strategy
Can understand? Can help?
kind johnscher
02/06/2017 at 7:53 PM #24152In order to calculate properly the lot for each trade, the target and stop must be set in points instead of money:
12Set target pprofit 100Set stop ploss 10I can make a code snippet for this of course, but be aware that lot size are always rounded up to the next whole number so you’ll never get the exact same profit/loss in money than your last trade, is it a problem?
02/08/2017 at 6:24 PM #24388so i thank you very much. I m happy that you help me.
So lets begin.
1234567891011121314151617181920212223242526// <strong>OriginalTrade</strong>: Code without Martingale// Tradingsystem TuesdayLongThursday DAX 1 Euro Mini TimeFrame 1H// with martingale// OriginalTradeMA1 = Average [1]MA2 = Average [2]c1 = Ma1>MA2t1 = time = 180000t2 = time = 090000d1 =dayofweek = 2d2 = dayofweek = 4If d1 And t1 and c1 THENbuy 1 Contract At MarketEndifIf d2 and t2 thensell at marketendifSet Stop PLoss 60 // from TradeSet Target PProfit 150 // from TradeAnd now: please integrate the martingale. little bit more complex then my first question
Once StrategyProfit = 0
Set Stop Loss StrategyProfit = 600 points // from Strategy !
Set Target StrategyProfit = 1.500 points // from Strategy !
in this new more compexer way, new codelines needed
If the TradeProfit from first trade > 0 = then
cumulate the winnings to StrategyProfit And start OriginalTrade again
Endif
If after first trade the TradeProfit < 0 then
cumulate the Losses to StrategyProfit And Start OriginalTrade again with PostionSize(new) to reach the Target TradeProfit // to find the Positionsize(new) is one codingproblem, i told
Endif
If the TradeProfit from second trade > 0 = then
cumulate the winnings to StrategyProfit And start OriginalTrade again
Endif
If after second trade the TradeProfit < 0 then
cumulate the Losses to StrategyProfit And Start OriginalTrade again with PostionSize(new) to reach the Target TradeProfit // to find the Positionsize(new) is one codingproblem, i told
Endif
and so one and so one and so and so to : n-trade
Stops and Targets see above
IF StrategyProfit = -600 Or + 1.500 points Then
Quit Strategy
Endif // Last If Endif makes Stop PLosses and Target PProfits of the Strategy redundant but more stringent
Understand? Can help?
the OriginalTrade in PRT Backtest is positiv, testet 15.000 units (backt to 23.01.15 to yet, included up and down in dax 1 euro)
kind regards
02/08/2017 at 6:32 PM #2438912345678910111213141516171819202122232425262728293031323334353637383940// OriginalTrade: Code without Martingale// Tradingsystem TuesdayLongThursday DAX 1 Euro Mini TimeFrame 1H// with martingaleonce ordersize=1// OriginalTradeMA1 = Average [1]MA2 = Average [2]c1 = Ma1>MA2t1 = time = 180000t2 = time = 090000d1 =dayofweek = 2d2 = dayofweek = 4If d1 And t1 and c1 THENif not onmarket thenIF c1 THENIF PositionPerf(1) < 0 THENOrderSize = OrderSize*2if ordersize<1 thenordersize=1ENDIFELSIF PositionPerf(1) > 0 THENOrderSize =1if ordersize<1 thenordersize=1ENDIFendifbuy ordersize Contract At MarketEndifIf d2 and t2 thensell at marketendifendifendifSet Stop PLoss 60 // from TradeSet Target PProfit 150 // from Trade02/08/2017 at 6:36 PM #2439002/08/2017 at 6:37 PM #24391You wrote:
“I can make a code snippet for this of course, but be aware that lot size are always rounded up to the next whole number so you’ll never get the exact same profit/loss in money than your last trade, is it a problem?”
… not at yet
.. not at yet spread tooo
.. not at yet brokerage few tooooo
… comes later
02/08/2017 at 6:39 PM #2439202/08/2017 at 6:39 PM #2439302/08/2017 at 6:40 PM #2439412345678<span class="token keyword">IF</span> <span class="token keyword">PositionPerf</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator"><</span> <span class="token number">0</span> <span class="token keyword">THEN</span>OrderSize <span class="token operator">=</span> OrderSize<span class="token operator">*</span><span class="token number">2</span><span class="token keyword">if</span> ordersize<span class="token operator"><</span><span class="token number">1</span> <span class="token keyword">then</span>ordersize<span class="token operator">=</span><span class="token number">1</span><span class="token keyword">ENDIF</span>it seems like only double, but this not i want
02/08/2017 at 6:41 PM #2439502/08/2017 at 6:48 PM #2440002/08/2017 at 6:49 PM #24401example
first trade = – 30 points
to reach the trade profit of second trade von 150 points the correct new positionsize must be not a double like *2 but rather
1 point plus x points to egalisize the losses from first trade
origin target = 150 points plus 30 points losses = 180 points
180/150 = x/1
180/150 = 1.2
Postionsize(new) = 1.2 (is not double)
second trade loos 40 points
the correct posistionssize(new) of third trade is:
losses from first trade = 30 plus losses from second trade= 40 points plus 150 target = 220 points
220/150 = x/1
x = 1,47 (is not double)
and so one to : n-trade
can you coded this?
02/08/2017 at 6:52 PM #24402you wrote:
A question, the robot starts on Tuesday at 6:00 p.m. and finish on Thursday at 9:00 p.m.? Does not it make more sense?
… 18.00 = 6 afternoon/evening
= 09.00 = in the morning
is time system
also works monday short tuesday to spezial times
= popular tradingssystem of a spezial community
02/08/2017 at 6:53 PM #2440302/08/2017 at 6:56 PM #2440412345678910111213141516171819<span class="token keyword">If</span> d1 And t2 <span class="token keyword">and</span> c1 <span class="token keyword">THEN</span><span class="token keyword">IF</span> c1 <span class="token keyword">THEN</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token keyword">If</span> d2 <span class="token keyword">and</span> t1 <span class="token keyword">then</span><span class="token keyword">sell</span> <span class="token keyword">at</span> <span class="token keyword">market</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>i tested
12345678910111213141516171819202122232425262728//-------------------------------------------------------------------------// Hauptcode : H4 live//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Hauptcode : H4 live//-------------------------------------------------------------------------Defparam flatafter = 210000c1 = time = 090000c2 = time = 130000c3 = time = 170000c5 = c1 or c2c6 = c2 or c3IF c5 AND ExponentialAverage [1] < ExponentialAverage [2] THENsellshort 1 CONTRACTS AT MARKETENDIFIF c6 AND ExponentialAverage [1] > ExponentialAverage [4] THENbuy 1 CONTRACT AT MARKETENDIFSet Stop pLoss 60Set Target pProfit 150123<span class="token punctuation"></span>yeah, works too. postiv in backtest 4H timeframe, tested only day, 10.000 units
-
AuthorPosts
Find exclusive trading pro-tools on