money management AND trailing stop function

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #72507 quote
    immo_vienna
    Participant
    Average
    #72552 quote
    Nicolas
    Keymaster
    Master

    Sorry, but what do you need exactly?

    #72557 quote
    immo_vienna
    Participant
    Average
    1. i am looking for the correct stop loss

     

    efparam cumulateorders = false
    
    REM Money Management
    Capital = 10000 
    Risk = 0.01 
    StopLoss = XXXXXX // whats my stop loss here?
     
    REM Calculate contracts
    equity = Capital + StrategyProfit
    maxrisk = round(equity*Risk)
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
     
    //order launch (example) would be set to any other entry conditions
    //c1 = close>close[1]
    c2 = close<close[1]
     
    //if c1 then
    //BUY positionsize AT MARKET
    //SET STOP PLOSS 50
    //endif
      
    //************************************************************************
    //trailing stop function
    trailingstart = 20 //trailing will start @trailinstart points profit
    trailingstep = 5 //trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
     newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
     IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
      newSL = tradeprice(1)+trailingstep*pipsize
     ENDIF
    //next moves
     IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
      newSL = newSL+trailingstep*pipsize
     ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
     IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
      newSL = tradeprice(1)-trailingstep*pipsize
     ENDIF
    //next moves
     IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
      newSL = newSL-trailingstep*pipsize
     ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
     SELL AT newSL STOP
     EXITSHORT AT newSL STOP
    ENDIF

    2) if i use this strategy and i buy an contract there is NO stoploss before //first move (breakeven).
    i need an stoploss at the market entry too. do u know what i mean? :S

     

    thx

    #72571 quote
    Nicolas
    Keymaster
    Master

    Something like:

    if on market and newsl=0 then 
     set stop ploss 100
    endif
    immo_vienna thanked this post
    #72576 quote
    immo_vienna
    Participant
    Average

    ad 2) seems legit thx!

    and what would u do bout the money management system?
    ad 1) i tried this but it doesnt work:

    REM Money Management
    Capital = 10000 
    Risk = 0.01 
    StopLoss = tradeprice(1)+trailingstep*pipsize // whats my stop loss here?
    #74716 quote
    immo_vienna
    Participant
    Average

    @Nicolas: can u help me a bit?

    #74731 quote
    Nicolas
    Keymaster
    Master

    The money management snippet given is used to calculated the lot size, not the stoploss size. Is it what you are trying to achieve (calculate the stoploss size according to your balance)?

    #75033 quote
    immo_vienna
    Participant
    Average
    #75069 quote
    Nicolas
    Keymaster
    Master

    Yes I know, but how are you supposed to change the lot size of the first order with a stoploss value calculated with a previous order that doesn’t exist? Sorry but I try hard to understand what you want to achieve .. 🙂

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

money management AND trailing stop function


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by Nicolas
7 years, 8 months ago.

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