Short signal in MC when still long in MS  [SOLVED]

Questions about MultiCharts and user contributed studies.
Dirk8
Posts: 26
Joined: 24 Mar 2014
Has thanked: 10 times
Been thanked: 1 time

Short signal in MC when still long in MS

Postby Dirk8 » 24 Mar 2014

I' running a strategy for many years on metastock (to IB TWS) without any problem but I'm switching to MC now. I'm trying to convert the formula correctly to test MC.

The last sessions, the signals looked almost 100% similar until today. MC is going short altough in Metastock it's still long and MS has it correct.

There should only be a short AFTER the long has an exitsignal. Not switching directly from long to short as soon the shortcondition is met.

And vice versa, only long after a shortexit.
(When LX, it's possible to have a SX on the bar)

Is there a solution for this?
For example, putting all the conditions (LE,LX, SE, SX) into one file?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Short signal in MC when still long in MS

Postby TJ » 24 Mar 2014

I' running a strategy for many years on metastock (to IB TWS) without any problem but I'm switching to MC now. I'm trying to convert the formula correctly to test MC.
The last sessions, the signals looked almost 100% similar until today. MC is going short altough in Metastock it's still long and MS has it correct.
There should only be a short AFTER the long has an exitsignal. Not switching directly from long to short as soon the shortcondition is met.
And vice versa, only long after a shortexit.
(When LX, it's possible to have a SX on the bar)
Is there a solution for this?
For example, putting all the conditions (LE,LX, SE, SX) into one file?
EasyLanguage can be programmed to execute your logic, but you have to specific as to your intent.

e.g. If you have a LONG postion, you can have the following options:

using the keyword SELL will liquidate your LONG position. ie. go flat.
using the keyword SELLSHORT will liquidate your LONG position, and at the same time enter you into a SHORT position.

Using the proper keyword will ensure the execution of your orders as intended.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Short signal in MC when still long in MS

Postby TJ » 24 Mar 2014

::
Is there a solution for this?
For example, putting all the conditions (LE,LX, SE, SX) into one file?
You can put all the conditions in one file.
Most of the programmers would prefer to have all the logics in one file.

Dirk8
Posts: 26
Joined: 24 Mar 2014
Has thanked: 10 times
Been thanked: 1 time

Re: Short signal in MC when still long in MS

Postby Dirk8 » 25 Mar 2014

::
Is there a solution for this?
For example, putting all the conditions (LE,LX, SE, SX) into one file?
You can put all the conditions in one file.
Most of the programmers would prefer to have all the logics in one file.

----
It's in 4 files now (LE,LX,SE,SX) but I use the commands Buy, Sell, Sell Short and BuyToCover so that should not give a problem isn't?

Hereunder my testing system:
------
LONG
------
Inputs: Displace( 0 ),
Price( Close);

variables: var1( 0 );

var1 = WAverage( Price, 30);

if Displace <= 0 then
begin
condition1 = Close > var1 ;
if condition1 then
Buy ( "DBLong" ) next bar at market ;
end ;

----------
LONGEXIT
-----------

Inputs: Displace( 0 );
variables: var1( 0 );

var1 = Lowest( Low, 10 )[1];

if Displace <= 0 then
begin
condition1 = Close < var1
;
if condition1 then
Sell ( "DBExitL" ) next bar at market ;
end ;

-------
SHORT
-------

Inputs: Displace( 0 ),
Price( Close);

variables: var1( 0 );

var1 = WAverage( Price, 20 );

if Displace <= 0 then
begin
condition1 = Close < var1;
if condition1 then
Sell Short ( "DBShort" ) next bar at market ;
end;

------
Altough, the SELL condition was not met, the SELL SHORT condition was met and the system goes SHORT.
How can I explain that the SELL SHORT can only be done, after a SELL (exit long) condition?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Short signal in MC when still long in MS  [SOLVED]

Postby Andrew MultiCharts » 25 Mar 2014

Hello Dirk8,
Altough, the SELL condition was not met, the SELL SHORT condition was met and the system goes SHORT.
How can I explain that the SELL SHORT can only be done, after a SELL (exit long) condition?
If conditions for exiting long (sell) are not satisfied, but the conditions for entering short (seelshort) are satisfied, 1 order to reverse position (if you are long now) into short will be generated and sent.

The solutions for for you would be to combine all 4 scripts into 1 and creating a sequence of conditions checking in order to avoid entering/reversing into short before exiting long. Please take into account the EL order execution priority.


Return to “MultiCharts”