thanks Nicolas, I just picked that up
LeoParticipant
Veteran
I coded this here with a profit target at the 161.8% fibo extension (that was already bad enough) and at least for the dax the result was not very promising. Here is the code if you want to play with it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
defparam cumulateorders=false
tradingtime=dayofweek>=1 and dayofweek<=5 and time>=90000
MA=ExponentialAverage[15](close)
once tc=0
if time=90000 then
RangeTop=highest[11](high[1])
RangeBottom=lowest[11](low[1])
endif
if intradaybarindex=0 then
tc=0
endif
CL=close>RangeTop and close[1]>RangeTop
CS=close<RangeBottom and close[1]<RangeBottom
box=RangeTop–RangeBottom
if not onmarket and not tc and tradingtime then
if CL and close>MA then
buy 1 contract at market
tc=1
elsif CS and close>MA then
sellshort 1 contract at market
tc=1
endif
set target pprofit box*1.618
endif
if longonmarket then
sell at RangeBottom stop
elsif shortonmarket then
exitshort at RangeTop stop
endif
|
Line 24 should be close< ema,
This strategy sounds interesting, let me know if is working
You are right, there is a typo in the sell short part. Thanks!
Hi, I have simplified my code, but have a small problem. I only want orders to be placed within 10% of the bottom / top of range. Range is the 2nd 4hr candles, and entry is based on 10 min bar closing outside the range. I am getting orders placed after I have taked profit, which is to far from the range. any ideas how to solve that?
defparam cumulateorders=false
tradingtime=dayofweek>=1 and dayofweek<=5 and time>100000 and time <170000
if time=100000 then
RangeTop=highest[24](high[1])
RangeBottom=lowest[24](low[1])
endif
box=RangeTop-RangeBottom
TP1=box*1.1
SL=box*.8
pricezoneS=rangebottom*0.9
pricezoneL=rangetop*1.1
//TP2=box*1.62
//TP3=box*2
entryl= close >= rangetop and close <= pricezonel
entrys=close<= rangebottom and close >= pricezones
if not onmarket and tradingtime then
if entryl then
buy 1 contract at market
//tc=1
elsif entrys then
sellshort 1 contract at market
//tc=1
endif
endif
//set profit to range height
SET TARGET PROFIT TP1
set stop loss SL
Problem is that new orders are being placed as soon as the ‘not onmarket’ condition becomes true again.
Do you perhaps want to limit the strategy to only 1 profitable trade?
Maybe try this, it will only create one set of stop orders for the day;
defparam cumulateorders=false
tradingtime=dayofweek>=1 and dayofweek<=5 and time>100000 and time <170000
If hour = 1 Then
TD = 1
ElsIf hour = 10 and minute = 0 then
RangeTop=highest[24](high)[1]
RangeBottom=lowest[24](low)[1]
endif
box=RangeTop-RangeBottom
TP1=box*1.1
SL=box*0.8
pricezoneS=rangebottom - (box*0.1)
pricezoneL=rangetop + (box*0.1)
If TD = 1 and on market Then
TD = 0
EndIf
if TD = 1 and not onmarket and tradingtime then
buy 2 contract at pricezoneL stop
sellshort 2 contract at pricezoneS stop
endif
//set profit to range height
SET TARGET pPROFIT TP1
set stop ploss SL
//GRAPH RangeTop coloured(255,0,0) AS "RangeTop"
//GRAPH RangeBottom coloured(0,255,0) AS "RangeBottom"
Thanks Juan,
That still produces multiple orders, I only want 1 long or 1 short per day. Once target is hit, we wait for the next day. I am using this on the GBP pairs manually right now with great success (it is basically the London Breakout strategy)
Ok got it like I wanted, now to test on GBP pairs
defparam cumulateorders=false
once order = 0
tradingtime=dayofweek>=1 and dayofweek<=5 and time>100000 and time <170000
if time=100000 then
RangeTop=highest[24](high[1])
RangeBottom=lowest[24](low[1])
order = 0
endif
box=RangeTop-RangeBottom
TP1= box*1.5
SL=box*1.1
pricezoneS=rangebottom*0.9
pricezoneL=rangetop*1.1
//TP2=box*1.62
//TP3=box*2
entryl= close >= rangetop and close <= pricezonel
entrys=close<= rangebottom and close >= pricezones
if not onmarket and not order and tradingtime then
if entryl then
buy 1 contract at market
order = 1
//tc=1
elsif entrys then
sellshort 1 contract at market
order = 1
//tc=1
endif
endif
//set profit to range height
SET TARGET PROFIT TP1
set stop loss SL