pAulseperformance

MA Cross - ***Programmers*** Please help with alertcondition()

Hello Traders and coders,

Here is a fundamental version of a moving average cross trading strategy that works on 1H and 4H timeframes.

It's very simple and would be well paired with proper technical analysis and risk management.

I am looking to use this to alert me of potential setups. I could not get the alertcondition function to work properly. If anyone can help me with that please comment or message me.
Open-source Skript

Ganz im Sinne von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es verstehen und überprüfen können. Ein Hoch auf den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln. Sie können das Skript den Favoriten hinzufügen, um es auf dem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?
//@version=2
strategy(shorttitle = "Gamma pips EMA Cross", title="MA Cross", overlay=true)
s100sma = sma(close, 100)
s200sma = sma(close, 200)
s26ema = ema(close,26)
s12ema = ema(close,12)

plot(s100sma, color = green, linewidth = 5)
plot(s200sma, color = blue, linewidth = 5)
plot(s26ema, color = yellow, linewidth = 3)
plot(s12ema, color = red, linewidth = 3)
EMACross = plot(cross(s26ema, s12ema) ? s26ema : na, style = cross, linewidth = 5, color = red)
SMACross = plot(cross(s100sma, s200sma) ? s200sma : na, style = cross, linewidth = 5, color = white)
Alert = cross(s26ema, s12ema)
alertcondition(Alert, title="EMA Crossing")

//============ signal Generator ==================================//
EMACrossover = crossover(s26ema, s12ema) //if yellow cross and is above red ->SELL
EMACrossunder = crossunder(s26ema, s12ema) //if yellow cross and is below red ->BUY
SMACrossover = crossover(s100sma, s200sma) //green crosses above blue ->Buy
SMACrossunder = crossunder (s100sma, s200sma) //green crosses below below ->Sell
price = close
BuyCondition = (EMACrossunder) and (price >= s100sma)
SellCondition = (EMACrossover) and (price <= s100sma)

///---------Buy Signal-------------///
if (BuyCondition)
    strategy.order("BUY ema crossunder", strategy.long)

 
///Short signal------//
if(SellCondition)
    strategy.order("SELL ema crossover", strategy.short)
   

Kommentare

Alertconditon dont work in strategy only in study ;)
+4 Antworten
If you have yet to figure this out, I would be happy to help
Antworten
I'm sure you've figured this out after 5 months, but for anyone having the same problem I'm pretty sure it's because alertcondition doesn't work if the script is a strategy. Only if it's a study (the relevant part is mentioned on line 2) - I'm not fully confident this is the case, but there's so like Pine script info available online I figured I'd try and contribute.
Antworten
scarf scarf
*little
Antworten
@scarf, Replying to your edit - thanks for the information. Any one else still trying to figure this out, this is the case. You cannot have it as a strategy, it must be a study.
+4 Antworten
Hello,

Were you able to get a solution to this? I have a project I'd like to implement (pay for someone to develop) and it depends on being able to alert by sms. Just wondering if you solved it? - thanks! Also, how do I find programmers on here who are available for hire?
Antworten
@niallc, Hi Niall I used Codementors to find a programmer to help me out with the pine scripts. Cost me only 15$ for 15 minutes on a 1 to 1 video chat. https://www.codementor.io/r/T3J3LG26F2.
Did you find another solution yourself.
Greetings from Cork, love the flag btw.
Antworten
niallc IrishInvestor
@IrishInvestor, Fair play to you - thanks! I never followed up on that and took a break from trading actively so no...never did get a solution. But I'll be bookmarking that site for sure. I live in Atlanta now, but I'll be back in Dublin for me father's birthday in a week or so...Cheers and Be Well. Niall.
Antworten