Simultaneous long and short signals
Simultaneous long and short signals
How to get rid off simultaneous long/short signals on the same bar (at open or close)? These should normally cancel out. is there a setting or should it be done with code? My strategy generates occasionally both long and short at the same time. Thanks in advance.
Re: Simultaneous long and short signals
Are you saying you are generating a long and a short at the same time? You'll need to use marketposition = 0 ahead of long conditional statements and the short conditional statements. This way a long can only generate if MP = 0 and the same with a short. For example if you are long one lot then MP = 1 and a short would not be able to generate as the first statement MP=0 is false.
You can also check the box to only allow one entry per bar either for the strategy or all strategies (something like that).
You can also check the box to only allow one entry per bar either for the strategy or all strategies (something like that).
Re: Simultaneous long and short signals
Thanks but this is also happening when the system is flat, MP=0. Then I get both a short and a long at the same time. I would like to get rid off those redundant signals from backtest.
Re: Simultaneous long and short signals
Your code is likely wrong. If you post it here, we can give more guidance. You should precede your long and short conditionals with IF MP=0 then begin
-
- Posts: 275
- Joined: 22 Apr 2014
- Has thanked: 70 times
- Been thanked: 72 times
Re: Simultaneous long and short signals
I have it setup like this to avoid two entry signals.
Code: Select all
if GoLong and GoShort = true then GoLong = False;
if GoLong and GoShort = true then Goshort= False;
if GoLong then
Buy ( "Long" ) positionsize contracts next bar market;
if GoShort then
SellShort ( "Short" ) positionsize contracts next bar market ;
Re: Simultaneous long and short signals
Without trying it in a script here are a few thoughts.
My preference would be to use market position as noted above, but if you prefer your method I would try the following:
Notice how you say two different times if golong and goshort = true then in one instance golong=false and with the same conditional being true that goshort=false
You should write something like
if golong=true AND goshort=true then golong=false
this would say that if both are ever true to take a short position, or if your preference is a long, then change to
if golong=true AND goshort=true then goshort=false
Another thing. Notice where you have the conditional to actually buy or sell short. You should say if golong=true then and if goshort=true then
I haven't tried these so I don't know what will work, but there are a few things for you to test out.
My preference would be to use market position as noted above, but if you prefer your method I would try the following:
Notice how you say two different times if golong and goshort = true then in one instance golong=false and with the same conditional being true that goshort=false
You should write something like
if golong=true AND goshort=true then golong=false
this would say that if both are ever true to take a short position, or if your preference is a long, then change to
if golong=true AND goshort=true then goshort=false
Another thing. Notice where you have the conditional to actually buy or sell short. You should say if golong=true then and if goshort=true then
I haven't tried these so I don't know what will work, but there are a few things for you to test out.
Re: Simultaneous long and short signals
Thanks guys. I tried market position and it doesn't works. I also tried something along the lines suggested by Hughes and it seems to work:
Code: Select all
If golong and Not goshort then buy next bar market
If goshort and Not golong then sell short next bar market
-
- Posts: 275
- Joined: 22 Apr 2014
- Has thanked: 70 times
- Been thanked: 72 times