Indicator Open

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

Indicator Open

Postby tradingest » 01 Jun 2020

Hi there,

I have built an indicator that works on opening the candle.
The indicator during the life of the candle doesn't change. I'd like to use it in Open candle and not in the next candle.
For example I want to open the candle where appear my red arrow because the indicator shown below is formed when the candle is opened.

How can I do? If I write buy ("Long") 1 contract next bar at Open; open in the next candle while I want to open when the indicator is below the line but this value is formed on Open candle...

Image

thanks in advance to help me
Attachments
Open.jpg
(8.18 KiB) Not downloaded yet

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

Re: Indicator Open

Postby JoshM » 04 Jun 2020

I don't know if I fully understand, but you can use `BarStatus()` to look if the script calculates on the opening tick of the bar.

That should make it possible to trade the value that the indicator had at the open of the bar.

(Note that your strategy does need to use `IntraBarOrderGeneration` for this to work.)

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

Re: Indicator Open

Postby tradingest » 04 Jun 2020

Thanks JoshM,

you are very kind. I have resolved thanks to you but I have another problem to resolve.
My code below it's very easy, I want to stop and open the opposite position in the same time.

Code: Select all

if MACD >0 and MP =0 and WPR[1] < 80 then begin Buy ("Long") 1 contract next bar at C limit; end; if MACD <0 and MP = 1 then begin Sell ("Stop Long") 1 contract next bar at close limit; sellshort ("Short1") 1 contract next bar at C limit; end;
In this way like shown in my code the position are incresed. Why?

Image


Thanks in advance
Attachments
position.jpg
(5.07 KiB) Not downloaded yet

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

Re: Indicator Open

Postby JoshM » 05 Jun 2020

I want to stop and open the opposite position in the same time.

Code: Select all

if MACD >0 and MP =0 and WPR[1] < 80 then begin Buy ("Long") 1 contract next bar at C limit; end; if MACD <0 and MP = 1 then begin Sell ("Stop Long") 1 contract next bar at close limit; sellshort ("Short1") 1 contract next bar at C limit; end;
In this way like shown in my code the position are incresed. Why?
Good question! But I cannot really say unfortunately. Can it be that your `MP` variable doesn't change? When that variable remains 1, your limit orders will be submitted even though they might already be filled.


Return to “MultiCharts”