Trades not opening at set time and strategy stopped but still running!

Viewing 15 posts - 16 through 30 (of 31 total)
  • Author
    Posts
  • #77213 quote
    GraHal
    Participant
    Master

    Here’s the results of my 24 hour + running of Roberto code.

    If I am required to analyse also then let me know, but a standardised  approach would make more sense so findings tally with the other Systems you ran @Vonasi?

    Long.pdf Short.pdf
    #77217 quote
    Vonasi
    Moderator
    Master

    I notice from a quick scan through that both strategies failed to open positions at 0030 and 2230 on the 30th July. So Roberts code also fails to open positions when it should.

    GraHal thanked this post
    #77220 quote
    GraHal
    Participant
    Master

    Good job you checked Vonasi as I thought I was looking at spreads changing when IG say they do! 🙂

    It’s been a long day on roofing trusses and exhaust flexi-repairs! 🙂

    Thank You

    #77222 quote
    Vonasi
    Moderator
    Master

    Good job you checked Vonasi as I thought I was looking at spreads changing when IG say they do!

    That would also be interesting to check (my checks of my own results showed everything to be as it should be and with no slippage) but first of all I think we need PRT to explain why both simple time based strategies fail to place trades at some times. I also do not understand why my version placed trades at times that are not in the code!

    #77231 quote
    robertogozzi
    Moderator
    Master

    Instead of bothering about minutes, I want to test this single line strategy on EurUsd, 30-minute TF, only opening positions, without closing them, one for LONGs:

    BUY 1 CONTRACT AT MARKET   //will buy once per bar, every thirty minutes

    and one for SHORTs:

    SELLSHORT 1 CONTRACT AT MARKET   //will sell once per bar, every thirty minutes

    after one day I’ll quit them and I’ll copy data to eXcel and to compare results and spreads.

    edit backtest looks fine, but live demo doesn’t!

    Vonasi thanked this post
    #77238 quote
    GraHal
    Participant
    Master

    Here’s the results of my 24 hour + running of Roberto code.

    For the sake of completeness and – for the convenience of PRT when they check out this Thread – the code I used is provided below …

    LONG

    //-------------------------------------------------------------------------
    // Main code : Vonasi Spread Test Long
    //-------------------------------------------------------------------------
    IF OnMarket THEN
    SELL AT MARKET
    ENDIF
    IF minute = 0 OR minute = 30 THEN
    BUY 2 CONTRACT AT MARKET
    ENDIF
    

    SHORT

    //-------------------------------------------------------------------------
    // Main code : Vonasi Spread Test Short
    //-------------------------------------------------------------------------
    IF OnMarket THEN
    ExitShort AT MARKET
    ENDIF
    IF minute = 0 OR minute = 30 THEN
    Sellshort 2 CONTRACT AT MARKET
    ENDIF
    
    #77241 quote
    Vonasi
    Moderator
    Master

    backtest looks fine, but live demo doesn’t!

    Robertogozzi – your new test idea is a good one as it eliminates the TIME element as being the issue and will confirm that it is an issue of orders not being sent.

    In what way – not fine? Not opening some trades I’m guessing.

    #77247 quote
    robertogozzi
    Moderator
    Master

    Yes it opened an order as soon as the first bar closed but no more!

    Backtesting, on the contrary, is super fine!

    I will report it to PRT, but I agree on the fact that there must be some issues in the communication area between PRT and IG.

    #77250 quote
    Vonasi
    Moderator
    Master

    Yes it opened an order as soon as the first bar closed but no more!

    I wonder if it is worth trying this to compare:

    defparam cumulateorders = true
    
    buy 1 contract at market
    

    and maybe one that closes the position.

    buy 1 contract at market
    
    if onmarket then
    sell at market
    endif
    #77277 quote
    robertogozzi
    Moderator
    Master

    The one that closes the position only opens a new trade every other bar, because it takes a bar to close the previously opened trade.

    If you move your lines 3-5 before line 1, then it opens only ONE trade, no matter whether DEFPARAM CumulateOrders = TRUE.

    #77278 quote
    Vonasi
    Moderator
    Master

    Well spotted – that is what happens if you type without thinking!

    So you are saying that no matter what version you test it only opens one trade and then no more?

    I wonder what happens if you put the BUY entry within an IF THEN with a condition set permanently to true.

    Maybe PRT have a way of sensing when a strategy could empty an account and so stop it trading?

    #77281 quote
    robertogozzi
    Moderator
    Master

    Maybe PRT have a way of sensing when a strategy could empty an account and so stop it trading?

    My demo (solely) account has a balance of over € 13,000,000 so opening even a hundred 1-contract trades should not be an issue! Moreover, I start both the LONG and SHORT versions, so they should almost balance out!

    I’ll test the BUY/SELLSHORT condition within IF..ENDIF set to true.

    #77284 quote
    Vonasi
    Moderator
    Master

    I was thinking that maybe they just have a basic check that a strategy is not able to just put orders to market without some conditions being involved as if someone accidentally coded it like that and then ran it live and went on holiday they would have a shock when they came back. It saves a lot of arguing with customers if you only let strategies place one trade in that situation.

    That would still not explain the issue with the time based strategies missing trades and placing trades when no condition was met. We seem to now be testing for two issues!

    #77458 quote
    Vonasi
    Moderator
    Master

    I decided to do a test this morning (backtest only). So I tested four combinations of BUY and SELL order on a weekly DJI chart. The results are within each code shown below:

    if not onmarket then
    buy 1 contract at market
    endif
    
    if onmarket then
    sell at market
    endif
    
    count = count + 1
    graph count
    
    //Results = 1265 trades and count = 2531
    if onmarket then
    sell at market
    endif
    
    if not onmarket then
    buy 1 contract at market
    endif
    
    count = count + 1
    graph count
    
    //Results = 1265 trades and count = 2531
    if onmarket then
    sell at market
    endif
    
    buy 1 contract at market
    
    count = count + 1
    graph count
    
    //Results = 0 trades and count = 2531 (it opened 1 trade and never closed it)
    buy 1 contract at market
    
    if onmarket then
    sell at market
    endif
    
    count = count + 1
    graph count
    
    //Results = 1265 trades and count = 2531

    So it appears that it is impossible to actually physically sell at the close of a bar and open a new position at the same time as PRT just lets one instruction cancel out the other. If you use ONMARKET and NOT ONMARKET then you get a trade only every other bar. This means that our strategies are missing 50% of the market.

    We have to use ONMARKET with our SELL instruction otherwise we get no trades!

    Am I missing something or is it impossible to close a trade and open a trade on the same bar opening? This might explain why some people complain of different performance in back testing compared to forward testing – because if your start bar is one bar different you get different results.

    #77460 quote
    robertogozzi
    Moderator
    Master

    In my tests the line

    buy 1 contract at market

    on Eur/Usd, 30 minutes, correctly opens one new trade each bar (48 trades in a day), without closing them, on ProBackTest, while on DEMO it only opens the first trade and NO MORE!

    I clicked on Help to send an assistance request (I posted it on the Italian forum), authorized decoding my strategy but… IG replied they do not provide support for coding issues, without telling me WHO is in charge of those issues. Oddly enough, if IG does not support coding issues, why the Help menu sends them such requests, instead of sending them elsewhere?

    Anyway, since yesterday morning I had no further reply by Email, nor from PRT on this forum!

Viewing 15 posts - 16 through 30 (of 31 total)
  • You must be logged in to reply to this topic.

Trades not opening at set time and strategy stopped but still running!


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

This topic contains 30 replies,
has 3 voices, and was last updated by Vonasi
7 years, 6 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 07/27/2018
Status: Active
Attachments: 10 files
Logo Logo
Loading...