Indicator plots fill up with values when I change the indicator parameters

To add comments, please log in or register
johnwehland
70
johnwehland  

Hi I was wondering if someone could point me in the right direction with this indicator that I built.

It plots fine until I change one of the input parameters. From there the indicator plots get messed up. I've tried everything it seems, but nothing seems to help. Below is the initialize function and some screenshots of the behavior.


Thank you for any help you can offer


Before



void OnInit()
{
   Print("I");
   
   handle_Aroon = -1;
   handle_avgATR = -1;
   lastUpdate = -1;
   currentP = 0;
   currentSL = -1;
   currentTP= -1;
   openP = -1;
   entryTime = -1;
   longPrimed = true;
   shortPrimed = true;
   
   ObjectsDeleteAll(0);
   
   ArrayInitialize(ExtTenkanBuffer, 0);
   ArrayInitialize(ExtKijunBuffer, 0);
   ArrayInitialize(ExtSpanABuffer, 0);
   ArrayInitialize(ExtSpanBBuffer, 0);
   ArrayInitialize(ExtChikouBuffer, 0);
   ArrayInitialize(up_signal, 0);
   ArrayInitialize(down_signal, 0);
   ArrayInitialize(StopLoss, 0);
   ArrayInitialize(TakeProfit, 0);
   ArrayInitialize(atr, 0);
   ArrayInitialize(atr_average, 0);
   ArrayInitialize(aroonBears, 0);
   ArrayInitialize(aroonBulls, 0);
   
   ObjectsDeleteAll(0);
   
   handle_avgATR = iCustom(_Symbol, _Period, "ATRAvg", ATR_Period, ATR_Averaging_Period);
   ArraySetAsSeries(atr, true);
   ArraySetAsSeries(atr_average, true);
   
   handle_Aroon = iCustom(_Symbol, _Period, "aroon", Aroon_Period, 0);
   ArraySetAsSeries(aroonBears, true);
   ArraySetAsSeries(aroonBulls, true);
   
   ExtBegin=Kijun_Sen;
   if(ExtBegin<Tenkan_Sen)
      ExtBegin=Tenkan_Sen;
     
   //--- indicator buffers mapping
   SetIndexBuffer(1,ExtTenkanBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtKijunBuffer,INDICATOR_DATA);
   SetIndexBuffer(3,ExtSpanABuffer,INDICATOR_DATA);
   SetIndexBuffer(4,ExtSpanBBuffer,INDICATOR_DATA);
   SetIndexBuffer(5,ExtChikouBuffer,INDICATOR_DATA);
//---
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpTenkan);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpKijun);
   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,InpSenkou-1);
//--- lines shifts when drawing
   PlotIndexSetInteger(3,PLOT_SHIFT,InpKijun);
   PlotIndexSetInteger(4,PLOT_SHIFT,-InpKijun);
//--- change labels for DataWindow
   PlotIndexSetString(1,PLOT_LABEL,"Tenkan-sen("+string(InpTenkan)+")");
   PlotIndexSetString(2,PLOT_LABEL,"Kijun-sen("+string(InpKijun)+")");
   PlotIndexSetString(3,PLOT_LABEL,"Senkou Span A;Senkou Span B("+string(InpSenkou)+")");
   
   //================================================================================================================
   
   SetIndexBuffer(6,up_signal,INDICATOR_DATA);
   PlotIndexSetInteger(5, PLOT_ARROW, 233);                          //SetIndexStyle(7,DRAW_ARROW);   //SetIndexArrow(7, 233);
   PlotIndexSetInteger(5,PLOT_ARROW_SHIFT,30);
   //PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0);
   ArraySetAsSeries(up_signal, true);
   
   SetIndexBuffer(7,down_signal,INDICATOR_DATA);
   PlotIndexSetInteger(6, PLOT_ARROW, 234);                          //SetIndexStyle(8,DRAW_ARROW);   //SetIndexArrow(8, 234);
   PlotIndexSetInteger(6,PLOT_ARROW_SHIFT,-30);
   //PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,0);
   ArraySetAsSeries(down_signal, true);
   //================================================================================================================
   width = (int)   ChartGetInteger(0,CHART_SCALE);
   if(width == 4)
   {
      width = 6;
   }
   if(width == 5)
   {
      width = 13;
   }
     
   SetIndexBuffer(8,TakeProfit,INDICATOR_DATA);
   PlotIndexSetInteger(7, PLOT_ARROW, 159);                          //SetIndexStyle(7,DRAW_ARROW);   //SetIndexArrow(7, 233);
   PlotIndexSetInteger(7,PLOT_ARROW_SHIFT,0);
   //PlotIndexSetDouble(7,PLOT_EMPTY_VALUE,0);
   ArraySetAsSeries(TakeProfit, true);
       
   SetIndexBuffer(9,StopLoss,INDICATOR_DATA);
   PlotIndexSetInteger(8, PLOT_ARROW, 159);                          //SetIndexStyle(7,DRAW_ARROW);   //SetIndexArrow(7, 233);
   PlotIndexSetInteger(8,PLOT_ARROW_SHIFT,0);
   //PlotIndexSetDouble(8,PLOT_EMPTY_VALUE,0);
   ArraySetAsSeries(StopLoss, true);
}
Keith Watford
Moderator
24861
Keith Watford  
Please edit your post and
use the code button (Alt+S) when pasting code
To add comments, please log in or register