Struggling to code a DAX scalping strategy

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #167501 quote
    Bob Harris
    Participant
    Average

    Ladies and gents

     

    I am struggling to code a strategy to scalp the open of the DAX that I think should be vey simple,

     

    Staggery is,

    1min candles on the open of the DAX,

    At the open find the high and the low from the pre trading (7pm to 8pm UK time)

    1.when the price breaks above or below this point enter a trade with a 15pt stop loss and a 30 Take profit,

    so far this works fine, however I am struggling to code the next bit, the attached code just does not seem to work

    2. if the profit goes up to 15 points (1R) move the stop loss to break even

    3. if I get stopped out I re-enter if the price crosses the original entry point in the same direction as the original trade

    my full code is below

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 080100
    timeEnterBefore = time >= noEntryBeforeTime
    
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 093000
    timeEnterAfter = time < noEntryAfterTime
    
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    ///set pounds per point
    ppp=1
    
    // set variables to zero
    once tradestoday =0
    Once shorttradestoday =0
    Once longtradestoday =0
    
    if time = 010000 then
    longtradestoday =0
    shorttradestoday =0
    tradestoday =0
    
    endif
    
    //// the pretrade high amd low
    
    if time = 080000 then
    pretradehigh= highest[60](high)
    pretradelow= lowest[60](low)
    Endif
    
    
    
    // Conditions to enter long positions on first move
    c1 =  close > pretradehigh And (Time < 083000) And tradestoday <1 and longtradestoday=0 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry
    
    
    IF c1   THEN
    BUY PPP PERPOINT AT MARKET
    longtradestoday =longtradestoday+1
    tradestoday = tradestoday+1
    ENDIF
    
    // Conditions to enter short positions on first move
    c2 =  close < pretradelow And (Time < 083000)And tradestoday <1 AND  shorttradestoday=0 And timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry
    
    
    IF c2  THEN
    SELLSHORT PPP PERPOINT AT MARKET
    shorttradestoday = shorttradestoday+1
    tradestoday = tradestoday+1
    ENDIF
    
    
    // Conditions to enter long positions again
    
    c10 = longtradestoday =1 and close > pretradehigh And (Time < 092000) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry And Not Onmarket 
    
    IF c10 THEN
    BUY PPP PERPOINT AT MARKET
    longtradestoday =longtradestoday+1
    tradestoday = tradestoday+1
    ENDIF
    
    // Conditions to enter short positions again
    
    c20 = shorttradestoday = 1 And close < pretradelow And (Time < 092000)And timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry And Not Onmarket
    
    IF  c20 THEN
    SELLSHORT PPP PERPOINT AT MARKET
    shorttradestoday = shorttradestoday+1
    tradestoday = tradestoday+1
    ENDIF
    
    
    
    
    /// set new  SL to break even
    If LongOnMarket And High > (tradeprice(1) +15) Then
    SET STOP pLOSS 0
    Endif
    
    If ShortOnMarket and low < (tradeprice(1) -15) Then
    SET STOP pLOSS 0
    Endif
    
    
    
    
    
    
    
    // Stops and targets
    SET STOP pLOSS 15
    Set Target pProfit 30
    
    Capture.jpg Capture.jpg Dax-Open-1.itf
    #167558 quote
    robertogozzi
    Moderator
    Master

    Try this one:

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 080100
    timeEnterBefore = time >= noEntryBeforeTime
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 093000
    timeEnterAfter = time < noEntryAfterTime
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    //set pounds per point
    ppp=1
    // set variables to zero
    once tradestoday =0
    Once shorttradestoday =0
    Once longtradestoday =0
    if time = 010000  then
    longtradestoday =0
    shorttradestoday =0
    tradestoday =0
    endif
    //reenter in case SL is hit
    if StrategyProfit < StrategyProfit[1] then
    IF LastTrade = 1 THEN
    longtradestoday =1
    ELSIF LastTrade = 2 THEN
    shorttradestoday =1
    ENDIF
    endif
    // the pretrade high amd low
    if time = 080000 then
    pretradehigh= highest[60](high)
    pretradelow= lowest[60](low)
    Endif
    // Conditions to enter long positions on first move
    c1 =  close > pretradehigh And (Time < 083000) And tradestoday <1 and longtradestoday=0 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry
    IF c1   THEN
    BUY PPP PERPOINT AT MARKET
    longtradestoday =longtradestoday+1
    tradestoday = tradestoday+1
    ENDIF
    // Conditions to enter short positions on first move
    c2 =  close < pretradelow And (Time < 083000)And tradestoday <1 AND  shorttradestoday=0 And timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry
    IF c2  THEN
    SELLSHORT PPP PERPOINT AT MARKET
    shorttradestoday = shorttradestoday+1
    tradestoday = tradestoday+1
    ENDIF
    // Conditions to enter long positions again
    c10 = longtradestoday =1 and close > pretradehigh And (Time < 092000) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry And Not Onmarket
    IF c10 THEN
    BUY PPP PERPOINT AT MARKET
    longtradestoday =longtradestoday+1
    tradestoday = tradestoday+1
    LastTrade = 1
    ENDIF
    // Conditions to enter short positions again
    c20 = shorttradestoday = 1 And close < pretradelow And (Time < 092000)And timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry And Not Onmarket
    IF  c20 THEN
    SELLSHORT PPP PERPOINT AT MARKET
    shorttradestoday = shorttradestoday+1
    tradestoday = tradestoday+1
    LastTrade = 1
    ENDIF
    // Stops and targets
    SET STOP   pLOSS   15
    Set Target pProfit 30
    //Breakeven of 15 pips reached
    IF Not OnMarket THEN
    ExitPrice = 0
    LastTrade = 0
    ENDIF
    IF (PositionPerf * PositionPrice) >= 15 * PipSize THEN
    ExitPrice = PositionPrice
    ENDIF
    IF ExitPrice THEN
    SELL      AT ExitPrice STOP
    EXITSHORT AT ExitPrice STOP
    ENDIF
    #167577 quote
    Vonasi
    Moderator
    Master

    Bob Harris

    • Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’. Your title has been edited.
    #181456 quote
    smp
    Participant
    Average

    I am struggling to code a strategy to scalp the open of the DAX that I think should be vey simple,

    Try this, active risk management to the upside as the downside always go straight to stop if wrong.  A little 5 min direction to stop false breaks

    See what you think?

    Early-Bird-DAX-V1.2-1.itf DAX-EB-tick-by-tick-1.png DAX-EB-tick-by-tick-1.png DAX-EB-open-1.png DAX-EB-open-1.png
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Struggling to code a DAX scalping strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bob Harris @bob_harris Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/19/2021
Status: Active
Attachments: 5 files
Logo Logo
Loading...