Hi, i need help coding a strategy having following rules:
- from H1 open
- if price moves 5 points either direction. If above open=Buy 1 contract, if below open=short 1 contract
- set target and SL 10 points
There you go (not tested):
Timeframe(1h,UpdateOnClose)
c = close
Timeframe (default)
Buy 1 Contract at c + 5 Stop
Sellshort 1 Contract at c - 5 Stop
Set Target pProfit 10
Set Stop pLoss 10
I would recommend to adapt 5 with the pointsize, if it is not equal to 1:
Timeframe(1h,UpdateOnClose)
c = close
Timeframe (default)
Buy 1 Contract at c + 5*pointsize Stop
Sellshort 1 Contract at c - 5*pointsize Stop
Set Target pProfit 10
Set Stop pLoss 10
thanks you guys!
im getting this problem (see attachment) and if i disable tick it shows insanly good result, does not seem right?
You have a stop loss too close to the market entry …. do a test by further distancing the stop.
It must process too much tick by tick data
thanks!
can someone please add time restriction, trading hours between 8-11
There you go:
Timeframe(1h,UpdateOnClose)
c = close
Timeframe (default)
IF time >= 080000 AND time <= 110000 THEN
Buy 1 Contract at c + 5*pointsize Stop
Sellshort 1 Contract at c - 5*pointsize Stop
Set Target pProfit 10
Set Stop pLoss 10
ENDIF
TIME is the time when a bar closes. If you want to refer the time it opens use OPENTIME, instead.
thanks alot!! one last thing, if i want to add that it closes all position after 17,30, how to add that code?
Add this as the first line:
DEFPARAM FlatAfter = 173000
or you can use these common lines:
If Time >= 173000 and OnMarket Then
Sell at Market
Exitshort at Market
Endif