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
WingParticipant
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.
but i wouldn’t know at what price the long was? ie know its position in relation to entry?
WingParticipant
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.