Download MetaTrader 5
To add comments, please log in or register
Do you need a trading robot? Orderit via Freelance service!
ThemBonez
37
ThemBonez 2015.06.13 17:01 

I wrote a custom indicator that finds the swing highs and lows.

Currently it puts an arrow object point to the price level and the time bar.  Green for High and Red for Low.

I would like to change it to text that shows a count variable.

Here is a portion of the code I created but it isnt showing the text.

Can someone show me what is wrong.   Thanx.

if (Low[i] < Low[i+1]
            && Low[i] < Low [i+2]
            && Low[i] < Low [i+3]
               && Low[i] < Low [i-1]
                  && Low[i] < Low[i-2]
                  && Low[i] < Low[i-3])
                 {
                  SwingLoBar[i] = 1;
                  SwingLo[i] = Low[i];
                  SwingCount = SwingCount + 1;
                  
                  ObjectCreate("Text",OBJ_TEXT,0,0,0);
                  ObjectSet("Text",OBJPROP_TIME,i);
                  ObjectSet("Text",OBJPROP_PRICE,SwingLo[i]-20*pips);
                  ObjectSetString(0,"Text",OBJPROP_TEXT,SwingCount);
                  ObjectSet("Text",OBJPROP_COLOR,clrRed);
Paul B
173
Paul B 2015.06.13 18:37  

You are not using some of the commands correctly. For instance, i is not a time. You should have:

ObjectSet("Text",OBJPROP_TIME,Time[i]);

 

 Also, it's good practice to convert integers to text:

ObjectSetString(0,"Text",OBJPROP_TEXT,IntegerToString(SwingCount));
/
To add comments, please log in or register