Hi,
I have an idea where I want to buy or sell at the open of the next candle + 2 pips/points in the 1-min timeframe
Now I created the following code:
OrderTollerance = 2
c1 = open>close[1]
if not onmarket and c1 and hora1 and hora2 then
Buy possize contract at open+OrderTollerance stop
endif
But when I execute the code act randomly.
Sometime it execute direct at Open of the next candle
Sometimes it sets buy/sell limit above/under the Open of the previous candle
Sometime it set a buy/sell limit of 1 above/under the Open
Is the code correct?
OrderTollerance = 3
c1 = open>close[1]
if not onmarket and c1 and hora1 and hora2 then
Buy possize contract at open+OrderTollerance stop
endif
You are likely to be using a STOP pending order, instead of a LIMIT one.
Can you mke an example of the bar where your conditions are met and the open of which bar you want to enter.
Additionally, do you want to to buy 2 pips above or below the OPEN price?
Hi,
The idea is to buy 2 pips above the OPEN price.
See screenshot attached
Ok, you only have to replace STOP with LIMIT in line 6.
Hi,
I changed the code with LIMIT and it is still the same.
The entry is still at the OPEN price (the using the 2 points) and a few candles later it set the entry 2 points below the OPEN price of the previous candle (see screenshot)
It seems that the ‘OrderTollerance’ is not working
OrderTollerance = 2
c1 = open>close[1]
if not onmarket and c1 and hora1 and hora2 then
Buy possize contract at open+OrderTollerance LIMIT
endif
Because the current price (CLOSE) is too close to the entry price (on DAX usually IG requires at least 6 points from the entry price, but it may change when volatility is high) and is entered incorrectly (in live trading the strategy would be interrupted).
On the IG website you may find the values for each instrument/asset.
This is the code with the support for the distance:
OrderTollerance = 2
Distance = 6
c1 = open>close[1]
if not onmarket and c1 and hora1 and hora2 then
EntryPrice = open + OrderTollerance
IF close > (EntryPrice + Distance) THEN
Buy possize contract at EntryPrice LIMIT
ELSIF close < (EntryPrice - Distance) THEN
Buy possize contract at EntryPrice STOP
ELSE
//Buy possize contract at MARKET
ENDIF
endif
I commented out the line where the entry is at MARKET because too close to the Entry price. You may remove the two slashes to enable entering at MARKET in that case.