stay away from a specific time between close and open of new position

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #55556 quote
    victormorkvictormork
    Participant
    Veteran

    I’ve coded a section preventing my system from opening a new position in the same direction as the old position just after a close of the old position. (I use a time exit so the entry signal can still be valid at close). It works on the backtest but I just wanted to double check if this is correct or if there is another way to do the same thing?

    if barindex > (longbarexit + stayawaytimeL) then
    longstayaway = 0
    endif
    
    if barindex > (shortbarexit + stayawaytimeS) then
    shortstayaway = 0
    endif
    
    
    //////////////////////////////////////////////////////////////////
    //// Conditions to exit long positions
    //////////////////////////////////////////////////////////////////
    
    le1 = barindex = tradeindex + Ltradetime
    
    if longonmarket and le1 then
    sell at market
    longbarexit = barindex
    longstayaway = 1
    endif
    
    //////////////////////////////////////////////////////////////////
    //// Conditions to exit lshort positions
    //////////////////////////////////////////////////////////////////
    
    se1 = barindex = tradeindex + Stradetime
    
    if shortonmarket and se1 then
    exitshort at market
    shortbarexit = barindex
    shortstayaway = 1
    endif
    

     

    #55627 quote
    mr bluemr blue
    Participant
    Senior

    thanks for sharing the code. what about testing this on the demo account?

    #55637 quote
    victormorkvictormork
    Participant
    Veteran

    I have tested it on the demo and it works šŸ™‚ I just wanted to see if there was somebody who had different way to accomplish the same thing.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTimeā„¢ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

stay away from a specific time between close and open of new position


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
victormork @victormork Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by victormorkvictormork
8 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/13/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...