How to make MC doesn't reverse my trade if needed?

Questions about MultiCharts and user contributed studies.
oliveagle
Posts: 20
Joined: 07 Jul 2011
Has thanked: 4 times
Been thanked: 4 times

How to make MC doesn't reverse my trade if needed?

Postby oliveagle » 04 Aug 2011

1st Question : How to stop MC reversing my position?
2nd Question: How can I stop trading at lastHour of friday?

actually they are the same question I think.

Here is the thing. MC will automatically reverse my entry signals.
For example the simplest trading strategy may looks like this:
---------------------code start --------------
MA1 = MA(10);
MA2 = MA(20);

if MA1 crossover MA2 then
buy 1 contract next bar at open;
if MA2 crossover MA1 then
sellshort 1 contract next bar at open;
------------------code end----------------------
u don't need a exit signal. Usually, it works fine. but in some circumstances, I don't want to let MC close my open position and establish a reversal position at the same time. for example, I just want the system stop trading at the lasthour of friday.
here is my code to do this, which is not work actually.
--------------- code start -----------------------------
MP = MarketPosition;

if dayofweek(date) = friday and LastHour then begin
if MP = 1 then
sell currentcontracts contracts this bar at close;
if MP = -1 then
buytocover currentcontracts contracts this bar at close;

end else begin
// we start to trading from here.

end;
--------------code end ----------------------------------
I just want to know whether there is any good solution for this?

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

Re: How to make MC doesn't reverse my trade if needed?

Postby TJ » 04 Aug 2011

it is easier to go the other way...

Code: Select all

if time < lasthour then
begin

// put your trading logic here

end
else

// liquidate your positions

oliveagle
Posts: 20
Joined: 07 Jul 2011
Has thanked: 4 times
Been thanked: 4 times

Re: How to make MC doesn't reverse my trade if needed?

Postby oliveagle » 04 Aug 2011

it is easier to go the other way...

Code: Select all

if time < lasthour then
begin

// put your trading logic here

end
else

// liquidate your positions

The problem is how to liquidate my positions without getting reversed by MC automatically?

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

Re: How to make MC doesn't reverse my trade if needed?

Postby TJ » 04 Aug 2011

The problem is how to liquidate my positions without getting reversed by MC automatically?
your liquidation code should be able to do that without error.

Can you draw a flow chart to illustrate your logic?

oliveagle
Posts: 20
Joined: 07 Jul 2011
Has thanked: 4 times
Been thanked: 4 times

Re: How to make MC doesn't reverse my trade if needed?

Postby oliveagle » 05 Aug 2011

The problem is how to liquidate my positions without getting reversed by MC automatically?
your liquidation code should be able to do that without error.

Can you draw a flow chart to illustrate your logic?
I find out the problem myself. thx any way. pal

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

Re: How to make MC doesn't reverse my trade if needed?

Postby TJ » 05 Aug 2011

The problem is how to liquidate my positions without getting reversed by MC automatically?
your liquidation code should be able to do that without error.

Can you draw a flow chart to illustrate your logic?
I find out the problem myself. thx any way. pal
As a mutual beneficial community,
you should share your findings.

oliveagle
Posts: 20
Joined: 07 Jul 2011
Has thanked: 4 times
Been thanked: 4 times

Re: How to make MC doesn't reverse my trade if needed?

Postby oliveagle » 15 Aug 2011

As a mutual beneficial community,
you should share your findings.
Yes. The problem is not the code. It's the rule of enter and exit.

The rule I use will always reverse itself in nature.
They are something looking like this.

Code: Select all

longCondition = MA1 crosses above MA2;
shortCondition = MA2 crosses above MA1;
each time a long enter will cause a short position get flatten, and vice versa.
That's the problem. hahaha...

BTW, thx your advice about sharing my findings.


Return to “MultiCharts”