When is Tradeprice updated?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #140514 quote
    teapot2002
    Participant
    Average

    Please can you help me with this? I am trying to place a stop order when the trade moves to breakeven, for which I need to know the price at which the trade was made, which I think is tradeprice. The trade is placed on the hourly chart (update on close) but the trade management code is on the 15 minute chart. It’s not working as I expect. In the attached screenshot, the trade is entered at 10.00 at 6021.7. I believe that tradeprice remains set to the previous trade until the next 15 minute bar, ie 10.15, when I expect it to be updated to 6021.7, but it’s not till 11.45. Can anyone please explain why?

    Thanks.

    Screenshot-2020-07-30-at-18.25.03.png Screenshot-2020-07-30-at-18.25.03.png
    #140518 quote
    GraHal
    Participant
    Master

    the trade management code is on the 15 minute

    So therefore the trade management code would not know / be able to compute the Trade Price until the next time the trade management code runs (after trade is opened at 10:00)  which would be 10:15.

    Probably needs a bit of thinking on it as you fall asleep!? 🙂 This is what I do and it’s amazing how our brains work on it while we are asleep and I wake with understanding!

    But I can think of more exciting things to dream about! 🙂

    #140537 quote
    teapot2002
    Participant
    Average

    Many thanks for your reply, GraHal.

    I could live with the Trade Price being updated at 10.15, but it’s graphed at the top of the screenshot, which shows it not being updated till 6 bars after 10am, ie on the 11.45 bar. What am I missing?

    You’re right about the brain working out these puzzles when we’re not thinking about them directly! What with that, and graphing everything, I can usually work things out; not this one, though.

    GraHal thanked this post
    #140633 quote
    Vonasi
    Moderator
    Master

    Not sure that I fully understand your question but TRADEPRICE is quite simply the price at which the last trade was carried out at. That can be a BUY, SELL, SELLSHORT or EXITSHORT price. So if you use TRADEPRICE to calculate a value at the same time that you send an entry order to the market then it will not be calculating on your entry price but the previous entry or exit price.

    TRADEPRICE as an entry price can only be known at the close of the bar that you entered at the open of.

    If you enter on the hourly chart then you have to wait till the close of the hourly candle to know TRADEPRICE. Try entering on the 15 minute time frame to update it sooner.

    Nicolas thanked this post
    #140750 quote
    teapot2002
    Participant
    Average

    Thanks for the reply, Nicolas. I take your point that, because I entered on the hourly chart, tradeprice will change at the end of the hour when I entered the trade, which is the 11am bar in the attached screenshot. However, it doesn’t seem to change until 11:45. In detail:

    1. as the screenshot shows, the code enters the trade at 10:00 at 6021.7, as shown by the text in the pink box in the middle of the screenshot.
    2. At this time, the top third of the screenshot shows tradeprice graphed, and it’s still at the price of the last trade entry, which is 6204.
    3. This is a 15-minute chart, as you can see from the timescale at the bottom of the chart. You say in your 9:46 post above: “TRADEPRICE as an entry price can only be known at the close of the bar that you entered at the open of.” So I’d expect it to change at on the 11:00 bar, the fourth bar after the trade opens, but it doesn’t.
    4. The top third screenshot, graphing tradeprice, shows it not changing until around 11:45, just before the trade closes, at which point it becomes the price that the trade opened at, ie 6021.7.

    Can you explain to me what’s happening?

    Again, many thanks.

    #140969 quote
    teapot2002
    Participant
    Average

    I’m very sorry to go on, but I don’t understand what’s happening with tradeprice in my screenshot, as I’ve described in points 1 – 4 above. I feel that this is so stupid that it’s blindingly obvious, but I still don’t see it. I would really appreciate help with this. Perhaps someone could go through my points 1 – 4 and explain at which one I’m going wrong.

    Thank you in advance.

    #140976 quote
    GraHal
    Participant
    Master

    You need to post your code in order to progress further else we are guessing what is not working correctly?

    #141011 quote
    Dow Jones
    Participant
    Veteran

    @teapot2002, do you change the timeframe(default) when trying to graph or trade management?

    Below I can enter trade at 1 hour and the tradeprice is correct on 15-min chart

    // Conditions to enter long positions
    timeframe(1 hour, updateonclose)
    MA20 = Average[20]
    MA50 = Average[50]
    
    C1 = MA20 crosses over MA50
    C2 = MA20 crosses under MA50
    
    IF NOT OnMarket AND C1 THEN
    BUY 1 CONTRACTS AT MARKET
    SET STOP pLOSS 100
    SET TARGET pPROFIT 150
    ENDIF
    
    // Conditions to enter short positions
    IF NOT OnMarket AND C2 THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    SET STOP pLOSS 100
    SET TARGET pPROFIT 150
    ENDIF
    
    timeframe(default)
    GRAPH tradeprice
    teapot2002 thanked this post
    #142736 quote
    teapot2002
    Participant
    Average

    Dow Jones – belated thanks, but many of them! That is the answer. I was graphing it on the 1 hour timeframe.

    Here’s an embarrassing admission – I don’t know how to ‘thank’ people officially. If you tell me, I shall thank you officially, as well as all the other kind people who have answered my questions in the past.

    #142744 quote
    Dow Jones
    Participant
    Veteran

    embarrassing admission – I don’t know how to ‘thank’ people officially

    When you come back to confirm if the answer is right, it is the big thanks already. Otherwise, it is really just handy, please don’t mind so much about it 🙂

    teapot2002 thanked this post
    #142754 quote
    Vonasi
    Moderator
    Master

    Here’s an embarrassing admission – I don’t know how to ‘thank’ people officially

    Just click on the ‘Thanks’ option on the top right of the post that you want to thank.

    teapot2002 thanked this post
    Screenshot_3-2.png Screenshot_3-2.png
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

When is Tradeprice updated?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
teapot2002 @teapot2002 Participant
Summary

This topic contains 10 replies,
has 4 voices, and was last updated by Vonasi
5 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/30/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...