ProBackTest How to test just one Trade per Day

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #206174 quote
    nick147
    Participant
    New

    I am trying to get the following ProBackTest code to test ONE trade PER DAY if the price goes 20 pips above the Daily R1 Pivot Line on the 1 minute time frame however it only tests just one trade and then stops instead of continuing on subsequent days.

    Can anyone advise how to limit trades to ONE PER DAY when the criteria is met.

    See the code below.

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // Cancel all pending orders and close all positions at the “FLATAFTER” time
    DEFPARAM FLATAFTER = 235900

    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 080000
    timeEnterBefore = time >= noEntryBeforeTime

    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0

    TIMEFRAME(default)

    //Pivot Points 
    //PrevBarLen = High[1] – Low[1]
    PP = (DHIGH(1) + DLOW(1) + DCLOSE(1)) / 3 // Pivot point (PP) = (High + Low + Close) / 3
    //R3 = DHIGH(1) + 2 * (PP – DLOW(1)) // Third resistance (R3) = High + 2(PP – Low)
    //R2 = PP + (DHIGH(1) – DLOW(1)) // Second resistance (R2) = PP + (High – Low)
    R1 = (2 * PP) – DLOW(1) // First resistance (R1) = (2 x PP) – Low
    S1 = (2 * PP) – DHIGH(1) // First support (S1) = (2 x PP) – High
    //S2 = PP – (DHIGH(1) – DLOW(1)) // Second support (S2) = PP – (High – Low)
    //S3 = DLOW(1) – 2 * (DHIGH(1) – PP) // Third support (S3) = Low – 2(High – PP)

    Once LongTradeOn = 1
    If IntraDayBarIndex = 0 then
    LongTradeOn = 1
    Endif

    If LongOnMarket or StrategyProfit <> StrategyProfit[1] Then
    LongTradeOn = 0
    Endif

    If timeEnterBefore AND not daysForbiddenEntry AND Close < R1 + 20 AND LongTradeOn AND Not LongOnMarket THEN
    Buy 1 contract at R1 + 20 STOP
    EndIf

    // Stops and targets
    SET STOP pLOSS 20
    SET TARGET pPROFIT 60

     

     

     

     

    Any advice would be greatly appreciated

    #206177 quote
    GraHal
    Participant
    Master

    then stops instead of continuing on subsequent days

    Code continues on subsequent days on DJI on 1 min TF … see attached.

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

ProBackTest How to test just one Trade per Day


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
nick147 @nick147 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by GraHal
3 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/21/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...