help coding H1 open strategy

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #144377 quote
    ullle73
    Participant
    Senior

    Hi, i need help coding a strategy having following rules:

    1. from H1 open
    2. if price moves 5 points either direction. If above open=Buy 1 contract, if below open=short 1 contract
    3. set target and SL 10 points
    #144379 quote
    robertogozzi
    Moderator
    Master

    There you go (not tested):

    Timeframe(1h,UpdateOnClose)
    c = close
    Timeframe (default)
    Buy 1 Contract at c + 5 Stop
    Sellshort 1 Contract at c - 5 Stop
    Set Target pProfit 10
    Set Stop    pLoss   10
    Nicolas and ullle73 thanked this post
    #144382 quote
    Nicolas
    Keymaster
    Master

    I would recommend to adapt 5 with the pointsize, if it is not equal to 1:

    Timeframe(1h,UpdateOnClose)
    c = close
    Timeframe (default)
    Buy 1 Contract at c + 5*pointsize Stop
    Sellshort 1 Contract at c - 5*pointsize Stop
    Set Target pProfit 10
    Set Stop    pLoss   10
    robertogozzi, MAKSIDE and ullle73 thanked this post
    #144390 quote
    ullle73
    Participant
    Senior

    thanks you guys!

    im getting this problem (see attachment) and if i disable tick it shows insanly good result, does not seem right?

    tick.jpg tick.jpg
    #144395 quote

    You have a stop loss too close to the market entry …. do a test by further distancing the stop.

    ullle73 thanked this post
    #144397 quote

    It must process too much tick by tick data

    ullle73 thanked this post
    #144419 quote
    ullle73
    Participant
    Senior

    thanks!

     

    can someone please add time restriction, trading hours between 8-11

    #144422 quote
    robertogozzi
    Moderator
    Master

    There you go:

    Timeframe(1h,UpdateOnClose)
    c = close
    Timeframe (default)
    IF time >= 080000 AND time <= 110000 THEN
       Buy 1 Contract at c + 5*pointsize Stop
       Sellshort 1 Contract at c - 5*pointsize Stop
       Set Target pProfit 10
       Set Stop    pLoss   10
    ENDIF

    TIME is the time when a bar closes. If you want to refer the time it opens use OPENTIME, instead.

    ullle73 thanked this post
    #144483 quote
    ullle73
    Participant
    Senior

    thanks alot!! one last thing, if i want to add that it closes all position after 17,30, how to add that code?

    #144484 quote
    robertogozzi
    Moderator
    Master

    Add this as the first line:

    DEFPARAM FlatAfter = 173000

    or you can use these common lines:

    If Time >= 173000 and OnMarket Then
       Sell at Market
       Exitshort at Market
    Endif
    ullle73 thanked this post
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

help coding H1 open strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ullle73 @jonas_rydqvist Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by robertogozzi
5 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/15/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...