martingale, need little help

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #23981 quote
    JohnScher
    Participant
    Veteran

    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

    #24152 quote
    Nicolas
    Keymaster
    Master

    In order to calculate properly the lot for each trade, the target and stop must be set in points instead of money:

    Set target pprofit 100 
    Set stop ploss 10

    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?

    #24388 quote
    JohnScher
    Participant
    Veteran

    so i thank you very much. I m happy that you help me.

    So lets begin.

     

    // OriginalTrade: Code without Martingale
    // Tradingsystem TuesdayLongThursday DAX 1 Euro Mini TimeFrame 1H
    // with martingale
    
    // OriginalTrade
    MA1 = Average [1]
    MA2 = Average [2]
    c1 = Ma1>MA2
    
    t1 = time = 180000
    t2 = time = 090000
    
    d1 =dayofweek = 2
    d2 = dayofweek = 4
    
    If   d1 And t1 and c1 THEN
    buy 1 Contract At Market
    Endif
    
    
    If d2 and t2 then
    sell at market
    endif
    
    Set Stop PLoss 60 // from Trade
    Set Target PProfit 150 // from Trade

    And 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

    #24389 quote
    Raul Vg
    Participant
    Senior
    // OriginalTrade: Code without Martingale
    // Tradingsystem TuesdayLongThursday DAX 1 Euro Mini TimeFrame 1H
    // with martingale
    once ordersize=1
    // OriginalTrade
    MA1 = Average [1]
    MA2 = Average [2]
    c1 = Ma1>MA2
    
    t1 = time = 180000
    t2 = time = 090000
    
    d1 =dayofweek = 2
    d2 = dayofweek = 4
    
    If   d1 And t1 and c1 THEN
    if not onmarket then
    IF c1 THEN
    IF PositionPerf(1) < 0 THEN
    OrderSize = OrderSize*2
    if ordersize<1 then
    ordersize=1
    ENDIF
    ELSIF PositionPerf(1) > 0 THEN
    OrderSize =1
    if ordersize<1 then
    ordersize=1
    ENDIF
    endif
    buy ordersize Contract At Market
    Endif
    
    
    If d2 and t2 then
    sell at market
    endif
    endif
    endif
    Set Stop PLoss 60 // from Trade
    Set Target PProfit 150 // from Trade
    #24390 quote
    Raul Vg
    Participant
    Senior

    Martingale sooner or later fails, would only work with infinite money.

    #24391 quote
    JohnScher
    Participant
    Veteran

    You 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

    #24392 quote
    JohnScher
    Participant
    Veteran

    Martingale sooner or later fails, would only work with infinite money.

    .. i m german with small intelligent i can not understand correkt what you mean?

    #24393 quote
    Raul Vg
    Participant
    Senior

    You can work from this code

    #24394 quote
    JohnScher
    Participant
    Veteran
    IF PositionPerf(1) < 0 THEN
    OrderSize = OrderSize*2
    if ordersize<1 then
    ordersize=1
    ENDIF
    
    
    

    it seems like only double, but this not i want

    #24395 quote
    JohnScher
    Participant
    Veteran

    i try again to understanding

    wait a minute

    #24400 quote
    Raul Vg
    Participant
    Senior

    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?

     

    If   d1 And t2 and c1 THEN
    
    IF c1 THEN
    ....
    
    
    If d2 and t1 then
    sell at market
    ....
    #24401 quote
    JohnScher
    Participant
    Veteran

    example

    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?

    #24402 quote
    JohnScher
    Participant
    Veteran

    you 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

    #24403 quote
    JohnScher
    Participant
    Veteran

    works just in dax

    #24404 quote
    JohnScher
    Participant
    Veteran
    If   d1 And t2 and c1 THEN
    
    IF c1 THEN
    ....
    
    
    If d2 and t1 then
    sell at market
    ....
    
    
    
    
    
    
    
    
    
    

    i tested

    //-------------------------------------------------------------------------
    // Hauptcode : H4 live
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    // Hauptcode : H4 live
    //-------------------------------------------------------------------------
    
    Defparam flatafter = 210000
    
    c1 = time = 090000
    c2 = time = 130000
    c3 = time = 170000
    
    c5 = c1 or c2
    c6 = c2 or c3
    
    
    IF  c5 AND ExponentialAverage [1] < ExponentialAverage [2] THEN
    sellshort 1 CONTRACTS AT MARKET
    ENDIF
    
    IF  c6 AND ExponentialAverage [1] > ExponentialAverage [4] THEN
    buy 1 CONTRACT AT MARKET
    ENDIF
    
    
    Set Stop pLoss 60
    Set Target pProfit 150
    
    
    
    

    yeah, works too. postiv in backtest 4H timeframe, tested only day, 10.000 units

Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

martingale, need little help


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
JohnScher @johnscher Participant
Summary

This topic contains 20 replies,
has 3 voices, and was last updated by JohnScher
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/05/2017
Status: Active
Attachments: No files
Logo Logo
Loading...