Timer for trade to complete

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #108451 quote
    Slowlyslowly
    Participant
    Average

    Hello

     

    Is it possible to create an instructions that states “if trade has not completed within X bars close at breakeven if seen before target or loss.

     

    so effectively I can limit the time the code is running before breakeven is triggered into place regardless of the percentage of target achieved.

     

    This is for code that should work quickly hence the request to put a timer on it before reducing risk.

     

    Any help or direction would be appreciated.

     

    Kind regards

    #108452 quote
    Slowlyslowly
    Participant
    Average

    Hi

     

    Sorry should have said breakeven instruction is already written into code based on percentage of target achieved. With a “breakevenstart” instruction and breakevenLevel.

    #108453 quote
    Vonasi
    Moderator
    Master

    Something like this perhaps:

    daysallowed = 10
    
    if onmarket and barindex - tradeindex >= daysallowed then
    if longonmarket then
    if close > positionprice then
    sell at positionprice stop
    endif
    if close < positionprice then
    sell at positionprice limit
    endif
    endif
    
    if shortonmarket then
    if close < positionprice then
    exitshort at positionprice stop
    endif
    if close > positionprice then
    exitshort at positionprice limit
    endif
    endif
    endif
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Timer for trade to complete


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

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