EMA Deep USD/JPY 1H
Forums › ProRealTime English forum › ProOrder support › EMA Deep USD/JPY 1H
- This topic has 13 replies, 4 voices, and was last updated 6 years ago by Nicolas.
-
-
08/06/2017 at 5:36 PM #42545
//————————————————————————-
// Morgan Pettersson 2017-08-06
//————————————————————————-
defparam preloadbars = 300
DEFPARAM CumulateOrders = true // Cumulating positions activatedmdays = 26
myStoploss = 30
myProfit = 48
myLots = 1EMA20=ExponentialAverage[20](close)
EMA50=ExponentialAverage[50](close)
EMA200=ExponentialAverage[200](close)//UpTrend
c1 = summation[mdays](ema20>ema50)=mdays
c2 = summation[mdays](ema50>ema200)=mdays
UpTrend = c1 and c2//Bullish Dip PinBar ema20
c3 = low < ema20 and close > ema20
c4 = close > open
c5 = abs(open-close)/abs(open-low) <= 0.5
BullishDipCondition = c3 and c4 and c5//*************************************
//Conditions to enter long positions
//*************************************IF UpTrend and BullishDipCondition THEN
IF SHORTONMARKET THEN
EXITSHORT AT MARKET
ENDIF
BUY myLots CONTRACT AT MARKET
SET STOP pTRAILING myStopLoss
SET TARGET pPROFIT myProfit
ENDIF//DownTrend
d1 = summation[mdays](ema20<ema50)=mdays
d2 = summation[mdays](ema50<ema200)=mdays
DownTrend = d1 and d2//Bearish dip
d3 = high > ema20 and close < ema20
d4 = close < open
d5 = abs(close-open)/abs(high-open) <= 0.5
BearishDipCondition = d3 and d4 and d5//*************************************
//Conditions to enter short positions
//**************************************
IF DownTrend and (BearishDipCondition) THEN
IF LONGONMARKET THEN
SELL AT MARKET
ENDIF
SELLSHORT myLots CONTRACT AT MARKET
SET STOP pTRAILING myStopLoss
SET TARGET pPROFIT myProfit
ENDIF08/06/2017 at 5:39 PM #42552Hi, thanks for sharing your automated trading strategy on USD/JPY. Because your post do not has any explanation, I only tried to simulate the same period on my own platform. Unfortunately, I do not get the same results as yours. Could you please explain us a bit how it works, the timeframe used, spread and any other useful information you could share. Thanks gain for sharing your code with the community, much appreciated 🙂
08/07/2017 at 2:26 PM #42677Hello!
Is it because i did not write enough explanation that it did not fit in the library?
Should i do another post with more explanation or put my text here?
/Morgan
08/07/2017 at 6:24 PM #4270108/07/2017 at 9:16 PM #42711USA/JPY mini 1 Hour
Trades from 1 jan 2017 08:00 to 4 aug 22:00.
Spread IG 0.7.
I define an uptrend if EMA20 >EMA>50EMA200
downtrend EMA20<EMA50<EMA200
If there is a pullback in an uptrend back to EMA20 and with a bullish pinbar I buy.
And the precise opposite in an downtrend.
I have had some problems with devisionwith zero that I dont really understand.
Some small changes in this code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071// Definition of code parametersdefparam preloadbars = 600DEFPARAM CumulateOrders = true // Cumulating positions deactivatedmydays = 26myStoploss = 30myProfit = 48myLots = 1var = 0.2EMA20=ExponentialAverage[20](close)EMA50=ExponentialAverage[50](close)EMA200=ExponentialAverage[200](close)//UpTrendc1 = summation[mydays](ema20>ema50)=mydaysc2 = summation[mydays](ema50>ema200)=mydaysUpTrend = c1 and c2//Bullish Dip PinBar ema20c3 = low < ema20 and close > ema20c4 = close > openif(open-low > 0) thenc5 = abs(open-close)/abs(open-low) <= varendifBullishDipCondition = c3 and c4 and c5//DownTrendd1 = summation[mydays](ema20<ema50)=mydaysd2 = summation[mydays](ema50<ema200)=mydaysDownTrend = d1 and d2//Bearish dipd3 = high > ema20 and close < ema20d4 = close < openif(high-open > 0) thend5 = abs(close-open)/abs(high-open) <= varendifBearishDipCondition = d3 and d4 and d5//*************************************//Conditions to enter long positions//*************************************IF UpTrend and (BullishDipCondition) THENIF SHORTONMARKET THENEXITSHORT AT MARKETENDIFBUY myLots CONTRACT AT MARKETSET STOP pTRAILING myStopLoss//SET STOP ploss myStopLossSET TARGET pPROFIT myProfitENDIF//*************************************//Conditions to enter short positions//**************************************IF DownTrend and (BearishDipCondition) THENIF LONGONMARKET THENSELL AT MARKETENDIFSELLSHORT myLots CONTRACT AT MARKETSET STOP pTRAILING myStopLoss//SET STOP ploss myStopLossSET TARGET pPROFIT myProfitENDIF08/07/2017 at 10:52 PM #4271808/07/2017 at 11:15 PM #42720Yes that sounds about right. I only have a demo account at IG so i think thats all the data i got.
08/08/2017 at 9:04 AM #4273108/08/2017 at 9:45 AM #42736None. The trend check is some standard values for ema that i use when i manuelly trade.
I developed the strategy and then tested it on different intrument. It worked best on USA/JPY and its my favourite for manuell trading so i used it.
I have changed the size of the pinbar to 0.2 from 0.5. The var varible. But I’m not sure if it’s for the better or not 🙂
/Morgan
08/08/2017 at 10:22 AM #4274008/09/2017 at 9:45 AM #42790Yesterday i got division by zero again. I dont know why?
08/09/2017 at 9:10 PM #42835Hi, having a quick read at your code, you have c5 and d5 with respectively open-low and high-open at denominator. So just a guess with good probability: your division by zero message probably matches candles for which open=low or open=high
10/29/2017 at 3:32 PM #50824What more can I do to avoid division with zero?
This coding language is really limited. No error handeling ..
c = abs(close-open)
d = abs(high-open)if d > 0 then
b = (c/d) <= 0.5
endif10/29/2017 at 6:23 PM #50832 -
AuthorPosts
Find exclusive trading pro-tools on