Long, Short or Long&Short

 
Does anybody know if it possible in the strategy code dynamically establish in what mode the strategy is running: LongOnly, ShortOnly or Long&Short? Thanks.
 
kornilip:
Does anybody know if it possible in the strategy code dynamically establish in what mode the strategy is running: LongOnly, ShortOnly or Long&Short? Thanks.

MT4 Long or Short yes everywhere...MT4 Long and Short US NO.., everywhere else YES.............(US FXDD still works Long and short very good...but the NFA has killed all the other Brokers...) and MT5 NO WHERE IT KILLS long and short everywhere.... US and everywhere...MT5 SUCKS...

 
n8937g:

MT4 Long or Short yes everywhere...MT4 Long and Short US NO.., everywhere else YES.............(US FXDD still works Long and short very good...but the NFA has killed all the other Brokers...) and MT5 NO WHERE IT KILLS long and short everywhere.... US and everywhere...MT5 SUCKS...

Missed the point completely. He asked about the setting in the tester.

I don't know of any way to tell.

 
WHRoeder:

Missed the point completely. He asked about the setting in the tester.

I don't know of any way to tell.

Yes, you could be right he may be talking about code and/or settings in the EA......or possibly strategy tester...not sure.

 
n8937g wrote >>

Yes, you could be right he may be talking about code and/or settings in the EA......or possibly strategy tester...not sure.

Yep. I was trying to figure out if the strategy tester was running with settings LongOnly, ShortOnly or Long&Short from inside the strategy itself.

The only way I found (Thanks to idea from integer) was with the bogus buy and sell orders:

int testTicket=OrderSend(Symbol(),OP_SELL,1,0,3,0,0,"Sell Try",1,0,CLR_NONE);
if (GetLastError() == 4111)

log("Long Only Mode"); // no short orders allowed
testTicket=OrderSend(Symbol(),OP_BUY,1,0,3,0,0,"Buy Try",1,0,CLR_NONE);
if (GetLastError() == 4110)

log("Short Only Mode"); //no long orders allowed

 
kornilip:

Yep. I was trying to figure out if the strategy tester was running with settings LongOnly, ShortOnly or Long&Short from inside the strategy itself.

The only way I found (Thanks to idea from integer) was with the bogus buy and sell orders:

int testTicket=OrderSend(Symbol(),OP_SELL,1,0,3,0,0,"Sell Try",1,0,CLR_NONE);
if (GetLastError() == 4111)

log("Long Only Mode"); // no short orders allowed
testTicket=OrderSend(Symbol(),OP_BUY,1,0,3,0,0,"Buy Try",1,0,CLR_NONE);
if (GetLastError() == 4110)

log("Short Only Mode"); //no long orders allowed

HI kornilip...one additional thought...In the Expert Adviser "Properties" under "Common"... the positions limitations... "Long", "Short", and" Long and Short" don't always work properly..( I'll be happy to post codes that prove this for disbelievers..... Frank_ud for starters)........Actual limiting codes in extern bool are the only way to ensure proper activity...

 
All optimization properties are written to an ini file that is named the same as the expert name and resides in the tester folder. It's quite straight forward to understand the ini file. This file can be read form within a tester run and processed to extract the info u want. But I think placing bogus buy and sell orders is simpler and just as good.
Reason: