Hi There
Yes ignore the above code as it not working correctly.
I am trying to figure out ptrailing as I have used it in a number of simulations on demo and the stoploss doesnt kick in it only acts a a trailing stop once you have reached 10 pips in profit.
So I am not sure what it is doing still testing that.
I have only been using PRT for 2 weeks now so still fumbling around.
The strategy seems to be working nicely when it comes to entry points just cant work out a good exit strategy or stoploss ( Maybe that means the strategy sucks 🙂 )
Thanks
@Stanton what about zero spread … results are unrealistic with no spread?
Also I get big loss when I include tick-tick, results are unrealistic with no tick-tick?
No not sucks … exits are more difficult to get right than entries in my opinion … keep at it! Maybe pick / copy good / working / successful exit conditions from another Strategy altother and paste into your code!? 🙂
CNParticipant
Senior
It does not suck, you are doing a great job StantonR! It gave me 50$ in profit today, thank you!!!
As @grahal is saying, keep at it and yes, exits are the hardest!!
SET STOP pLOSS 10 pTRAILING 10
This kind of statement can’t be used in IG live trading FYI. But it does work for backtests for sure.
CNParticipant
Senior
Ok, Great to have that sorted, but Nicolas, below, what is wrong with the SL/TSL ?
It does not work in live mode..
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM preloadbars = 150
n = 1
tweezerTop = ABS(High -(High[1]))<= High * 0.0075
tweezerBottom = ABS(Low -(Low[1]))<= Low * 0.0075
bullindicator = OPEN[1] > CLOSE [1] AND OPEN < CLOSE
bearindicator = OPEN[1] < CLOSE [1] AND OPEN > CLOSE
Boll = 20
Boldown = BollingerDown[Boll](close)
Bolup = BollingerUp[Boll](close)
BolliLong = (low < Boldown) and tweezerBottom and bullindicator
Bolishort = (high > Bolup) and tweezerTop and bearindicator
IF NOT LongOnMarket AND BolliLong THEN
BUY n CONTRACTS AT MARKET
ENDIF
// Conditions to enter short positions
IF NOT ShortOnMarket and Bolishort THEN
SELLSHORT n CONTRACTS AT MARKET
ENDIF
//trailing stop function
trailingstart = 10 //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
It does not work in live mode..
What does not work exactly? Entries? or trailing stop?
I do not see any stoploss in the strategy, only the trailing stop that will start once you reach 10 points profit.
CNParticipant
Senior
The trailing does not work. It sets itself 10pts down and stops there. Does not follow the movement.
It works, please try to debug with GRAPH ! 🙂 this is the only instruction to debug variables, so please use it!
Please find attached example of the “newSL” variable GRAPHed on chart in a backtest, you see that it moves correctly, at each new candlestick.
CNParticipant
Senior
Here is the stats atm in demo with full-size AUD/USD, realy realy big possibilitys if we get the stop sorted.
To keep the momentum up, I’ve done a bit on this AUD/USD 100,000 units @ 1H average spread 1.4 (from link below).
http://www.myfxbook.com/forex-broker-spreads/IG-AUDUSD-real-spread/1768,11
// Main code : GS BollBounceTweez AUDUSD 1H
//-------------------------------------------------------------------------
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM preloadbars = 150
//DEFPARAM FlatAfter = 110000
//DEFPARAM FlatBefore = 190000
n = 1
tweezerTop = ABS(High -(High[1]))<= High * 0.0075
tweezerBottom = ABS(Low -(Low[1]))<= Low * 0.0075
bullindicator = OPEN[1] > CLOSE [1] AND OPEN < CLOSE
bearindicator = OPEN[1] < CLOSE [1] AND OPEN > CLOSE
Boll = 20
Boldown = BollingerDown[Boll](close)
Bolup = BollingerUp[Boll](close)
BolliLong = (low < Boldown) and tweezerBottom and bullindicator
Bolishort = (high > Bolup) and tweezerTop and bearindicator
IF NOT LongOnMarket AND BolliLong and SMI[14,3,5](close) < 45 THEN
BUY n CONTRACTS AT MARKET
ENDIF
// Conditions to enter short positions
IF NOT ShortOnMarket and Bolishort and SMI[14,3,5](close) > 45 THEN
SELLSHORT n CONTRACTS AT MARKET
ENDIF
If ExponentialAverage[30](close) crosses under ExponentialAverage[250](close) Then
Sell at Market
Endif
If ExponentialAverage[5](close) crosses over ExponentialAverage[40](close) Then
EXITShort at Market
Endif
Use below for exits if you think above is too optimised, but fear / down and greed / up are not ‘psychologically symmetrical activities’ so why would we expect symmetrical variables for EMA (any thoughts on that logic welcome)?
Revised equity curve atached.
If ExponentialAverage[30](close) crosses under ExponentialAverage[240](close) Then
Sell at Market
Endif
If ExponentialAverage[30](close) crosses over ExponentialAverage[240](close) Then
EXITShort at Market
Endif