Buy/Sell at open +/- xx pips/points

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #189606 quote
    RichardVeen
    Participant
    Junior

    Hi,

    I have an idea where I want to buy or sell at the open of the next candle +  2 pips/points in the 1-min timeframe

    Now I created the following code:

    OrderTollerance = 2
    c1 = open>close[1]

    if not onmarket and c1 and hora1 and hora2 then
    Buy possize contract at open+OrderTollerance stop
    endif

     

    But when I execute the code act randomly.

    Sometime it execute direct at Open of the next candle

    Sometimes it sets buy/sell limit above/under the Open of the previous candle

    Sometime it set a buy/sell limit of 1 above/under the Open

     

    Is the code correct?

    #189607 quote
    RichardVeen
    Participant
    Junior
    OrderTollerance = 3
     
    c1 = open>close[1]
     
    if not onmarket and c1 and hora1 and hora2 then
    Buy possize contract at open+OrderTollerance stop
    endif
    #189613 quote
    robertogozzi
    Moderator
    Master

    You are likely to be using a STOP pending order, instead of a LIMIT one.

    Can you mke an example of the bar where your conditions are met and the open of which bar you want to enter.

    Additionally, do you want to to buy 2 pips above or below the OPEN price?

    #189627 quote
    RichardVeen
    Participant
    Junior

    Hi,

    The idea is to buy 2 pips above the OPEN price.

    See screenshot attached

    Entry-2-Open.png Entry-2-Open.png
    #189629 quote
    robertogozzi
    Moderator
    Master

    Ok, you only have to replace STOP with LIMIT in line 6.

    Pending-STOP-LIMIT-Orders-Ordini-Pendenti.jpg Pending-STOP-LIMIT-Orders-Ordini-Pendenti.jpg
    #189632 quote
    RichardVeen
    Participant
    Junior

    Hi,

    I changed the code with LIMIT and it is still the same.

    The entry is still at the OPEN price (the using the 2 points) and a few candles later it set the entry 2 points below the OPEN price of the previous candle (see screenshot)

    It seems that the ‘OrderTollerance’ is not working

    OrderTollerance = 2
     
    c1 = open>close[1]
     
    if not onmarket and c1 and hora1 and hora2 then
    Buy possize contract at open+OrderTollerance LIMIT
    endif
    Entry-2-points-from-the-previous-candle.png Entry-2-points-from-the-previous-candle.png
    #189642 quote
    robertogozzi
    Moderator
    Master

    Because the current price (CLOSE) is too close to the entry price (on DAX usually IG requires at least 6 points from the entry price, but it may change when volatility is high) and is entered incorrectly (in live trading the strategy would be interrupted).

    On the IG website you may find the values for each instrument/asset.

    This is the code with the support for the distance:

    OrderTollerance = 2
    Distance        = 6
    c1 = open>close[1]
    if not onmarket and c1 and hora1 and hora2 then
       EntryPrice = open + OrderTollerance
       IF close > (EntryPrice + Distance) THEN
          Buy possize contract at EntryPrice LIMIT
       ELSIF close < (EntryPrice - Distance) THEN
          Buy possize contract at EntryPrice STOP
       ELSE
          //Buy possize contract at MARKET
       ENDIF
    endif

    I commented out the line where the entry is at MARKET because too close to the Entry price. You may remove the two slashes to enable entering at MARKET in that case.

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

Buy/Sell at open +/- xx pips/points


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/08/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...