Hedging
Forums › ProRealTime English forum › ProOrder support › Hedging
- This topic has 3 replies, 2 voices, and was last updated 7 years ago by Wing.
-
-
02/21/2017 at 6:45 PM #25962
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
02/21/2017 at 7:22 PM #2596402/21/2017 at 7:25 PM #2596602/21/2017 at 7:56 PM #25969You 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:
123if rsi[14]<30 thenbuy 1 lot at marketendifShort hedging system:
123456789101112131415once LongEntry=0once LongEntryPrice=0If LongEntry=1 thenLongEntryPrice=openendifLongEntry=0if rsi[14]<30 and longentryprice=0 thenLongEntry=1endif// hedgesellshort 1 lot at longentryprice-20 stopOr 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.
-
AuthorPosts