Unwanted Multiple Orders with Stop Order

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #167270 quote
    jpgcreatestrading
    Participant
    Average

    Hi, this is the first time i have ever posted on the website, so apologies if i don’t follow the correct protocols, or have posted in the wrong place.

    I am struggling with the backtesting software and a strategy i have been working on. My aim is to use Stop Orders to enter the market, with CumulateOrders True as often more than one trade will be open at once. the problem i run into is that it will send multiple Orders to the market with a single trigger; i.e. when my signal triggers i place a Stop Order to buy at a certain price above the current close, and this will cause multiple orders at market.

     

    to give more details, the set up is as follows:

    wait until price is above 21 SMA – set direction to 1

    wait for a single candle pullback, use this as a signal bar, place a buy level 2pts above, and sell level below

    when a signal bar occurs (the single candle pullback) i set up the system with “Buysystem”; this is so that if the price goes below the sell height before activating the trade, it will cancel the setup and never take the trade off that bar, and look for a new setup.

    if the trade is activated, the “Buysystem” will turn off as well.

    the trouble is, even though the “Buysystem” reverts to zero, another order to market is often placed, if the price carries up in the direction, as far as i am aware this should not happen as it should only buy when the “Buysystem” is on…?

     

    i have noticed this problem with a few of my systems, and my main one is way to long (and probably poorly written)  to include here, so i have written a simple one to get to the bottom of this problem. i have also noticed the same thing happens when i want to exit the position (when countofposition is more than 1 obviously). in general, i am only wanting to buy once per trigger (or exit once per exit trigger), not twice as is often happening.

    one quick fix i found is:

    if not (COUNTOFshortSHARES[0] < COUNTOFshortSHARES[1]) then

    , or

    if COUNTOFshortSHARES[0] = COUNTOFshortSHARES[1])then

    these will work, however if there are two consecutive signals, then it means the second order wont go through until the bar after that (leaving a bar between), which is bad for exiting the trade as the trade will possible continue unwanted.

     

    i have commented out the sellshort orders to solve one issue at a time.

    i have attached photos below of what i am relating to.  i have circled with a dotted red circle to show the double orders, i have also held the mouce over one of the orders so that it shows the “BuySystem” zeros out when the first order is place and so the second order should not occur.

     

     

    sorry if i have described the situation poorly…

     

     

    defparam flatafter = 160000
    timok = time > 080000 AND time < 160000
    
    sma = average[21](close)
    
    if close > sma then
    direction = 1
    elsif close < sma then
    direction = -1
    else 
    direction = 0
    endif
    
    if direction = 1 then
    if NOT Buysystem then
    if high[1] = highest[3](high) AND high[1] <> high[2] then
    buyheight = high[1] + 2
    sellheight = (Min(Min(Low[0], Low[1]) - 2, Close - 4))
    Buysystem = 1
    endif
    endif
    endif
    if Buysystem AND timok then
    if low <= sellheight then
    Buysystem = 0
    endif
    BUY 1 SHARES AT buyheight stop
    if high >= buyheight - 0.5 then // minus spread
    Buysystem = 0
    endif
    endif
    
    //if direction = -1 then
    //if NOT sellshortsystem then
    //if low[1] = lowest[3](low) AND low[1] <> low[2] then
    //sellshortheight = high[1] + 2
    //exitshortheight = Max(Max(High[0], High[1]) + 2, Close + 4)
    //sellshortsystem = 1
    //endif
    //endif
    //endif
    //if sellshortsystem AND timok then
    //if low <= exitshortheight then
    //sellshortsystem = 0
    //endif
    //BUY 1 SHARES AT sellshortheight stop
    //if high >= sellshortheight then
    //sellshortsystem = 0
    //endif
    //endif
    
    if Not timok then
    Buysystem = 0
    sellshortsystem = 0
    endif
    
    
    if onmarket then
    set target profit 10
    set stop loss 10
    endif
    
    graphonprice sma
    graphonprice buyheight coloured(0,0,150)
    graphonprice sellheight coloured(150,0,0)
    graph Buysystem
    
    Untitled-2.jpg Untitled-2.jpg Untitled-3.jpg Untitled-3.jpg
    #167273 quote
    jpgcreatestrading
    Participant
    Average

    sorry the following photo did not attach to the original post

    Untitled-1.jpg Untitled-1.jpg
    #167279 quote
    jpgcreatestrading
    Participant
    Average

    i think this is also part of the problem (maybe will help with the solution)

    i have attached a photo of another strategy in progress with a trailing stop based on my ADX type indicator. i have graphed the Stop Loss with a black line. as you can see, the stop loss trails nicely and price should have been Stopped out at 08:32 (first red circle), but the trade wasn’t Stopped out until later (the second red circle).

    it seems that there is a delay in recognising signals. all the calculations are there and are correct to the bar (to the minute), but the Orders don’t realise until a bar later.

     

    so as you can see the trailing Stop does work (i can also post more photos of this strategy to show it works elsewhere if necessary), but it doesn’t seem to take action if the Stop Loss was trailed on the bar previous

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

Unwanted Multiple Orders with Stop Order


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 2 replies,
has 1 voice, and was last updated by jpgcreatestrading
4 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/16/2021
Status: Active
Attachments: 4 files
Logo Logo
Loading...