Hi to all,
For the compiler the dividing lines of this code are not correct. Can you explain please?
if (macdResult == 0 || stochResult == 0 || bollingerResult == 0)
Hi Steve,
I changed the wrong line with the first one suggested by you and seems correct. By the way the compiler still doesn't want to load the script, even there are apparently no errors.
So I would let you see all the script so you could see if there's something wrong, and if you like make some corrections. Maybe you will get some fun:)
It's a script for scalping EUR/USD at 15 mins, but I think it could work also for cryptovalues.
Here's the script
//@version=5
study("My EUR/USD Trade")
// Set the currency pair to trade
string symbol = "EUR/USD"
// Set the lot size to trade
double lot = 0.01
// Set the stop loss and take profit levels in pips
int sl = 30
int tp = 60
// Calculate the stop loss and take profit levels in terms of the symbol's base currency
double stopLoss = SymbolInfoDouble(symbol, SYMBOL_BID) - sl * SymbolInfoDouble(symbol, SYMBOL_POINT)
double takeProfit = SymbolInfoDouble(symbol, SYMBOL_BID) + tp * SymbolInfoDouble(symbol, SYMBOL_POINT)
// Create arrays to store the MACD, Stochastic and Bollinger Bands values
double macd[]
double macdSignal[]
double macdHist[]
double slowK[]
double slowD[]
double upperBand[]
double middleBand[]
double lowerBand[]
// Calculate the MACD values
int fastLength = 12
int slowLength = 26
int signalLength = 9
int macdResult = iMACD(symbol, PERIOD_M15, fastLength, slowLength, signalLength, PRICE_CLOSE, macd, macdSignal, macdHist)
// Calculate the Stochastic values
int stochLength = 14
int stochSmoothing = 3
int stochResult = iStochastic(symbol, PERIOD_M15, stochLength, stochSmoothing, PRICE_CLOSE, MODE_MAIN, slowK, slowD)
// Calculate the Bollinger Bands values
int bollingerPeriod = 20
int bollingerDeviation = 2
int bollingerResult = iBands(symbol, PERIOD_M15, bollingerPeriod, bollingerDeviation, PRICE_CLOSE, MODE_MAIN, upperBand, middleBand, lowerBand)
// Check if the MACD, Stochastic and Bollinger Bands calculations were successful
if macdResult == 0 and stochResult == 0 and bollingerResult == 0
{
Print("Failed to calculate MACD, Stochastic or Bollinger Bands. Error code: ", GetLastError())
return
}
// Check if the MACD histogram is above the signal line and the Stochastic %K is above %D, which signals a bullish trend
if (currentMacd > currentMacdSignal && currentSlowK > currentSlowD)
{
// Buy entry
If there's no errors and it's not loading, look for a small red circle with a white exclamation mark near the top left of the chart near where the script would be situated. That is for errors related to the market rather than the script
Ok that makes sense where it came from. ChatGPT will only create what you ask for and it's not accurate because it has only recently started learning pinescript but will get better over time. The script doesn't make sense to me so I don't know what you are wanting it to do. Moreover, I don't have the time to build scripts for people. What I suggest for your next step is to define what it is you want the script to do. Set it out in steps. I'm happy to critique it for you if you post it here.
My purpose was to build a script for 15 min scalping especially for the pair EUR/USD, as I wrote in a previous post. Unfortunately I don't have the knowledge to make it better and I guess Gpt would not be able to improve it without the right advices.
Again I am happy to critique your strategy. Tell me in plain English what your entry reasons are including any filtering and what your exit reasons are. Also how do you want this to display on the chart and any alerts you would require.
Also have you considered doing the Pine Script Mastery Course? I can vouch for how it has made a HUGE difference in my scripting as well as in the success of my trading.