Shifting back to SL after positive stop sert

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

    Hi

    I’ve been having my positive stop shift back to normal SL when it pulls back a bit, esentially when it doesnt meet criteria to shift to positive stop I think…it confused me a bit so I put in code so that is shouldn’t do it, but it continues to do it.

    I included code into the SL and TP so tat it wouldn’t be calculated after  its been set, but it still continues to shift back to its original stoploss..

    I have created a ticket, but am I missing something obvious?

    Below is related code, I’ve added code to rule out it shifting only, but it appears to continue… there is no other code relating to the stoploss or new positive stop

    IF not onmarket and stoptrade and longcond  and mybullish and clong and tradeok and tradestoplong and tradestopatr and bullishmacd4 and myatrnow and ranging THEN // //  and mybullishconf removed but retained macd
    BUY myamountlong PERPOINT AT MARKET
    endif
    //===============================================
    //To keep positive stop
    //===============================================
    If not onmarket then
    keepstop=0
    endif
    If longonmarket and keepstop=0 then //and keepstop=0
    set stop loss longrisk
    set target pprofit longrisk*1.1
    keepstop=1 // keep positive stop once set
    endif
    
    //===============================================
    //End To keep positive stop
    //===============================================
    IF TDclose THEN  
    SELL AT MARKET
    ENDIF
     
    IF  not onmarket and stoptrade and shortcond and mybearish and cshort and tradeok and tradestopshort and tradestopatr and bearishmacd4  and myatrnow  and ranging THEN // and mybearishconf removed but retained macd
    SELLSHORT myamountshort PERPOINT AT MARKET
    endif
    //===============================================
    //To keep positive stop
    //===============================================
    If not onmarket then
    keepstop=0
    endif
    If shortonmarket and keepstop=0 then//and keepstop=0
    set stop loss shortrisk
    set target pprofit shortrisk*1.1
    keepstop=1 //// keep positive stop once set
    endif
    //===============================================
    //End To keep positive stop
    //===============================================
    IF  TDclose THEN //myexitshort or
    EXITSHORT AT MARKET
    ENDIF
    endif
    
    //set stop to positive
    If not onmarket then
    setstop=1
    endif
    //0=off 1=on
    If not OnMarket then
    NewSL = 0
    Endif
    If NewSL = 0 and PositionPerf > 0 and setstop Then
    Pips = tradeprice * PositionPerf
    If setstop=1 and longonmarket and Pips >= (longrisk/1.8) and ((longrisk/1.8)- (longrisk/3.1))>=5.5 Then//drawdown0
    myfactor3=longrisk/3.1
    NewSL = tradeprice + myfactor3
    setstop=0
    endif
    If setstop=1 and shortonmarket and Pips >= (shortrisk/1.8) and ((shortrisk/1.8)- (shortrisk/3.1))>=5.5 Then//drawdown0
    myfactor3=shortrisk/3.1
    NewSL = tradeprice - myfactor3
    setstop=0
    endif
    If NewSL > 0 Then
    SELL at NewSL STOP
    EXITshort at NewSL STOP
    Endif
    Endif
    
    #189059 quote
    robertogozzi
    Moderator
    Master

    Try moving the last ENDIF to just before line 53.

    #189060 quote
    PeterSt
    Participant
    Master

    Roberto,

    ?
    I think you wanted to suggest something else ?

    robertogozzi thanked this post
    image_2022-02-28_162457.png image_2022-02-28_162457.png
    #189066 quote
    robertogozzi
    Moderator
    Master

    You are right PeterSt, I had to write try moving the last ENDIF to just before line 65.

    #189068 quote
    Philstrading
    Participant
    Senior

    hmm.. Lolzzz

    Lets do that and see

    cheers

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

Shifting back to SL after positive stop sert


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Philstrading
3 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/28/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...