which is a Priority, SET STOP PRICE and SELL AT x STOP

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #213888 quote
    ZeroCafeine
    Participant
    Senior

    Hi every one,

    Let’s take the example where I am long in market, the buy price 20, and I create a stop loss at 15, If I create a sell order higher than my SL I have the impression that sometimes it doesn’t work, so the question is how to disable the first SL :

    IF Long then 
      BUY 1 Share AT 20 Limit
      Set Stop Price 15
    ENDIF
    
    IF C1 THEN
      Sell AT 18 Stop
    ENDIF
    
    // I tried something like this but it doesn't seem to work
    IF C1 THEN
      Sell AT 18 Stop
      Set Stop Price 0 // To disable it permanently
    ENDIF

    Best Reguards,
    ZeroCafeine

    #213891 quote
    GraHal
    Participant
    Master

    The Sell at 18 Stop cancels the Set Stop Price 15.
    Reason: 
    Sell at 18 Stop is the more recent command / lower down the code.

    Try …

    If Close > 15 AND <= 18 Then
    Sell at Market
    Endif

    Above will not cancel Set Stop Price 15 because above is an Order: at Market.

    ZeroCafeine thanked this post
    #213896 quote
    robertogozzi
    Moderator
    Master

    Maybe a cause could be that 18 is too close to 20, so the pending order may be turned into an AT-MARKET order if the required distance is greater.

    You should check with the broker if, for that instrument or asset, that distance is ok.

    You might then use IF…ENDIF to check whether you need to execute something or something else.

    GraHal and ZeroCafeine thanked this post
    #213911 quote
    ZeroCafeine
    Participant
    Senior

    Ok ok,tks you, this number it’s just for exemple, I’m doing some backtest for learning how to program,

     

    @Grahal I agree with you, because I got this problem before, even the selling order is at 18, but because I have also a sell stop at 15,

    The software will make me exit at 15 instead of 18, when of course 18 is more favorable for an exit on a long order

     

    @ Roberto I will try to find the exactly problem with a very small code and share it here, maybe after tomorrow

     

    Tks again 😊

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

which is a Priority, SET STOP PRICE and SELL AT x STOP


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by ZeroCafeine
2 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/30/2023
Status: Active
Attachments: No files
Logo Logo
Loading...