Random entry level

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #202824 quote
    Tropic
    Participant
    New

    Hi guys, i did this code that should go short at minimum of previous day and long at maximum prev day,

     

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    DEFPARAM FLATAFTER = 220000
    DEFPARAM FLATBEFORE = 010000
    // Condizioni per entrare su posizioni long
    c1 = (ABS((Dopen(1)-Dclose(1))))<= ((ABS((Dhigh(1)-Dlow(1))))/2)
    
    IF c1 THEN
    BUY 1 share AT Dhigh(1) stop
    ENDIF
    
    // Condizioni per entrare su posizioni short
    c2 = (ABS((Dopen(1)-Dclose(1))))<= ((ABS((Dhigh(1)-Dlow(1))))/2)
    
    IF c2 THEN
    SELLSHORT 1 share AT Dlow(1) stop
    ENDIF

    Problem is that sometime the entry level is totally random not according with the code, like in the photo. Do you know why? Thanks

    #202826 quote
    Tropic
    Participant
    New

    This is the photo

    Screenshot-61.png Screenshot-61.png
    #202830 quote
    Nicolas
    Keymaster
    Master

    Firstly you should graph on the price chart what is the value of dlow(1), so you have an hint of what the code is using:

    graphonprice dlow(1)

    Are you using custom trading hours? Because the OHLC constants returned by instruction such as Dlow are always using the official instrument timezone.

    #202832 quote
    Tropic
    Participant
    New

    Thanks Nicholas, custom trading hours? I don’k know what it is so i think no im not using that, just left the default chart price but now i can understand the problem, the problem is on the Mondays. I’m on the Gold (Spot Gold mini 10 oz, hope this is the right chart for the standard gold quote) and i see that dlow(1) and dhigh(1) don’t take the lowest and the highest price of the previous Friday but something different. I think i can solve this but can you explain me why this happens? Gold quotations are by Monday 0.00 to Friday 22.30 right ? So what’s there that changes the variable of dlow(1) and dhigh(1) ??

    #202833 quote
    phoentzs
    Participant
    Master

    Since I use similar stuff I can say… On Mondays Dhigh and Dlow is taken over from Sunday trading. Sunday evening the forex and gold market is open from 10:00 p.m. and a Sunday candle is lit. A dhigh(1), which is used on Monday, then refers to this candle.

    #202834 quote
    fifi743
    Participant
    Master

    good evening, does this code change anything

     

    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    DEFPARAM FLATAFTER = 220000
    DEFPARAM FLATBEFORE = 010000
    if OpenDayOfWeek>0 and OpenDayOfWeek<=5 then
    dailylow=dlow(0)
    dailyhigh=dhigh(0)
    endif
    
    // Condizioni per entrare su posizioni long
    c1 = (ABS((Dopen(1)-Dclose(1))))<= ((ABS((dailyhigh[1]-dailylow[1])))/2)
     
    IF c1 THEN
    BUY 1 share AT Dhigh(1) stop
    ENDIF
     
    // Condizioni per entrare su posizioni short
    c2 = (ABS((Dopen(1)-Dclose(1))))<= ((ABS((dailyhigh[1]-dailylow[1])))/2)
     
    IF c2 THEN
    SELLSHORT 1 share AT Dlow(1) stop
    ENDIF
    
    #202850 quote
    Tropic
    Participant
    New

    Really? So the gold market opens on Sunday at 10.00 pm like the Forex? that is strange cause on the gold’s chart it doesn’t show the Sunday candle, it jumps directly from Friday to Monday, in the Forex currencies it shows a candle in Sunday intstead.

    #202851 quote
    Tropic
    Participant
    New

    thank you FIFI but don’t worry, i have already solved it in a simple way, changing the variable when it is Monday using something like this:

    n=1
    IF OPENDAYOFWEEK = 1 THEN
    n=2
    ENDIF
    
    dhigh(n)...
    
    dlow(n)...
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Random entry level


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Tropic @tropic Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/19/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...