Dax Breakout – Need some assistance please

Forums ProRealTime English forum ProOrder support Dax Breakout – Need some assistance please

Viewing 15 posts - 1 through 15 (of 15 total)
  • #223505

    Hi,

     

    Posted this initially in the wrong forum, posting again correctly.

    I am new to this forum and new to coding in general but hoping you can help.

    I want to produce a strategy that takes the high and low of the 7:45-8am bar (UK). If the market goes 5 points above the high it’s a (buy), if 5 points below the low it triggers a sell. 20 point stop loss with a 40 point profit target. If one trade triggers the other is cancelled.

    I think the below captures it but I might be wrong (I took a lot of it from a previous code I found and made amendments).

    Lastly, and this is the part I need help with. If the trade is 15 points in my favour the stop loss moves to 0 or breakeven and I am not sure how to code that.

    Any help would be greatly appreciated. Thanks.

     

    DEFPARAM cumulateOrders = false
    //—————————————–
    timeframe (1 minute)
    OTD = Barindex – TradeIndex(1) > IntradayBarIndex //one trade X day
    startHour = 080000
    cTime = time >= startHour
    //——————————————————
    if openTime = 074500 then
    myHighest = high
    myLowest = low
    endif
    if openTime >= 074500 and openTime <=075959 then
    myHighest = max (myHighest,high)
    myLowest = min (myLowest,low)
    endif
    //————————————————————–
    if not onMarket and cTime and OTD then
    buy 1 contract at myHighest + (5*pointSize) stop
    sellShort 1 contract at myLowest – (5*pointSize) stop
    endif
    //—————————————————————–
    SET STOP LOSS 20
    set target pProfit 40

    #223507

    The code seems correct and pending orders are automatically cancelled at the closing of each bar. They need to be placed again if needed.

    There might be a minor chance that both pending orders are triggered, if that occurs on the same bar. It’s not possible to prevent that from happening (DEFPARAM cumulateOrders = false is of no use in this case).

    The only correction I have made is to tell a STOP from a LIMIT order:

    #223509

    Hi Roberto,

    Thanks very much for looking at this.

    Am I correct in saying “if the buy signal and the sell signal both trigger within the same 1 minute bar then both trades will trigger” but if they appear in different 1 min bars this will not happen?

    Also, I mentioned moving my 20 point stop loss to Breakeven or 0 when I am 15 points in profit. Would you be able to assist with that?

    #223510

    If you wanto to bring the stop to breakeven after 15 points add to your code this snippet.

     

     

    2 users thanked author for this post.
    #223513

    PatMc, you are absolutely right.

    MauroPro coded an effective snippet for beeakeven. This is his example modified to use different instructions:

    2 users thanked author for this post.
    #223514

    Hi Roberto, I tried your code with the new instruction but it doesn’t hit the breakeven point. I had already tried it, written in a different way, before inserting the classical snippet, and also to me it didn’t work either (I thought I made a mistake).

    Could you check?

    #223515

    This is the way I had written (but it didn’t work) the code with the new instruction (the old snippet work fine):

     

    floatingPosition = positionPrice*positionPerf/pointSize

    if (longOnMarket or shortOnMarket) and floatingPosition > 15*pointSize then
    set stop breakeven
    endif

     

    1 user thanked author for this post.
    #223917

    How could the code be changed to put at 1 or 2 points in profit instead of just break even?

    #223920

    In line 5 and 7 you have to write:

    myExit = tradePrice(1) + 2*pointSize

    1 user thanked author for this post.
    #224093

    Hi, I have noticed the coding produces results on a sunday evening and I would like to exclude this from the below. I tried what I thought was correct but doesn’t work.

     

    DEFPARAM cumulateOrders = false
    //—————————————-
    timeframe (1 minute)
    OTD = Barindex – TradeIndex(1) > IntradayBarIndex //one trade X day
    startHour = 080000
    cTime = time >= startHour
    //——————————————————
    if openTime = 074500 then
    myHighest = high
    myLowest = low
    endif
    if openTime >= 074500 and openTime <=075959 then myHighest = max (myHighest,high) myLowest = min (myLowest,low) endif //————————————————————- if not onMarket and cTime and OTD then IF close > myHighest THEN
    buy 1 contract at myHighest + (5*pointSize) limit
    ELSIF close < myHighest THEN buy 1 contract at myHighest + (5*pointSize) stop ENDIF IF close > myLowest THEN
    sellShort 1 contract at myLowest – (5*pointSize) stop
    ELSIF close < myLowest THEN
    sellShort 1 contract at myLowest – (5*pointSize) limit
    ENDIF
    endif
    //—————————————————————-
    SET STOP pLOSS 20
    set target pProfit 40

    #224104

    Just add to your code: “dayOfWeek” (monday = 1, tuesday = 2 …):

    if (dayOfWeek >= 1 and dayOfWeek <= 5) and not onMarket and cTime and OTD then

    1 user thanked author for this post.
    #224202

    Hi all,

    I am not sure the coding gives me what I thought it was.

    In summary, I expect the code to provide me with the high and low between 0745am and 0759am -minute bar. It would then trigger a buy or sell if the market hits 5 points below those bars’ high or low.

    For example: On November 23rd the high and low of the DAX between 07:45am and 07:59am was 15,961.4 and 15948.4. This would mean a buy is triggered at 15,966.4 (15,961.4 + 5 points) and a sell would be triggered at  15943.4 (15948.4 – 5 points).

    The trade triggered a sell at 15946.4 which is 3 points less than it should do and at no point did it reach 15943.4 to trigger a sell but the system triggered a sell at 08:01 at 15946.4 and proceeded to lose 20 points. I note that all the entries happen at the start of a new bar so I believe it will only ever trigger at the close of previous bar but I don’t understand why it triggered in the first place if the buy/sell at high/low + 5 is working properly.

    Any help is greatly appreciated and thanks for all the assistance provided so far 🙂

     

    DEFPARAM cumulateOrders = false
    //—————————————-
    timeframe (1 minute)
    OTD = Barindex TradeIndex(1) > IntradayBarIndex //one trade X day
    startHour = 080000
    cTime = time >= startHour
    //——————————————————
    if openTime = 074500 then
       myHighest = high
       myLowest  = low
    endif
    if openTime >= 074500 and openTime <=075959 then
       myHighest = max (myHighest,high)
       myLowest  = min (myLowest,low)
    endif
    //————————————————————-
    if not onMarket and cTime and OTD then
       IF close > myHighest THEN
          buy       1 contract at myHighest + (5*pointSize) limit
       ELSIF close < myHighest THEN
          buy       1 contract at myHighest + (5*pointSize) stop
       ENDIF
       IF close > myLowest THEN
          sellShort 1 contract at myLowest   (5*pointSize) stop
       ELSIF close < myLowest THEN
          sellShort 1 contract at myLowest   (5*pointSize) limit
       ENDIF
    endif
    //—————————————————————-
    SET STOP   pLOSS   20
    set target pProfit 40
    #224207
    JS

    Hi,

    Calculating the highest and lowest values doesn’t go well…

    (if you want to know why, please let me know)

    Try these:

    If OpenTime=075900 then

    myHighest=Highest[15](High)

    myLowest=Lowest[15](Low)

    EndIf

    In the next part:

    Omit these sentences:

    If Close>myHighset then

    If Close>myLowest then

    1 user thanked author for this post.
    #224208

    In your formula you have typed:  close > myLowest, instead you have to write close < myLowest.

    Also use graphOnPrice to see the buy – sell levels.

    You can also add this INDICATOR to see the max and min of the chosen time:

    Here is the simplest formula:

    I add a picture of the day 23 you were referring to.

     

     

     

    1 user thanked author for this post.
    #224210

    This would be the formula with the advice of JS (the result is the same, test 200K).

     

     

     

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 15 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login