Buy stop and Sell stop order in next bar

Questions about MultiCharts and user contributed studies.
kinwai
Posts: 89
Joined: 03 May 2019
Has thanked: 12 times
Been thanked: 1 time

Buy stop and Sell stop order in next bar

Postby kinwai » 29 Dec 2019

Refer to my below code, when reach high or low in next bar, then will place buy or sell order respectively.
However, I want to buy only when reach high in next bar. Once order placed, I want to set stop loss when reach low, but not to place sell order even marketposition is 0, how to revise my code? Thanks.

Code: Select all

Buy next bar at high stop; Sell next bar at low stop;

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

Re: Buy stop and Sell stop order in next bar

Postby TJ » 29 Dec 2019

Refer to my below code, when reach high or low in next bar, then will place buy or sell order respectively.
However, I want to buy only when reach high in next bar. Once order placed, I want to set stop loss when reach low, but not to place sell order even marketposition is 0, how to revise my code? Thanks.

Code: Select all

Buy next bar at high stop; Sell next bar at low stop;

You need to organize your thoughts a bit -- What you need to do is,
When the latest price of THIS BAR has exceeded the high of last bar . . . Buy next bar at high stop . . .

kinwai
Posts: 89
Joined: 03 May 2019
Has thanked: 12 times
Been thanked: 1 time

Re: Buy stop and Sell stop order in next bar

Postby kinwai » 29 Dec 2019

I know how to describe in sentence, but how to translate in code? Actually, I cannot use this bar to check exceed the high of last bar.

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

Re: Buy stop and Sell stop order in next bar

Postby TJ » 30 Dec 2019

. . . I cannot use this bar to check exceed the high of last bar.
Why not?

Do you know the "High of this bar" before the bar is finished?

kinwai
Posts: 89
Joined: 03 May 2019
Has thanked: 12 times
Been thanked: 1 time

Re: Buy stop and Sell stop order in next bar

Postby kinwai » 30 Dec 2019

Let me elaborate more the logic.

When current bar close, I want to set next bar to buy if price > current bar high and set stop lose to current bar low.

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

Re: Buy stop and Sell stop order in next bar

Postby TJ » 30 Dec 2019

Let me elaborate more the logic.

When current bar close, I want to set next bar to buy if price > current bar high and set stop lose to current bar low.
Let's begin with some trading strategy design basics.

The evaluation of your logic happens in the current bar.
You can ONLY compare the current situation with something happened in the PAST.
Because we do not know the future, we cannot make an evaluation of future events.

Thus I said, you need to organize your thoughts a bit - I know what you mean; it is a matter of timing orientation.
Please re-read my suggestion in the previous post again.

kinwai
Posts: 89
Joined: 03 May 2019
Has thanked: 12 times
Been thanked: 1 time

Re: Buy stop and Sell stop order in next bar

Postby kinwai » 03 Jan 2020

I know you want to use this bar to check the high of last bar. In this case, I may need to enable IOG in backtest, so that to check each tick to place buy order when exceed the high of last bar immediately.

I’m thinking to use buy stop order to avoid to enable IOG. I could use this bar high and place buy stop order in next bar (future event). But don’t know how to set stop loss on this case. When I place both buy and sell stop order, I cannot make sure the buy stop order must execute first.


Return to “MultiCharts”