Sorry, but what do you need exactly?
- 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
Something like:
if on market and newsl=0 then
set stop ploss 100
endif
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?
@Nicolas: can u help me a bit?
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)?
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 .. 🙂