No entry after not working?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #178303 quote
    egyptiantrader
    Participant
    Junior

    I’ve added some no entry code (straight from the simplified creation tool in bold below) but its having no effect even when I change the time so I’m trading from 8 hrs to less than an hour a day? Trades are still showing in back test after the no entry time?

    No idea why this isn’t working?

    Help please.

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the “FLATBEFORE” time.
    DEFPARAM FLATBEFORE = 143500
    // Cancel all pending orders and close all positions at the “FLATAFTER” time
    DEFPARAM FLATAFTER = 220000

    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 145500
    timeEnterAfter = time < noEntryAfterTime

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

    #178310 quote
    robertogozzi
    Moderator
    Master

    These two commands:

    • DEFPARAM FLATBEFORE = 143500
      DEFPARAM FLATAFTER   = 220000

    mean that you do NOT want any trade open before 143500 AND after 220000.

    This further instruction:

    • noEntryAfterTime = 145500
      timeEnterAfter = time < noEntryAfterTime

    means that you can enter a trade BEFORE 145500 (but AFTER 143500 as from above).

    So your trades can only be opened between 143500 AND 145459.

    If you trade on a 15-minute TF you can only enter at 144500. On a higher TF no trade will ever be opened.

    In any case at 220000 ALL trades will be closed.

    #178313 quote
    egyptiantrader
    Participant
    Junior

    Yes I agree with what you have said but that’s not how the back test results are working. I’m on a 5m timeframe and only adjusted the noentrytime to 14:55 test it. I’m seeing no effect no matter what time I enter?

     

    See attached results:

    One image is the results with no restriction on entry between 14:35 and 22:00

    The other is image is as above but no entries allowed after 16:00.

    There’s no difference when they definitely should be?

    Screenshot-2021-09-24-15.28.03.png Screenshot-2021-09-24-15.28.03.png Screenshot-2021-09-24-15.26.42.png Screenshot-2021-09-24-15.26.42.png
    #178329 quote
    robertogozzi
    Moderator
    Master

    To check results I need the working code in order to be able to replicate your trades.

    #178540 quote
    egyptiantrader
    Participant
    Junior

    //————————————————————————-
    // Main code : EMA cross over DOW £1
    //————————————————————————-
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the “FLATBEFORE” time.
    DEFPARAM FLATBEFORE = 143500
    // Cancel all pending orders and close all positions at the “FLATAFTER” time
    DEFPARAM FLATAFTER = 220000

    //// Prevents the system from placing new orders to enter the market or increase position size after the specified time
    //noEntryAfterTime = 160000
    //timeEnterAfter = time < noEntryAfterTime

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

    ////stops trades within x bars after exit
    //ONCE BarCount = 0
    //ONCE TradeON = 1 //1=trading allowed 0=trading disbaled
    //IF OnMarket AND Not OnMarket[1] THEN
    //TradeON = 0 //disable trading
    //BarCount = 0 //reset counter
    //ENDIF
    //IF Not OnMarket THEN //Increase counter when not on market
    //BarCount = BarCount + 1
    //ENDIF
    //IF BarCount > 3 THEN
    //TradeON = 1
    //ENDIF

    //Initial balance
    myBalance5mDOW = CALL “Balance 5m DOW”

    If Time = 143000 then
    upper=highest[6](high)
    lower=lowest[6](low)
    endif

    //Conditions to enter long positions
    indicator1 = ExponentialAverage[shortT](close)
    indicator2 = ExponentialAverage[longT](close)
    c1 = (indicator1 CROSSES OVER indicator2)

    IF close >upper AND c1 AND myBalance5mDOW <minibalance AND not daysForbiddenEntry THEN
    BUY 0.5 CONTRACT AT MARKET
    ENDIF

    // Conditions to exit long positions
    indicator3 = ExponentialAverage[shortT](close)
    indicator4 = ExponentialAverage[longT](close)
    c2 = (indicator3 CROSSES UNDER indicator4)

    IF open <upper -5 OR C2 THEN
    SELL AT MARKET
    ENDIF

    //Conditions to enter SHORT positions
    indicator1 = ExponentialAverage[shortT](close)
    indicator2 = ExponentialAverage[longT](close)
    c3 = (indicator1 CROSSES UNDER indicator2)

    IF c3 AND close <lower AND not daysForbiddenEntry THEN
    SELLSHORT 0.5 CONTRACT AT MARKET
    ENDIF

    // Conditions to exit short positions
    indicator3 = ExponentialAverage[shortT](close)
    indicator4 = ExponentialAverage[longT](close)
    c4 = (indicator3 CROSSES OVER indicator4)

    IF open >lower +5 OR C4 THEN
    EXITSHORT AT MARKET
    ENDIF

    SET STOP pLOSS (stoploss)
    SET TARGET pPROFIT (TP)

    #178542 quote
    egyptiantrader
    Participant
    Junior

    The section is commented out at the moment  above.

    //// Prevents the system from placing new orders to enter the market or increase position size after the specified time
    //noEntryAfterTime = 160000
    //timeEnterAfter = time < noEntryAfterTime

    Thanks.

    #178549 quote
    robertogozzi
    Moderator
    Master

    It must be a working code.

    It’s missing:

    • indicator “Balance 5m DOW”
    • longT
    • minibalance
    • shortT
    • stoploss
    • TP
    #178554 quote
    egyptiantrader
    Participant
    Junior

    //Balance 5m DOW
    //Initial Ballance calculation

    starttime = 133000
    endtime = 143000

    If Time = endtime then
    upper=highest[6](high)
    lower=lowest[6](low)
    dif=round(abs(lower-upper))

    endif

    DRAWHLINE (BB) coloured(0,200,0)
    DRAWHLINE (SB)coloured(200,0,0)

    RETURN dif

    #178556 quote
    egyptiantrader
    Participant
    Junior
    • longT =18
    • minibalance = 110
    • shortT = 13
    • stoploss = 35
    • TP = 450
    #178585 quote
    robertogozzi
    Moderator
    Master

    Ok, I see, it’s because you need to add AND timeEnterAfter to your entry conditions, so that they read:

    IF close >upper AND c1 AND myBalance5mDOW <minibalance AND not daysForbiddenEntry AND timeEnterAfter THEN
    IF c3 AND close <lower AND not daysForbiddenEntry AND timeEnterAfter THEN
    egyptiantrader thanked this post
    #178592 quote
    egyptiantrader
    Participant
    Junior

    Thank you. I’ll give that a go.

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

No entry after not working?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 10 replies,
has 2 voices, and was last updated by egyptiantrader
4 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/24/2021
Status: Active
Attachments: 2 files
Logo Logo
Loading...