Don't trade if stopped

Questions about MultiCharts and user contributed studies.
Cicikov
Posts: 5
Joined: 11 Apr 2017
Has thanked: 2 times

Don't trade if stopped

Postby Cicikov » 05 Jun 2018

Hi all,

is there a code for "do not open a new position if during the current session you have been stopped"?

"If entriestoday(date)=0..." works only if I opened the position during this session. I'd like something that works if my original position was opened yesterday or earlier...

Thanks!

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Don't trade if stopped

Postby sptrader » 05 Jun 2018

You might try these functions:
Marketposition and positionproft. (or openpositionprofit).

Cicikov
Posts: 5
Joined: 11 Apr 2017
Has thanked: 2 times

Re: Don't trade if stopped

Postby Cicikov » 05 Jun 2018

You might try these functions:
Marketposition and positionproft. (or openpositionprofit).
thanks but I suppose it doesn't work because after you have been stopped your MP and PP will be 0 and a new trade will be allowd again...

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Don't trade if stopped

Postby JoshM » 05 Jun 2018

You can also try the PosTradeExitCategory keyword. With that keyword we can lookup what kind of order closed a position (i.e., was it a stop order, limit order, market order?). That way you can check if the position was stopped out or reached its profit target.

See PosTradeExitCategory for more.

Cicikov
Posts: 5
Joined: 11 Apr 2017
Has thanked: 2 times

Re: Don't trade if stopped

Postby Cicikov » 08 Jun 2018

You can also try the PosTradeExitCategory keyword. With that keyword we can lookup what kind of order closed a position (i.e., was it a stop order, limit order, market order?). That way you can check if the position was stopped out or reached its profit target.

See PosTradeExitCategory for more.
Thank you Josh, that's a good keyword but a problem still exists, e.g if I got stoppet 3 days ago I want to have the trade today if conditions are met. The only case I don't want to trade is when I get stoppet today and today I also have the condition for the trade. PosTradeExitCategory don't refers to a specific day but only to a specific kind of exit...so how can I say "if I got stoppped and this appened today"?

thanks

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Don't trade if stopped

Postby JoshM » 11 Jun 2018

Thank you Josh, that's a good keyword but a problem still exists, e.g if I got stoppet 3 days ago I want to have the trade today if conditions are met. The only case I don't want to trade is when I get stoppet today and today I also have the condition for the trade. PosTradeExitCategory don't refers to a specific day but only to a specific kind of exit...so how can I say "if I got stoppped and this appened today"?
Yes, but you can combine PosTradeExitCategory() with other keywords to get the time a particular position was opened or closed.

But do you close down MultiCharts at the end of the day, and start it again the next day? Because those keywords like PosTradeExitCategory() only work when your strategy keeps running all the time. If you stop auto-trading, MultiCharts cannot retrieve the position data from 3 days ago.


Return to “MultiCharts”