Catch a move each day with the channel made during night
Forums › ProRealTime English forum › ProOrder support › Catch a move each day with the channel made during night
- This topic has 14 replies, 3 voices, and was last updated 8 years ago by Adolfo.
-
-
04/22/2016 at 9:43 AM #5783
Hi,
I have tried to write a code that “Catch a move each day with the channel made during night”. It dose that by define a channel each night, and then add some distance to a Buystop and a Sellimit. But I cant get it right, can some please help? 🙂
12345678910111213141516171819//Goal to place a buystop some distance over the channel made during night, and a sellimit some distance under the channel made during night.defparam preloadbars =20If time = 060000 then // an attempt to define the channel made during nightHL = highest[4](high)LL = lowest[4](low)endifHL1 = HL+2 //an attempt to add distance upp and down on the channel made during night.LL1 = LL-2c1 = close > HL1//c2 = close < LL1If time > 070000 and time < 170000 and c1 thenbuy 1 shares at HL1 stopsellshort 1 shares at LL1 limitendifExit by Stoploss and takeprofit
04/22/2016 at 9:45 AM #5785Its made for OMX, or similar. And on 30M, or lesser timeframe.
04/22/2016 at 9:54 AM #5787At line 13, for your c1 condition you are testing if close is already above HL1.
Then at line 17 you’re trying to place a stop order at HL1, but you cannot do that, because a stop pending order must be placed above the price (for buying purpose).
If you already known that the price has break up your defined zone (c1 is true), then just BUY at that moment directly on market, without setting a stop order:
1buy 1 shares at marketThat is for the buy condition. For your sell one, you have totally messed up the whole code here 🙂 Because if you want to set pending orders, don’t test if price has already crossed up or down your trigger prices! Just defined your pending orders and that’s all! 😉
04/22/2016 at 12:04 PM #5800Thanks Nicolas!
I tried this:1234567891011121314151617181920212223242526272829defparam preloadbars =400if intradaybarindex = 0 thenopenbuy=0opensell=0endifIf time = 060000 thenHL = highest[360](high)LL = lowest[360](low)endifHL1 = HL+2LL1 = LL-2c1 = close > HL1c2 = close < LL1If time > 060000 and time < 160000 and c1 thenbuy 1 shares at marketopenbuy = openbuy+1endifIf time > 060000 and time < 160000 and c2 thensellshort 1 shares at marketopensell = opensell+1endifSET STOP PLOSS 5But the system takes so many trades a day, like in the picture. I wish it only to take one buy and/or one sell-trade day.
04/22/2016 at 12:04 PM #5802I use it on 1 min timeframe now 🙂
04/22/2016 at 12:08 PM #5803Sorry, I found the problem 🙂
It should be like this:
1234567891011121314151617181920212223242526272829defparam preloadbars =400if intradaybarindex = 0 thenopenbuy=0opensell=0endifIf time = 060000 thenHL = highest[360](high)LL = lowest[360](low)endifHL1 = HL+2LL1 = LL-2c1 = close > HL1c2 = close < LL1If time > 060000 and time < 160000 and openbuy=0 and c1 thenbuy 1 shares at marketopenbuy = openbuy+1endifIf time > 060000 and time < 160000 and opensell=0 and c2 thensellshort 1 shares at marketopensell = opensell+1endifSET STOP PLOSS 504/22/2016 at 12:21 PM #5805Hi, i’m working on a breakout strategy and get this:
123456789101112131415161718192021222324252627282930313233343536373839404142434445REM No acumular órdenesDEFPARAM CumulateOrders=TrueREM Horario de operativaDEFPARAM FlatBefore = 090100DEFPARAM FlatAfter = 152900REM APERTURA//apertura=dopen(0)REM Maximo y minimo nocturnoif time=080000 then // Select time when max and min are testedmaximo=dhigh(0)+x*pipsize // x= points distance above maximum night rangeminimo=dlow(0)-y*pipsize //y= points distance under minimum night rangeendifREM If price is in night range both orders are "STOP"if HIGH<maximo and LOW>minimo thenif not onmarket thenbuy myLOT contract at maximo stopsellshort myLOT contract at minimo stopset target pprofit yourprofitset stop ploss yourstopendifREM If price is above maximumif Close>maximo thenif not longonmarket thenbuy myLOT contract at maximo limit // buy in a pullbackbuy myLOT contract at market // Buy at marketset target pprofit yourprofitset stop ploss yourstopendifENDIFREM ENTRAR AL MERCADO POR DEBAJO DEL RANGOREM VENDERIF Close<minimo thenif not shortonmarket and posicion>1 thensellshort myLOT contract at minimo limitsellshort mylot shares at marketset target pprofit yourprofitset stop ploss yourstopendifendifI did a backtest on it and seems like it’s working fine, hope it helps you!
Cheers
04/22/2016 at 1:43 PM #581504/22/2016 at 2:05 PM #5816Is it possibile maybe to filter trades by, for example, SuperTrend? 🙂
04/22/2016 at 2:24 PM #581704/22/2016 at 3:11 PM #5821Sorry, my bad, its an indicator:
http://www.prorealcode.com/documentation/supertrend/04/22/2016 at 7:21 PM #5834This was the best I came up with today, BUT it need more backtesting!
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455//-------------------------------------------------------------------------// Main code : Tid kväll 2 1 min x//-------------------------------------------------------------------------defparam preloadbars =800cl=461cs=361x=5y=4if intradaybarindex = 0 thenopenbuy=0opensell=0endif//SP = Supertrend[30,10]//SPU = close > SP//SPD = close < SPIf time = 060000 thenHL = highest[360](high)LL = lowest[360](low)endifHL1 = HL+xLL1 = LL-yc1 = close > HL1c2 = close < LL1If time > 060000 and time < 150000 and openbuy=0 and c1 thenbuy 1 shares at marketopenbuy = openbuy+1endifIf time > 060000 and time < 150000 and opensell=0 and c2 thensellshort 1 shares at marketopensell = opensell+1endifIf longonmarket and close<close[cl] thensell at marketendifIf shortonmarket and close>close[cs] thenexitshort at marketendifSET TARGET PPROFIT 70SET STOP PTRAILING 35// Optimera cl och cs 0, 725, 25// Optimera x och y 2, 20, 104/22/2016 at 7:54 PM #5836It dosent seem to work on other period then I tested on 🙂
04/23/2016 at 12:19 PM #5841Hi again Nicolas, Adolfo or someone else.
I would like to make a filter (or system) witch only allows trades
if the prize sometime during the day,
during a period of 8 hours hasn’t moved more than 2 points.
If the prize after the 8 hours period breaks up or down,
the system should take an order in the direction.I have tried to make this, but can’t get it right.
I use it on 5 min timeframe.I tried this:
123456789HL <span class="token operator">=</span> <span class="token indicators">highest</span><span class="token punctuation">[</span><span class="token number">96</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token keyword">close</span><span class="token punctuation">)</span>LL <span class="token operator">=</span> <span class="token indicators">lowest</span><span class="token punctuation">[96</span><span class="token punctuation">]</span><span class="token punctuation">(close</span><span class="token punctuation">)</span>HL1 <span class="token operator">=</span> HL<span class="token operator">+</span>xLL1 <span class="token operator">=</span> LL<span class="token operator">-</span>ychannel = LL1 - HL1 <= 2But I don’t know how to define the “8h, no more than 2 points” channel.
Thanks!04/23/2016 at 12:58 PM #5842 -
AuthorPosts
Find exclusive trading pro-tools on