Enable TimeFrames settings?

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #127131 quote
    aland
    Participant
    Average

    Hi Everyone,

    I have tested a code in the backtesting environment and it worked well.

    when I tested it today in the proOrder autotrading it totally ignored my TimeFrame command

    The code is something like this:

    TIMEFRAME (30 minutes,updateonclose )
    //check cond and set signal 1 or -1
    
    TimeFrame(default)
    //if -1 do...
    //if 1 do ...

    I run it on a 1 min TF and at the end of every 1 min bar it gave me a new signal (instead of giving a new signal every 30 min)

     

    I read in the forum a question about it in 2018 and it said TF will be enabled soon. so I guess they are long live by now, but this is my first attempt with them (so far I love them!)

    #127140 quote
    robertogozzi
    Moderator
    Master

    That’s correct, if you run it from 1-minute TF it may enter 30 times.

    You have to write code non to!

    If you post an idea I may help you.

    aland thanked this post
    #127143 quote
    aland
    Participant
    Average

    So I am confused.

    Why does TM exist in the first place if it can not work in the “real world”?

    is TF for testing purposes only?

    #127146 quote
    robertogozzi
    Moderator
    Master

    You can use anything in real trading, provided it is used correctly!

    Examples (both tested on DAX, 1-minute chart):

    // This version may enter severeal times on the same signal
    //
    DEFPARAM CumulateOrders = false
    TIMEFRAME(4 hour,UpdateOnClose)
    CrossOver = close crosses over average[10]
    TIMEFRAME(default)                         //say 1-minute TF
    if CrossOver and Not OnMarket then
       buy at market
    endif
    set stop   pLoss   20
    set target pProfit 40
    // This version may enter only once on the same signal
    //
    DEFPARAM CumulateOrders = false
    TIMEFRAME(4 hour,UpdateOnClose)
    CrossOver = close crosses over average[10]
    TIMEFRAME(default)                         //say 1-minute TF
    ONCE TradeON = 0
    IF CrossOver AND Not CrossOver[1] THEN
       TradeON = 1
    Endif
    if CrossOver AND Not OnMarket AND TradeON then
       buy at market
       TradeON = 0
    endif
    set stop   pLoss   20
    set target pProfit 40
    aland thanked this post
    #127147 quote
    robertogozzi
    Moderator
    Master

    It’s basically the same code, but I have added some code, in te latter, to avoid re-entering on the same signal.

    You can do (almost) anything using the correct code to!

    aland thanked this post
    #127150 quote
    aland
    Participant
    Average

    Thanks,

    But I’m still confused. what is not “correct” with the code I tried, that worked in the test environment?
    Just to be clear, the TimeFrame 30 is chaging the MyRSI paremeter every minute. one bar it sets it to buy, the next to sell again and again. whereas the plan is to set the MyRSI once every 30 minutes and get into a trade (or leave it) when the other conditions are met.

    to put it simply: I don’t understand why it would change the myRSI signal every minute not every 30 min. again, in test it works fine only in the proauto trading platform it does not. which led me to believe the problem is in the settings.

    //this should occur only every 30 min - but in fact this is activated every minute on a 1min TF
    TIMEFRAME (30 minutes,updateonclose )
    MyRSI = RSI[5](close)
    IF MyRSI>50 THEN
    Signal = 1
    ELSIF MyRSI<50 THEN
    Signal=-1
    ENDIF
    
    //this should occur every minute
    TimeFrame(default)
    IF Signal = 1 THEN
    IF SHORTONMARKET THEN
    EXITSHORT AT MARKET
    BUY StakeSize CONTRACTS AT high+EntryBuffer stop
    SET STOP LOSS high-low+2*EntryBuffer
    ELSIF NOT ONMARKET THEN
    BUY StakeSize CONTRACTS AT high+EntryBuffer stop
    SET STOP LOSS high-low+2*EntryBuffer
    ENDIF
    ENDIF
    
    IF Signal = -1 THEN
    IF LONGONMARKET THEN
    SELL AT MARKET
    SELLSHORT StakeSize CONTRACTS AT low-EntryBuffer stop
    SET STOP LOSS high-low+2*EntryBuffer
    ELSIF NOT ONMARKET THEN
    BUY StakeSize CONTRACTS AT low-EntryBuffer stop
    SET STOP LOSS high-low+2*EntryBuffer
    ENDIF
    ENDIF
    #127157 quote
    robertogozzi
    Moderator
    Master

    No, UpdateOnClose will allow changing MyRsi when the 30-minute candle closes.

    #127158 quote
    robertogozzi
    Moderator
    Master

    Append

    GRAPH MyRsi

    to your code to monitor its value each 1-minute candle in the variable window opened by ProBackTest.

    #127179 quote
    aland
    Participant
    Average

    I think that is the problem.

    in the test environment I used GRAPH of course, and it works fine.

    In the AutoTrading environment I can’t use GRAPH and it doesn’t work as intended.

    There is something basic here that I seem t be missing.

    #127190 quote
    aland
    Participant
    Average

    Here is the GRAPH output.

    RSI changes value every 30 minutes on a 1min chart.

    Yet in the AutoTrading it changes the value every 1 min.

    Again, my guess is that something is wrong with the AutoTrading settings and not the code

    RSI_TEMP.jpg RSI_TEMP.jpg
    #127199 quote
    robertogozzi
    Moderator
    Master

    How do you know it changes every minute?

    aland thanked this post
    #128088 quote
    aland
    Participant
    Average

    I realized it was a bug in the code. not a problem with TF. Thank you very much for your help…

    #128095 quote
    Vonasi
    Moderator
    Master

    aland – Not sure how this topic went quite so far without anyone spotting that you posted it in the wrong forum but you did! ProBuilder where you posted it is is for indicator topics and ProOrder is for strategy topics. I will move this topic but please try to post in the correct forum with any future topics.

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

Enable TimeFrames settings?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
aland @aland Participant
Summary

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

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