Buy two (or three) bars after the signal

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12793 quote
    ML
    Participant
    Average

    Hi everybody,

    I have a quick question for you. I just built a simple Trading System. I would like to put in code something like “when this condition happen buy two (or three) bars after the signal happened”.

    Would it be possible?

    Thanks a lot in advance

    ML

    #12802 quote
    Nicolas
    Keymaster
    Master

    Hi, you can compare the BARINDEX between the current one and the one when your signal occurred.

    #12815 quote
    ML
    Participant
    Average

    Hi Nicolas!

    Can you explain better?

    Let say I have something like:

    xxx=golong+goshort
    if xxx=1 then
    buy 1 contracts at market nextbaropen
    elsif xxx=-1 then
    sellshort 1 contracts at market nextbaropen
    endif

    My idea would be to write something like “buy 1 contracts at market nexttwobaropen” but I know it does not exist!

    How can I use the BARINDEX  comand?

    Thanks a lot in advance for your reply!

     

    ML

    #12816 quote
    Nicolas
    Keymaster
    Master

    nextbaropen is depreciated, it is not used anymore in the PRT language.

    You can save the barindex when your signal occur and then compare its value with the current barindex one. Of course your ‘golong’ signal should occur only once in the past, otherwise the ‘signalbar’ variable would be constantly renewed with the current barindex.

    xxx = golong
    
    if xxx then 
     signalbar = barindex
    endif
    
    if barindex-xxx=2 then 
     buy 1 lot at market 
    endif 
    

    Please take the time to understand before asking your next question 🙂

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

Buy two (or three) bars after the signal


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ML @ml Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Nicolas
9 years, 5 months ago.

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