Pips condition above or below EMA to trigger an order
Forums › ProRealTime English forum › ProOrder support › Pips condition above or below EMA to trigger an order
- This topic has 7 replies, 2 voices, and was last updated 6 years ago by Nicolas.
-
-
10/01/2018 at 12:56 PM #81668
Hi,
my expert has 2 EMA: 36 and 12.
When 12EMA cross over or under 36EMA and price go away from 36 about X=number of pips and then return and touch 12EMA:
Open long if 12 EMA cross over 36 EMA and price go away X numeber of pips.
Open short if 12 EMA cross under 36 EMA and price go away X numeber of pips.
Could you write me how can I code that price have to go away for example 30 pips from EMA 36???
Thanks
10/02/2018 at 7:28 AM #81727The below code should trigger the orders as per your description.
123456789101112131415161718192021222324252627282930defparam cumulateorders=falsefast = average[12,1]slow = average[36,1]distance = 30if (fast>slow and high crosses over level) or (fast<slow and low crosses under level) thentrigger = 1endifif fast crosses over slow thenif trigger=1 thenbuy at marketendiflevel = slow+distance*pointsizetrigger = 0elsif fast crosses under slow thenif trigger=1 thensellshort at marketendiflevel = slow-distance*pointsizetrigger = 0endif//graph fast coloured(0,200,0)//graph slow coloured(200,0,0)//graph high//graph low//graph levelgraph trigger1 user thanked author for this post.
10/02/2018 at 3:56 PM #81780Grazie Nicolas,
puoi aiutarmi ancora?
La condizione dei 30 pips ci deve essere dopo che è avvenuto l’incrocio della 12 con la 36, e questo è ok.
Ma per aprire un trade short o long il prezzo una volta superato il limite dei 30 pips deve tornare indietro, toccare la ema 36 ed il trade si apre ad apertura candela successiva al tocco.
10/02/2018 at 4:21 PM #8178110/02/2018 at 4:30 PM #81783Thanks, Nicolas
can you help me again?
The condition of the 30 pips must be there after the crossing of 12 with 36 has occurred, and this is ok.
But to open a trade short or long the price once exceeded the limit of 30 pips must go back, touch ema 36 and the trade opens at the opening candle next to touch.
10/04/2018 at 9:45 AM #81886I don’t understand since this is what the code does actually. By “touch ema 36”, do you mean a new crossover ? Or a single touch ? and the trade should open in what direction ?
1 user thanked author for this post.
10/05/2018 at 2:24 PM #82067If I have a cross over this is level=0, price have to move level+30pips, then price have to return down and touch EMA36, after touch I open a long trade.
If I have a cross under this is level=0, price have to move level-25pips, then price have to return up and touch EMA36, after touch I open a short trade.
10/08/2018 at 8:30 AM #82233Ok, so that’s almost completely different, the below code should work as intended:
123456789101112131415161718192021222324252627282930defparam cumulateorders=falsefast = average[12,1]slow = average[36,1]buydistance = 30selldistance = 25if onmarket thenbuytrigger=0selltrigger=0endifif fast>slow and high crosses over slow+buydistance*pointsize and not onmarket thenbuytrigger = 1endifif buytrigger thenbuy at slow limitendifif fast<slow and low crosses under slow-selldistance*pointsize and not onmarket thenselltrigger=1endifif selltrigger thensellshort at slow limitendifset target pprofit 10set stop ploss 20I added takeprofit and stoploss values, otherwise the first trade will never end! 🙂
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on