Attachments forums

List of attachments posted on this forum.


All files on forums: 136582

Re: No Nonsense Forex - Indicators

memirxan, Wed Dec 07, 2022 4:55 am

Centaur wrote: Tue Dec 06, 2022 7:53 am Yes it will give all signals in history, to limit this to new signals only you can do the following:

Code: Select all

//--- calculate start position
   int bar;
   if(prev_calculated == 0)
     {
      bar = 0;
      int bar_cnt = Bars(_Symbol, _Period);
     }
   else
      bar = prev_calculated - 1;
//--- main loop
   for(int i = bar; i < rates_total && !_StopFlag; i++)
     {
      if(i > length)
        {
         //--- calculate alpha trend
         ATR[i] = fSMA(i, length, TR);
         UpTrend[i] = low[i] - ATR[i] * atr_multiplier;
         DownTrend[i] = high[i] + ATR[i] * atr_multiplier;
         Alpha_Calc[i] = (inp_change_calc == No ? RSI[i] >= 50 : MFI[i] >= 50) ? UpTrend[i] < Alpha_Calc[i - 1] ? Alpha_Calc[i - 1] : UpTrend[i] : DownTrend[i] > Alpha_Calc[i - 1] ? Alpha_Calc[i - 1] : DownTrend[i];
         //--- plot alpha trend
         Alpha[i] = NormalizeDouble(Alpha_Calc[i], _Digits);
         Offset[i] = NormalizeDouble(Alpha_Calc[i - 2], _Digits);
         //--- plot buy and sell signals
         Buy_Signal_Calc[i] = Alpha[i] > Offset[i] && Alpha[i - 1] <= Offset[i - 1] ? 1.0 : 0.0;
         Sell_Signal_Calc[i] = Alpha[i] < Offset[i] && Alpha[i - 1] >= Offset[i - 1] ? 1.0 : 0.0;
         Buy_BarCount[i] = fBarsSince(i, Buy_Signal_Calc);
         Sell_BarCount[i] = fBarsSince(i, Sell_Signal_Calc);
         Arrows[i] = Buy_BarCount[i] > Sell_BarCount[i] ? 1.0 : -1.0;
         Buy_Signal[i] = inp_signals == No ? EMPTY_VALUE : Arrows[i] == -1.0 && Arrows[i - 1] == 1.0 ? Offset[i] : EMPTY_VALUE;
         Sell_Signal[i] = inp_signals == No ? EMPTY_VALUE : Arrows[i] == 1.0 && Arrows[i - 1] == -1.0 ? Offset[i] : EMPTY_VALUE;
         if(Buy_Signal[i] != EMPTY_VALUE && i > bar_cnt)
           {
            SendNotification("Buy Signal was Triggered!");
            Alert("Buy Signal was Triggered!");
           }
         if(Sell_Signal[i] != EMPTY_VALUE && i > bar_cnt)
           {
            SendNotification("Sell Signal was Triggered!");
            Alert("Sell Signal was Triggered!");
           }
        }
     }
hello again mate, I tried the code you gave, but it gives bar_cnt error. I'm sorry I made you tired :(
All files in topic