To avoid the trade at the same previous price  [SOLVED]

Questions about MultiCharts and user contributed studies.
tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

To avoid the trade at the same previous price

Postby tradingest » 22 Oct 2016

Hi all,

attached my problem that I want to avoid for not getting the trade at the same level of the previous.
The trade value is at a High candle

Image

Somebody can you help me?

Thanks,
tradingest
Attachments
the_same_value.JPG
(51.78 KiB) Downloaded 1360 times

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: To avoid the trade at the same previous price

Postby tradingest » 24 Oct 2016

somebody can you help me to resolve this problem?

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: To avoid the trade at the same previous price

Postby tony » 24 Oct 2016

A conditional statement included in your order generation commands as simple as the following would work

Code: Select all

close <> entryprice(1) // if current price which is close doesn't equal entry price of the prior position
Or if you wanted to have entry perhaps a few ticks above a prior value you can use

Code: Select all

( close - entryprice(1) ) > 5 * TickSize // If current price is 5 ticks above prior entry price.

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: To avoid the trade at the same previous price

Postby tradingest » 25 Oct 2016

Hi tony,

entryprice(1) to avoid the trade in the next day by previous price or this condition is always true also in the following days?

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: To avoid the trade at the same previous price

Postby tradingest » 25 Oct 2016

Hi tony,

I have read that entryprice (1) representing the number of positions ago. Perfect! That said my question is: this function entryprice consider the order place or the real price filled?

I work with limit order and the signal is generated from H(n). If I write code H (n) <>entryprice (1) is always verified because the entryprice is always different from H (n) due to slippage.

How I can make it?

thanks as always,
tradingest

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

Re: To avoid the trade at the same previous price

Postby JoshM » 25 Oct 2016

I work with limit order and the signal is generated from H(n). If I write code H (n) <>entryprice (1) is always verified because the entryprice is always different from H (n) due to slippage.
If "H(n)" returns your limit price, you can also store that value in variable. Then, when the next limit order situation comes up, you can verify the then-current value of H(n) with the value stored in the variable. Or do I misunderstand completely?

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: To avoid the trade at the same previous price

Postby tradingest » 25 Oct 2016

it's possible to have an example?

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

Re: To avoid the trade at the same previous price

Postby JoshM » 25 Oct 2016

it's possible to have an example?
What's the code that you already have? That also makes it a lot easier for us to give focused and concrete help.

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: To avoid the trade at the same previous price

Postby tradingest » 25 Oct 2016

now I don't have the code. I'd like the generic example

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

Re: To avoid the trade at the same previous price

Postby JoshM » 25 Oct 2016

now I don't have the code. I'd like the generic example
I don't have the time to write (and test on real-time data) a trading strategy for you, and then incorporate any feedback you have.

Perhaps someone else can help you with that.

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: To avoid the trade at the same previous price

Postby tradingest » 25 Oct 2016

thanks for help but I hope that somebody is more pragmatic.

Nobody ask you to write the strategy for me but I want only hint.

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

Re: To avoid the trade at the same previous price

Postby JoshM » 25 Oct 2016

thanks for help but I hope that somebody is more pragmatic.

Nobody ask you to write the strategy for me but I want only hint.
For a hint, I would code my previous comment like this:

Code: Select all

Variables:
IntrabarPersist prevLimitPrice(0),
IntrabarPersist currentLimitPrice(0),
IntrabarPerist goodToBuy(false);

// Assuming `enterLong` is only true once for each entry order
if (enterLong = true) then begin

currentLimitPrice = H(n);

goodToBuy = currentLimitPrice <> prevLimitPrice;

prevLimitPrice = currentLimitPrice;

end;

if (goodToBuy) then
Buy 1 contracts next bar at currentLimitPrice limit;

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: To avoid the trade at the same previous price

Postby tony » 25 Oct 2016

Hi tony,

I have read that entryprice (1) representing the number of positions ago. Perfect! That said my question is: this function entryprice consider the order place or the real price filled?

I work with limit order and the signal is generated from H(n). If I write code H (n) <>entryprice (1) is always verified because the entryprice is always different from H (n) due to slippage.

How I can make it?

thanks as always,
tradingest
Entry price would be the price you filled. So it should take in account any slippage, etc. But if you are using limit orders, then entry price and your limit price for the generated order should be identical and there should be no slippage in the first place.

And entryprice(1) would be the prior position so not necessarily for today but could be a prior day.

tradingest
Posts: 283
Joined: 05 Dec 2014
Location: Italy
Has thanked: 53 times
Been thanked: 3 times

Re: To avoid the trade at the same previous price

Postby tradingest » 25 Oct 2016

Hi Tony,

sorry I'm confused. I use stop order. This approach work the same?

tradingest

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: To avoid the trade at the same previous price  [SOLVED]

Postby tony » 25 Oct 2016

Hi Tony,

sorry I'm confused. I use stop order. This approach work the same?

tradingest
You said earlier you use limit orders. Regardless, entryprice returns the price you filled at per your broker. That may be different if you are not using SA mode, I don't know 100%. What you are trying to do is pretty straightforward and what Josh and I wrote above should clear up any issues you have. Part of the learning process is trying things in PLE, print out variables if needed to see if you are writing conditions correctly, etc and learn from your mistakes until you produce the outcome you desire. It's how all of us have learned and continue to learn. Good luck. You'll get it.


Return to “MultiCharts”