Hi
Stoploss trigger value set to a minus value what is it doing?
I’m currently running and testing this. Using normal values it works as it should, and works particularly well for a eurusd strategy I wrote with different normal integers. However when I put in a negative integer for the stop trigger to move th estop loss I get interesting results but I am unable to ascertain why via graphing.
This is on GBPUSD 7hrs and I’ve put below code to enter on next candle for testing purposes of the stoploss move.
Graphing and graphonprice show this on the 7hr as opening on the new stoploss level of 43, however the backtesting results show significant improvement of stopouts without losing good trades and provide different results entirely to just using a stoploss of 43 by quite a lot, 250pips or so over 16 months.
I’m currently testing this out and have tested on the 1 minute and 5 minutes as well as 10 minutes which show results of moving based on time and on the next bar for 5 or 10 mins or if I recal it was 1 minute on the 5 minute chart with a lesser negative value (memory fails me a bit there), so it can also vary if you change the value to a lower negative value like -10 or -20 say.
I’ve got this up on the 7hr GBPUSD testing to see what it does and screen recording it currently so I can flick through and see at what point it changes and then try to figure out why. I might be missing something obvious but the stoplevel graph reflects the graphonprice levels which is what I would be expecting.
I’ve left it run on the demo 7hr now for over 1 hour and its retained its stoploss of 60pips for the first hour of running and not changed to the new stoploss, so I’m thinking it’s time related somehow otherwise I would have a graph showing 60 dropping to 43 on the next bar if it closed at or past a particular level, which isnt reflected in the graphing. Might take me a few days of recording if I get stopped out and have to await the next candle, in which case I’ll try a stupid initial stoploss and take profit…
Just to note the only change from this working normally is I set the trigger to a negative value of -32 that is “newstoptrigger= -32” in the code
Hopefully someone knows what is happening and I dont have to record for days on end. 🙂
Pic of graph and graphonprice attached as well
DEFPARAM CumulateOrders = false
//Conditions for long position
c1=(close[1] >=open[1]) //opens long after bullish candle close
If not onmarket and c1 Then
Buy 1 perpoint at market
endif
//conditions to enter short positions
c2=(close[1] <= open[1]) //opens short after bearish candle close
If not onmarket and c2 then
Sellshort 1 perpoint at market
endif
stopamount=60 //stopamount
targetamount=125 //target
newstoplevel=43// value to work out stop level tradeprice + or -
newstoptrigger=-32 //pips moved to trigger new stop level
If longonmarket and (close-tradeprice)>=newstoptrigger then
Mystoplevel=(tradeprice-newstoplevel)//sets the vlaue if price gone to or beyond 60 pips
Elsif longonmarket and (close-tradeprice)<=newstoptrigger then
Mystoplevel=(tradeprice-newstoplevel)
Elsif longonmarket then
Mystoplevel=(tradeprice-stopamount)//set the value to level to calculate 60 pips
//Below setting stoploss for shorts//
Elsif shortonmarket and (tradeprice-close)>=newstoptrigger then
Mystoplevel=(tradeprice+newstoplevel)
Elsif shortonmarket and (tradeprice-close)<=newstoptrigger then
Mystoplevel=(tradeprice+newstoplevel)
Elsif shortonmarket then
Mystoplevel=(tradeprice+stopamount)
endif
If longonmarket then
Mystoploss=tradeprice-mystoplevel ///changing to pips
Elsif shortonmarket then
Mystoploss=Mystoplevel-tradeprice//changing to pips
Endif
set Stop Loss Mystoploss
SET TARGET pPROFIT targetamount
If not onmarket then
Mystoploss=stopamount
Endif
Graphonprice Mystoplevel as "Mystoplevel"
Graph Mystoploss