Sell Order entry at or near close of trading

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #76129 quote
    Dymjohn
    Participant
    Senior
    DEFPARAM CumulateOrders = True // Cumulating positions allowed
    
    // Conditions to enter short positions
    indicator1 = RSI[4](close)
    c1 = (indicator1 > 70)
    indicator3 = 0
    if (CurrentTime = 205500) and close[0] > close[1] then
    indicator3 =1
    endif
    if (CurrentTime = 205900) then
    indicator3 = 0
    endif
    c3 = (indicator3 =1)
    IF c1 and c3 THEN
    SELLSHORT 1 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator2 = Average[5](close)
    c2 = (close CROSSES UNDER indicator2)
    
    IF c2 THEN
    EXITSHORT AT MARKET
    ENDIF
    

    The above doesn’t work is there any way this can be achieved please. I want to place the “sell order” at the end of the day provided the current price is above yesterday’s close. I am intending to trade the daily chart.

    Dymjohn

    #76130 quote
    Vonasi
    Moderator
    Master

    There is no time of 205500 or 205900 on daily candles which is why it does not work. You would need to be on a minute chart to have a candle for the time of 205900.

    #76133 quote
    Dymjohn
    Participant
    Senior

    thanks Vonasi

    Is there no way of placing an order to open at the end of the day whilst Auto trading on daily charts? My thoughts were that when a setup occurs in volatile markets you don’t want to wait until the open of the next day when there is likely to be a large gap in price.

    #76135 quote
    Vonasi
    Moderator
    Master

    All decisions are made at the close of a candle so the only way to enter part way through a day is to trade a shorter time frame chart or place stop and limit orders at the previous candles close. On a daily chart nothing can be changed or decided until the days candle has closed. Multi Time Frame is being trialled at the moment and might help you get closer to what you want to do. It should be available for testing on IG/PRT Demo accounts tomorrow hopefully.

    Dymjohn thanked this post
    #77585 quote
    simeong
    Participant
    Average

    Hi,

    So is they anyway to close orders just before the end of the trading day so no orders are held overnight. I’m not sure the FLATDEPRAM is working

    #77586 quote
    Vonasi
    Moderator
    Master

    Not on a daily time frame as there is only one time for a daily candle. If you switch to faster time frames then you can stop trading at any time that is represented by a candle on the chart. So hourly chart means you can stop trading or close positions at 2100, 2200, 2300 etc On a 30 minute chart 2100, 2130, 2200, 2230, 2300 are all available. Switch to a 1 minute chart and 2159 becomes available.

    As I mentioned MTF which is being tested in demo at the moment will allow you to do this – you can make trading decisions on a daily chart and then close positions at 2159 on a minute chart.

    DEFPARAM FLATAFTER will close all positions but only if a candle with the time you specify exists on the chart you are trading on.

    simeong thanked this post
    #77588 quote
    simeong
    Participant
    Average
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // Setting Time Framework
    //startTrading
    noEntryBeforeTime = 143000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // endTrading
    noEntryAfterTime = 213000
    timeEnterAfter = time < noEntryAfterTime
    //Close all Positions
    DefParam FlatAfter = 211500

    Hi Vonasi,

    Your reply really cleared things up.

    I am trading on a 15 minute timeframe and have been using the following code. However the algo is still creating orders at 15:30 on one day and not closing them till 14:50 the next day. I believe I am using the DEFPARAM FLATAFTER function correctly but if I am not would love some guidance.

    Kind Regards,

    Simone

    #77604 quote
    Vonasi
    Moderator
    Master

    The code looks fine for a fifteen minute chart. The only suggestion would be to move the DEFPARAM FLATAFTER to the beginning of the code. I don’t know whether this is the problem or whether PRT cares about the location but I have always seen all the DEFPARAM’s as the first lines of code before rather than buried in the code.

    #77659 quote
    Nicolas
    Keymaster
    Master

    All DEFPARAM must be at the beginning of the code, otherwise ProBacktest will throw errors.

    #77660 quote
    Vonasi
    Moderator
    Master

    All DEFPARAM must be at the beginning of the code, otherwise ProBacktest will throw errors.

    Thanks for confirming that Nicolas. Something in the back of my mind told me that that was the case. Maybe the documentation should be updated to show this?

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

Sell Order entry at or near close of trading


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Dymjohn @dymjohn Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/17/2018
Status: Active
Attachments: No files
Logo Logo
Loading...