can someone give their indicators source code, cuz i am facing some problems and chatgpt can't solve it, i need an indicator that gives signal
so my indicator gives buy and buy stop signal, sometime it's giving wrong buy stop signals, also indicator shows old arrows on the loaded chart but stops giving new signals as new bars form (no real-time update)
or can you guys just help if you don't wanna give your indicators source code, at least i need good tutorial. thank you )
See alerts in code.
what do you mean, do you mean errors if it's error there is not a single error but it's not working how it supposed to do,
thank you for source code, it's more complicated than I thought.😶
here is the calculate section can you help me find the thing that causing problem :
//+------------------------------------------------------------------+ //| OnCalculate | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { if(rates_total < 10) return 0; static int lastBuyIndex = -1000; static bool buyStopFired = false; int start = prev_calculated > 1 ? prev_calculated - 1 : 2; double lips[], closeArr[], highArr[], lowArr[], rsiArr[], demaArr[]; ArraySetAsSeries(lips, true); ArraySetAsSeries(closeArr, true); ArraySetAsSeries(highArr, true); ArraySetAsSeries(lowArr, true); ArraySetAsSeries(rsiArr, true); ArraySetAsSeries(demaArr, true); if(CopyBuffer(hLips, 2, 0, rates_total, lips) <= 0 || CopyBuffer(hRSI, 0, 0, rates_total, rsiArr) <= 0 || CopyBuffer(hDEMA, 0, 0, rates_total, demaArr) <= 0 || CopyClose(_Symbol, _Period, 0, rates_total, closeArr) <= 0 || CopyHigh(_Symbol, _Period, 0, rates_total, highArr) <= 0 || CopyLow(_Symbol, _Period, 0, rates_total, lowArr) <= 0) return(prev_calculated); for(int i = start; i <= rates_total - 1; i++) { BuyBuffer[i] = EMPTY_VALUE; BuyStopBuffer[i] = EMPTY_VALUE; bool priceAboveDEMA = closeArr[i] > demaArr[i] && closeArr[i - 1] > demaArr[i - 1] && closeArr[i - 2] > demaArr[i - 2]; bool buyNow1 = closeArr[i] > lips[i]; bool buyNow2 = closeArr[i - 1] > lips[i - 1]; bool buyWasOk = closeArr[i + 1] <= lips[i + 1]; bool buyRsi = rsiArr[i] < RSI_BuyMax; if(buyNow1 && buyNow2 && buyWasOk && buyRsi && priceAboveDEMA) { BuyBuffer[i] = lowArr[i] - 500 * _Point; lastBuyIndex = i; buyStopFired = false; } // Show Buy Stop after Buy only once if(!buyStopFired && i > lastBuyIndex && closeArr[i] > demaArr[i] && closeArr[i - 1] < demaArr[i - 1]) { BuyStopBuffer[i] = highArr[i] + 500 * _Point; buyStopFired = true; } } return(rates_total); }
As far as I can tell from the code snippet that you posted, your arrow arrays are set to align with time series but your buffers are not. And then your indicator loop counts forward (i++).
For starters, I would set your buffers as series and rewrite your indicator loop to count backward so everything is aligned. In the indicator code that I posted, the backward loop is:
for(int i = rates_total - 1; i >= 0; i--)
Even if you don't want to count backward, you're referencing rates_total -1 in your loop and then returning straight rates_total. This doesn't work.
Also, if the logic of your signal/trigger conditions are well written, you shouldn't need empty values.As far as I can tell from the code snippet that you posted, your arrow arrays are set to align with time series but your buffers are not. And then your indicator loop counts forward (i++).
For starters, I would set your buffers as series and rewrite your indicator loop to count backward so everything is aligned. In the indicator code that I posted, the backward loop is:
Even if you don't want to count backward, you're referencing rates_total -1 in your loop and then returning straight rates_total. This doesn't work.
Also, if the logic of your signal/trigger conditions are well written, you shouldn't need empty values.As far as I can tell from the code snippet that you posted, your arrow arrays are set to align with time series but your buffers are not. And then your indicator loop counts forward (i++).
For starters, I would set your buffers as series and rewrite your indicator loop to count backward so everything is aligned. In the indicator code that I posted, the backward loop is:
Even if you don't want to count backward, you're referencing rates_total -1 in your loop and then returning straight rates_total. This doesn't work.
Also, if the logic of your signal/trigger conditions are well written, you shouldn't need empty values.From what you described, it looks like the issue might be related to the use of static variables inside the OnCalculate function.
These variables retain their values between calls, which could prevent new signals from being generated if they’re not properly reset. Consider whether they really need to be static, or if regular variables would work better.
Also, be careful with array access like closeArr[i + 1] or lips[i + 1]. If i + 1 goes beyond the array limits, it can cause unexpected behavior or even stop the indicator from working. Make sure your loop stays within safe bounds.
If the indicator stops updating in real time, check for silent errors that might interrupt execution. Using Print() statements can help you trace the logic and identify where things go wrong.
can someone give their indicators source code, cuz i am facing some problems and chatgpt can't solve it, i need an indicator that gives signal
Do you understand what a public codebase is ...

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
can someone give their indicators source code, cuz i am facing some problems and chatgpt can't solve it, i need an indicator that gives signal
so my indicator gives buy and buy stop signal, sometime it's giving wrong buy stop signals, also indicator shows old arrows on the loaded chart but stops giving new signals as new bars form (no real-time update)
or can you guys just help if you don't wanna give your indicators source code, at least i need good tutorial. thank you )