Hedging

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

    Question….

    If I am long on the market, can i use a 2nd automated script to see if there is a long position, and if that long position is – 20 pips enter a short position as a hedge?

    I know this cant be done in the same script as you cant have a long and short order together, but can it be done separately? If so how ?

    Thanks

    #25964 quote
    Wing
    Participant
    Veteran

    No, systems can’t check each other. But by including a variable that checks for the long entry inside the system that only goes short, you can ‘check’ if the mirror system is long currently.

    #25966 quote
    pips_103
    Participant
    Average

    but i wouldn’t know at what price the long was? ie know its position in relation to entry?

    #25969 quote
    Wing
    Participant
    Veteran

    You wouldn’t know the exact entry price, but the price would likely be close to the open of the bar, or based on a limit price that you can also give the other system access to. For example:

    Long system:

    if rsi[14]<30 then
    buy 1 lot at market
    endif

    Short hedging system:

    once LongEntry=0
    once LongEntryPrice=0
    
    If LongEntry=1 then
    LongEntryPrice=open
    endif
    
    LongEntry=0
    
    if rsi[14]<30 and longentryprice=0 then
    LongEntry=1
    endif
    
    // hedge
    sellshort 1 lot at longentryprice-20 stop
    
    

    Or something like that. If you exit both positions at the same time (a set time for example), you need to just reset the variables again.

    The easiest way is to create a common indicator that gives entries to each system, so they know exactly when an entry is triggered for the opposite system.

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

Hedging


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
pips_103 @pips_103 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/21/2017
Status: Active
Attachments: No files
Logo Logo
Loading...