Lag in orders

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #144527 quote
    lucien
    Participant
    Average

    Hello,

    I see in a backtest that orders are placed at the next bar open. Now I have a strategy based on daily condition, but I want to place an order during the next day when the conditons are met on daily basis the previous day and the high of the current day is higher than the previous day. I do not want to wait till the next day open but I want to buy as soon as possible. I tried to work with different timeframes but get errors. I think it is easy to answer for you as experts?

    Thanks for your replies in advance

    #144529 quote
    Nicolas
    Keymaster
    Master

    With MTF code you can indeed test a daily timeframe condition each 1 sec. Please post your code so we can point you how to make it.

    #144533 quote
    lucien
    Participant
    Average

    Hi Nicolas,

    Thanks for you quick repy and your help.

     

    c1=adx[14]>30
    DP = DIplus[14](close)
    DN = DIminus[14](close)
    c2=DP>DN
    c3=low[1]<low[2]
    c4=low[2]<low[3]
    c5=low[3]<low[4]
    Highnextday=high[1]
    
    //buy when high current day is higher than highnextday
    c6=High>High[1]
    condition=c1 and c2 and c3 and c4 and c5 and c6
    IF NOT LongOnMarket AND voorwaarde THEN
    BUY 100 CONTRACTS AT MARKET
     
    ENDIF
    
     
    
    
    
    SET TARGET %PROFIT x
    set stop %loss y

     

     

     

    SET TARGET %PROFIT x
    set stop %loss y

    #144537 quote
    Nicolas
    Keymaster
    Master

    Seems to be only a part of the full strategy? Anyway, here is how it should be coded:

    timeframe(daily,updateonclose)
    c1=adx[14]>30
    DP = DIplus[14](close)
    DN = DIminus[14](close)
    c2=DP>DN
    c3=low[1]<low[2]
    c4=low[2]<low[3]
    c5=low[3]<low[4]
    Highnextday=high[1]
    
    timeframe(default)
    //buy when high current day is higher than highnextday
    c6=High>dHigh(1)
    condition=c1 and c2 and c3 and c4 and c5 and c6
    IF NOT LongOnMarket AND condition THEN
    BUY 100 CONTRACTS AT MARKET
    ENDIF
    
    SET TARGET %PROFIT x
    set stop %loss y

    You can launch it in any inferior timeframe than the daily one. Code will be read one time each bar, 1-minute would be fine.

    #144541 quote
    lucien
    Participant
    Average

    Thank You!

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

Lag in orders


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
lucien @lucien Participant
Summary

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

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