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...
thanks in advance to help me
Indicator Open
-
- Posts: 283
- Joined: 05 Dec 2014
- Location: Italy
- Has thanked: 53 times
- Been thanked: 3 times
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Indicator Open
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.)
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.)
-
- Posts: 283
- Joined: 05 Dec 2014
- Location: Italy
- Has thanked: 53 times
- Been thanked: 3 times
Re: Indicator Open
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.
In this way like shown in my code the position are incresed. Why?
Thanks in advance
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;
Thanks in advance
- Attachments
-
- position.jpg
- (5.07 KiB) Not downloaded yet
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Indicator Open
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.I want to stop and open the opposite position in the same time.In this way like shown in my code the position are incresed. Why?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;