5M gold strategy win 92% win rate

 

Hello ,


Below you can find my scrip that i have backe tested in gold with more than 90% win rate . please help me to make EA ( MT4) .


Pine scrip : 


//@version=2

strategy("Goldscalping", overlay=true)

tim=input('160')

out1 = security(tickerid, tim, open)
out2 = security(tickerid, tim, close)

plot(out1,color=red)
plot(out2,color=green)

longCondition = crossover(security(tickerid, tim, close),security(tickerid, tim, open))

if (longCondition)
    strategy.entry("long", strategy.long)

shortCondition = crossunder(security(tickerid, tim, close),security(tickerid, tim, open))

if (shortCondition)
    strategy.entry("short", strategy.short)
 
I cannot see your SL nor any TP.

Do you have a definition for that?

Using 2.5 Minutes Periods will need some serious adjustments. Either with accessing Ticks or by creating a custom symbol.

Anyways, spread might very probably eat you up.


 
Would it be possible to create an EA using two 1-period moving average, one price_close and one price_open set for a longer timeframe (this pinescript works with 160 minute timeframe but also 60, 30, 15...)

The problem is that this indicator repaints and see the future bars, if it were real it would be the holy grail that works with all assets.



See what the real code would look like in pinescript (lookahead disabled):

//@version=3

strategy("Goldscalping", overlay=true)

tim=input('160')

out1 = security(tickerid, tim, open)
out2 = security(tickerid, tim, close)

plot(out1,color=red)
plot(out2,color=green)

longCondition = crossover(security(tickerid, tim, close, lookahead=barmerge.lookahead_off),security(tickerid, tim, open))

if (longCondition)
    strategy.entry("long", strategy.long)

shortCondition = crossunder(security(tickerid, tim, close, lookahead=barmerge.lookahead_off),security(tickerid, tim, open))

if (shortCondition)
    strategy.entry("short", strategy.short)






 
Oh, interesting, it's 160 minutes. I suspected seconds.

So in pine script you have to turn off lookahead?


 
Dominik Christian Egert #:
Oh, interesting, it's 160 minutes. I suspected seconds.

So in pine script you have to turn off lookahead?

@version 3 and disabled lookahead is necessary if you want a true backtest without interference from future data

 
Felipe Matheus Isidorio #: Would it be possible to create an EA using two 1-period moving average, one price_close and one price_open set for a longer timeframe (this pinescript works with 160 minute timeframe but also 60, 30, 15...). The problem is that this indicator repaints and see the future bars, if it were real it would be the holy grail that works with all assets. See what the real code would look like in pinescript (lookahead disabled):

Using the same period for both moving averages, and given that the open price is most often almost the same as the close price of the previous bar, you are essentially just using one moving average and simply detecting its slope, whether up or down.

 
Fernando Carreiro #:

Using the same period for both moving averages, and given that the open price is most often almost the same as the close price of the previous bar, you are essentially just using one moving average and simply detecting its slope, whether up or down.

Yes, but I just translate the logic of this indicator

And it works since it is crossover (open[0]>close[0] && open[1]<close[1]) but it is not profitable.

 
Felipe Matheus Isidorio #:

Yes, but I just translate the logic of this indicator

And it works since it is crossover (open[0]>close[0] && open[1]<close[1]) but it is not profitable.

SL would be work with fractal : it means lowest fractal in 5M could be SL ( also can set it as 15 min but i have tested 5 min SL is better )  for TP : there is two way : first one highest pervious fractal pivot  and second one trailing profit with highest high