iCustom() Question - page 2

 
GumRai:

That looks good to me. You are definitely on the right track.

If using in the strategy tester, you will have to attach the indicator to the tester chart (ie attach the indicator to a chart and save template as tester.tpl

For your EA to detect objects in Strategy Tester, it must be run in visual mode .

To reduce the amount of Prints you may only want to print when the "trend" changes 

 

 or if watching in visual mode, consider using Comment() instead of Print() 

There is nothing appear on the Chart GumRai  :(
 
xlearner:
There is nothing appear on the Chart GumRai  :(

I wrote a simple indicator to create an object and change the colour every hour

I then adapted your code in an EA

void OnTick()
  {
   static int Trend=1245;
   string clr;
   clr=ColorToString(ObjectGet("D1B",OBJPROP_COLOR),True); // "D1B" is the name of the object 

   if(clr=="clrLimeGreen" && Trend!=0)
     {
      Trend=0; // Up 

      Print("The color is ",clr," and the Trend = UP");

     }
   if(clr=="clrRed" && Trend!=1)
     {

      Trend=1; // Down

      Print("The color is ",clr," and the Trend = DOWN");
     }

 Ran it in visual mode (with the indicator template saved as tester.tpl)

and it worked as expected with the prints in the journal

0 03:19:32 2015.01.05 00:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:32 2015.01.05 00:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:32 2015.01.05 01:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:32 2015.01.05 02:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:32 2015.01.05 03:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 04:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 05:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 06:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 07:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 08:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 09:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 10:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 11:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 12:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 13:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 14:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 15:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 16:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 17:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 18:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 19:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 20:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 21:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.05 22:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.05 23:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.06 00:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.06 01:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.06 02:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP

0 03:19:33 2015.01.06 03:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.06 04:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP 

 

 What are you seeing in the journal?

 
GumRai:

I wrote a simple indicator to create an object and change the colour every hour

I then adapted your code in an EA

 Ran it in visual mode (with the indicator template saved as tester.tpl)

0 03:19:33 2015.01.06 03:00  Check Object Colour EURUSDSB,H1: The color is clrRed and the Trend = DOWN

0 03:19:33 2015.01.06 04:00  Check Object Colour EURUSDSB,H1: The color is clrLimeGreen and the Trend = UP 

 

 What are you seeing in the journal?

:) , I forgot to change the Template , Ok it works fine now .
Another Question : How can I see the color of two Time frames ? For example the H1 And The Daily .
I tried to To use The Object Names of the timeframes I want , But , Only the M5 and the current timeframe change their color (Look at the picture) .



 
xlearner:

:) , I forgot to change the Template , Ok it works fine now .
Another Question : How can I see the color of two Time frames ? For example the H1 And The Daily .
I tried to To use The Object Names of the timeframes I want , But , Only the M5 and the current timeframe change their color (Look at the picture) .



That is dependent on the indicator. If the objects do not change colour, then a colour change cannot be detected.

Maybe the inputs for the indicator allow you to change the applied time-frames? 

 
GumRai:

That is dependent on the indicator. If the objects do not change colour, then a colour change cannot be detected.

Maybe the inputs for the indicator allow you to change the applied time-frames? 

In Main chart window the indicator objects change their colors , like in the image 



 

What do you think the problem is GumRai ??

This is the indicator :  

Files:
 

Some indicators do not always work as expected in the strategy tester. Seems to be the case with this indicator.

Getting the objects' colour should work ok on realtime charts though 

 
GumRai:

Some indicators do not always work as expected in the strategy tester. Seems to be the case with this indicator.

Getting the objects' colour should work ok on realtime charts though 

Thank you GumRrai , Could you say to me why The Ea run only The Sell Orders , see the code ?

string TimeframeToString(int P)
{
   switch(P)
   {
      case PERIOD_M5:  return("M5B");
      case PERIOD_M15: return("M15B");
      case PERIOD_M30: return("M30B");
      case PERIOD_H1:  return("H1B");
      case PERIOD_H4:  return("H4B");
      case PERIOD_D1:  return("D1B");
   }
   return("");
}     
      string per= TimeframeToString(Period());
      static int Trend=1245;
      string clr;
      clr=ColorToString( ObjectGet( per, OBJPROP_COLOR ),True); // per is the name of the object 
      
      if (clr=="clrLimeGreen"  && Trend!=0)
      {
            Trend=0; // Up 
            
            Comment("The color is ", clr ," and the Trend = ",Trend);
            Print("The color is ", clr ," and the Trend = ",Trend);

      }
      
      if(clr=="clrRed" && Trend!=1)
      {

         Trend=1; // Down
         Comment("The color is ", clr  ," and the Trend = ",Trend);
         Print("The color is ", clr ," and the Trend = ",Trend);
      }

      // Bullish Pinbar With our conditions
            if (PinBarType() == 0) // is it a bullish pin bar ?
            {
               if( Trend == 0) // Up
               {
                  if (MathMin( Open[1], Close[1] )>SMA50) // Is the body above the Ma ?
                  {
                        return(0); // Ok , Its a good BU PB . Let's go Buy .
                  }
            }
            }
      
      // Bearish Pinbar With our conditions

            if (PinBarType() == 1) // Is it a bearish Pin Bar ?
            {
            if(Trend == 1)
            {
                  if (MathMax( Open[1], Close[1] )<SMA50) // Is the body below the MA ?
                  {
                        return(1); // Ok , Its a good BE PB . Let's go Sell .
                  }
            }
            }
 
xlearner:
Thank you GumRrai , Could you say to way The Ea run only The Sell Orders , see the code ?


Possibly because the Daily colour does not change to LimeGreen at any time during the test

Do you have any print statements that the colour is lime green and Trend=0 in the journal? 

 
GumRai:

Possibly because the Daily colour does not change to LimeGreen at any time during the test

Do you have any print statements that the colour is lime green and Trend=0 in the journal? 

I works now 

2015.01.10 11:14:29.078 2011.02.03 08:00  PBD_EA_v0.4_objects EURUSD,H4: open #35 buy 0.50 EURUSD at 1.38040 sl: 1.37740 tp: 1.38787 ok
2015.01.10 11:14:27.968 2011.01.27 08:00  PBD_EA_v0.4_objects EURUSD,H4: The color is clrLimeGreen and the Trend = 0

Thanks Alot GumRai , But still the Problem of multi time frames , I will find a solution for it , or I will Try with Another indicator work with the buffers using iCustom() 


Reason: