Cancel order after three candles

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #144359 quote
    kaq52
    Participant
    Average

    Hi folks, looking for code for second step  of below logic, if someone could help please:

    1. Place a stop order (BUY amount LOT AT 25 stop)
    2. If order is not filled in next three candles or within next 45 minutes, cancel this stop order

     

    Thanks in advance, kaq

    #144362 quote
    robertogozzi
    Moderator
    Master

    ProOrder’s logic is the other way round.

    Pending orders ALWAYS expire each bar, so you need to place them again each new bar if your entry conditions are still valid.

    When conditions are no more valid, just don’t place them.

    #144374 quote
    TempusFugit
    Participant
    Veteran

    Hi Kaq,

    Roberto is right. If you want an entry signal to last for 3 candles you can do something like that:

    ENTRYSIGNAL = CONDITION1 AND CONDITION2 AND CONDITION3...
    
    IF ENTRYSIGNAL OR ENTRYSIGNAL[1] OR ENTRYSIGNAL[2] THEN
    BUY AT MARKET
    ENDIF
    #144375 quote
    kaq52
    Participant
    Average

    Thanks both.

    My strategy is, if current candle closes bullish engulfing, place a pending stop order two points above the closing candle, and wait for next three candles to see if order gets fulfilled else cancel pending order.

    Reading what has been explained above, looks like it is not possible…or is it?

    #144376 quote
    TempusFugit
    Participant
    Veteran

    I think is posible, just change the MARKET order for “BUY AT CLOSE+2 STOP”

    #144380 quote
    robertogozzi
    Moderator
    Master

    There you go (not tested);

    Bullish = close > open
    Body    = abs(close - open)
    c1      = close >= open[1]
    c2      = open <= close[1]
    c3      = Body > Body[1]
    c4      = Bullish AND Bearish[1]
    c5      = c1 and c2 and c3 and c4
    c       = 0
    If c5 Then
       c    = close
    Endif
    If summation [3](c5) Then
       Buy 1 Contract at c + 2 Stop
       Set Target pProfit 10
       Set Stop   pLoss   10
    Endif
    TempusFugit thanked this post
    #144471 quote
    Madrosat
    Participant
    Master

    Roberto

    Your code is no good

    #144476 quote
    robertogozzi
    Moderator
    Master

    You are right, line 13 should read:

    Buy 1 Contract at c + 2*pipsize Stop
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Cancel order after three candles


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kaq52 @kaq52 Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by robertogozzi
5 years, 5 months ago.

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