Stoploss trigger value set to a minus value what is it doing?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #136003 quote
    Philstrading
    Participant
    Senior

    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
    
    
    stoploss-shift.jpg stoploss-shift.jpg
    #136005 quote
    Philstrading
    Participant
    Senior

    Looking at my notes there I’m not sure they are current.. best to read the code..- sorry about that,, above code totally wrong one.

    Below is current code with the results shown

    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 th elevel fo r stoploss if triggered
    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 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
    //Show results on the chart and as a graph
    Graphonprice Mystoplevel as "Mystoplevel"
    Graph Mystoploss
    
    #136133 quote
    Philstrading
    Participant
    Senior

    Well seems like a non starter for solutions, however running it seems to set the new stop at next bar open, so starts with the intial stoploss and moves to new stoploss at next bar. Doesnt explain the programming of it mind or why a lesser value doesnt wait for the next bar. Next bar stoploss move actually gives me better profit on the timeframe used with this strategy, I think because it allows a bit of a foat (7hrs timeframe) so allows additional catches. So I’ll need to code for stoploss at the second bar of trade and see if it produces the same result…  now have to work on that unless anyones got a few lines of code of coure… 🙂

    #136136 quote
    robertogozzi
    Moderator
    Master

    I suggest that you also GRPAH all other variables and expressions that may affect results:

    • GRAPH TradePrice
    • GRAPH tradepricenewstoplevel
    • GRAPH Mystoplevel-tradeprice
    • GRAPH close – TradePrice
    • GRAPH TradePrice – close

    to easily spot any wrong value.

    You might use ABS() to make a negative vlue positive, but that would leave the glitch hidden.

    #136175 quote
    Philstrading
    Participant
    Senior

    Ok cheers..

    #136199 quote
    Vonasi
    Moderator
    Master

    Philstrading – there is no need to quote Roberto when he is the only person who has replied to your topic! Unnecessary quoting bloats topics and makes them hard to read for others. Please read the forum rules regarding quoting before using the quote button again. I have deleted your unnecessary quote.

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

Stoploss trigger value set to a minus value what is it doing?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by Vonasi
5 years, 8 months ago.

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