Help Converting This To MultiCurrency

Back to topics list To post a new topic, please log in or register
avatar
40
noobshow 2015.07.31 13:22
 

Hi All,

I am trying to Convert a Strength Indicator to Buffer out/Draw Out Result Of Multiple Pairs not just the main Symbol()...But, am having problem doing that....

I saw So many peoples using this and i think if we could convert it to Cluster Type it would be Cooler...

#property indicator_chart_window


//——————————————————————————————————————————————————————|


enum corner
                                                        {
                               CORNER_NONE                                 = -1,                     // Don't show info
                               CORNER_LEFT_UP                      =  0,                     // Left upper corner
                               CORNER_RIGHT_UP                =  1,                  // Right upper corner
                               CORNER_LEFT_DN                      =  2,                     // Left lower corner
                               CORNER_RIGHT_DN                =  3                   // Right lower corner
                                                        };


input  string ——————————————————————————————————————    = "« Indicator parameters »";
input  corner              InfoCorner                                   =  CORNER_RIGHT_UP; // Info position

extern string ———————————————————————————————————————   = "« Settings for color panel »";
extern color              ColorBull                     =  clrLimeGreen;
extern color              ColorBull_3D                  =  clrDarkGreen;
extern color              ColorBear                     =  clrRed;
extern color              ColorBear_3D                  =  clrMaroon;

extern string ————————————————————————————————————————  = "« Setup force Percentage »";
extern int                Bulls_Strength_Percent        =  40;
extern int                Bears_Strength_Percent        =  50;

extern string ————————————————————————————————————————— = "« Settings for audio signals »";
extern bool                   ShowAlert                     =  true;            // Use signals "Alert" ?
extern bool               SendPush                      =  false;           // PUSH send messages to your phone ?
extern bool               SendMailInfo                  =  false;           // Send notifications by e-mail ?
extern bool               ShowSound                     =  false;           // Use beeps "Sound" ?
extern string             SoundNameBuy                  =  "buy.wav";       // Title signal "BUY"
extern string             SoundNameSell                 =  "sell.wav";      // Title signal "SELL"


//——————————————————————————————————————————————————————|
string DefaultPairs[] = {"AUDCAD","AUDCHF","AUDJPY","AUDNZD","AUDUSD","CADCHF","CADJPY","CHFJPY","EURAUD","EURCAD","EURCHF","EURGBP","EURJPY","EURNZD","EURUSD","GBPAUD","GBPCAD","GBPCHF","GBPJPY","GBPNZD","GBPUSD","NZDCAD","NZDCHF","NZDJPY","NZDUSD","USDCAD","USDCHF","USDJPY"};


string IndicatorName = "© Recent Strength";


bool USEM1  = true;
bool USEM5  = true;
bool USEM15 = true;
bool USEM30 = true;
bool USEH1  = true;
bool USEH4  = true;
bool USED1  = true;
bool USEW1  = false;
bool USEMN  = false;

int MULTM1  = 1;
int MULTM5  = 1;
int MULTM15 = 1;
int MULTM30 = 1;
int MULTH1  = 1;
int MULTH4  = 1;
int MULTD1  = 1;
int MULTW1  = 1;
int MULTMN  = 1;


string meter_head;


int    num_tf = 0;


double bull[];  
double bear[];


bool   bullArt = false;
bool   bearArt = false;

        
//——————————————————————————————————————————————————————————————————————————————————————————————|

string Period2Text( int TmPeriod )
{

   switch( TmPeriod )
   {
      case PERIOD_M1  : return( "M1"  );
      case PERIOD_M5  : return( "M5"  );
      case PERIOD_M15 : return( "M15" );
      case PERIOD_M30 : return( "M30" );
      case PERIOD_H1  : return( "H1"  );
      case PERIOD_H4  : return( "H4"  );
      case PERIOD_D1  : return( "D1"  );
      case PERIOD_W1  : return( "W1"  );
      case PERIOD_MN1 : return( "MN1" );
   }      

   return( "ERR" );
}

//——————————————————————————————————————————————————————————————————————————————————————————————|

int init()
{

   if( USEM1  )  { num_tf = num_tf + MULTM1;   meter_head =               "M1";  }
   if( USEM5  )  { num_tf = num_tf + MULTM5;   meter_head = meter_head + " M5";  }
   if( USEM15 )  { num_tf = num_tf + MULTM15;  meter_head = meter_head + " M15"; }
   if( USEM30 )  { num_tf = num_tf + MULTM30;  meter_head = meter_head + " M30"; }
   if( USEH1  )  { num_tf = num_tf + MULTH1;   meter_head = meter_head + " H1";  }
   if( USEH4  )  { num_tf = num_tf + MULTH4;   meter_head = meter_head + " H4";  }
   if( USED1  )  { num_tf = num_tf + MULTD1;   meter_head = meter_head + " D1";  }
   if( USEW1  )  { num_tf = num_tf + MULTW1;   meter_head = meter_head + " W1";  }
   if( USEMN  )  { num_tf = num_tf + MULTMN;   meter_head = meter_head + " MN";  }


   EventSetMillisecondTimer( 100 );

   
   return(0);
}

//—————————————————————|

int deinit()
{

   obj_delete( "FLN_" );

   Comment( "" );

   return(0);
}

//————————|


int start()
{

//————————————————————————————————————————————————————————|
       for(int i=0;i<ArraySize(DefaultPairs);i++) 
           {
          ArrayResize(bull,i);
          ArrayResize(bear,i); 
    if( SendMailInfo || ShowAlert || ShowSound || SendPush )
   {

      if( Bulls_Strength_Percent <= NormalizeDouble( bull[i] * 10, 0 ) && bullArt )
      {
         
         bullArt = false;

         if( SendPush     ) SendNotification( StringConcatenate( IndicatorName, "  /  ", _Symbol, "  « ", periods(), " »  ( Bulls Strength = ", Bulls_Strength_Percent, " % )" ));

         if( SendMailInfo ) SendMail( StringConcatenate( IndicatorName, "  /  ", AccountCompany(), " ", AccountNumber(), " ", _Symbol ),
                            StringConcatenate( "  « ", periods(), " »  ( Bulls Strength = ", Bulls_Strength_Percent, " % )", " ", TimeToStr( TimeCurrent(), TIME_DATE | TIME_MINUTES )));

         if( ShowAlert    ) Alert( IndicatorName, "  /  ", _Symbol, "  « ", periods(), " »  ( Bulls Strength = ", Bulls_Strength_Percent, " % )" );

         if( ShowSound    ) PlaySound ( SoundNameSell );
      }

      if(! bullArt && Bulls_Strength_Percent > NormalizeDouble( bull[i] * 10, 0 ) )  bullArt = true;


//——————————————————————————————————————————————————————————————————————————————————————————————|


      if( Bears_Strength_Percent <= NormalizeDouble( bear[i] * 10, 0 ) && bearArt )
      {

         bearArt = false;

         if( SendPush     ) SendNotification( StringConcatenate( IndicatorName, "  /  ", _Symbol, "  « ", periods(), " »  ( Bears Strength = ", Bears_Strength_Percent, " % )" ));

         if( SendMailInfo ) SendMail( StringConcatenate( IndicatorName, "  /  ", AccountCompany(), " ", AccountNumber(), " ", _Symbol ),
                            StringConcatenate( "  « ", periods(), " »  ( Bears Strength = ", Bears_Strength_Percent, " % )", " ", TimeToStr( TimeCurrent(), TIME_DATE | TIME_MINUTES )));

         if( ShowAlert    ) Alert( IndicatorName, "  /  ", _Symbol, "  « ", periods(), " »  ( Bears Strength = ", Bears_Strength_Percent, " % )" );

         if( ShowSound    ) PlaySound ( SoundNameBuy );
      }

      if(! bearArt && Bears_Strength_Percent > NormalizeDouble( bear[i] * 10, 0 ) )  bearArt = true;

   }

   return(0);
}

//—————————————————————————————————————————————————————————————|


void OnTimer()
{

   int adW, adH;


   long colir = ChartGetInteger( 0, CHART_COLOR_BACKGROUND, 0 );
   int  width = ChartGetInteger( 0, CHART_WIDTH_IN_PIXELS,  0 );
   int  heigh = ChartGetInteger( 0, CHART_HEIGHT_IN_PIXELS, 0 );



           if( InfoCorner == 0 || InfoCorner == 2 )
           {
              adW = 0;  adH = 0;
      }

           if( InfoCorner == 1 )  adH = - 12;

           if( InfoCorner == 1 || InfoCorner == 3 )  adW = width - 233;
           if( InfoCorner == 2 || InfoCorner == 3 )  adH = heigh -  77;


//———————————————————————————————————————————————————————————————|


   bull[DefaultPairs] = 0 ;  
   bear[DefaultPairs] = 0 ;


   if( USEM1  )  { DoWork( PERIOD_M1,  MULTM1   ); }

   if( USEM5  )  { DoWork( PERIOD_M5,  MULTM5   ); }

   if( USEM15 )  { DoWork( PERIOD_M15, MULTM15  ); }

   if( USEM30 )  { DoWork( PERIOD_M30, MULTM30  ); }

   if( USEH1  )  { DoWork( PERIOD_H1,  MULTH1   ); }

   if( USEH4  )  { DoWork( PERIOD_H4,  MULTH4   ); }

   if( USED1  )  { DoWork( PERIOD_D1,  MULTD1   ); }

   if( USEW1  )  { DoWork( PERIOD_W1,  MULTW1   ); }

   if( USEMN  )  { DoWork( PERIOD_MN1, MULTMN   ); }


     for(int i=0;i<ArraySize(DefaultPairs);i++)
      {
    bull[DefaultPairs] = bull[i] / num_tf ;  
   bear[DefaultPairs] = bear[i] / num_tf ; 



   TxtFln( " Bl3d ", NormalizeDouble( bull[i] * 10, 0 ) + " %", 181 + adW, 22 + adH, 11, "Arial", ColorBull_3D, false, 0 );

   TxtFln( " Bull ", NormalizeDouble( bull[i] * 10, 0 ) + " %", 182 + adW, 23 + adH, 11, "Arial", ColorBull, false, 0 );
   TxtFln( " Bill ", NormalizeDouble( bull[i] * 10, 0 ) + " %", 183 + adW, 23 + adH, 11, "Arial", ColorBull, false, 0 );


   TxtFln( " Br3d ", NormalizeDouble( bear[i] * 10, 0 ) + " %", 11 + adW, 22 + adH, 11, "Arial", ColorBear_3D, false, 0 );

   TxtFln( " Bear ", NormalizeDouble( bear[i] * 10, 0 ) + " %", 12 + adW, 23 + adH, 11, "Arial", ColorBear, false, 0 );
   TxtFln( " Biar ", NormalizeDouble( bear[i] * 10, 0 ) + " %", 13 + adW, 23 + adH, 11, "Arial", ColorBear, false, 0 );


//———————————————|


   int lining = 0;
   int detect = 0;


//—————————————————————————————————|


   for( int j = 0;  j < 100;  j ++ )
   {


      color clr_lining = ColorBull_3D;

      if( j >= 0 && j < ( NormalizeDouble( bear[DefaultPairs] * 10, 0 ) - 0 ))  clr_lining = ColorBear_3D;

      TxtFln( " detector " + j, "_", ( -14 + lining ) + adW, 53 + adH, 19, "Arial", clr_lining, true, 90 );

                                                                                                     lining += 2;
      if( j >=  NormalizeDouble( bear[DefaultPairs] * 10, 0 ) - 1 &&  j <=  NormalizeDouble( bear[DefaultPairs] * 10, 0 ) - 1 )  lining += 2;


//———|


      color clr_detector = ColorBull;

      if( j >= 0 && j < ( NormalizeDouble( bear[DefaultPairs] * 10, 0 ) - 0 ))  clr_detector = ColorBear;

      TxtFln( " lining " + j, "_", ( -12 + detect ) + adW, 55 + adH, 19, "Arial", clr_detector, false, 90 );

                                                                                                     detect += 2;
      if( j >=  NormalizeDouble( bear[DefaultPairs] * 10, 0 ) - 1 &&  j <=  NormalizeDouble( bear[DefaultPairs] * 10, 0 ) - 1 )  detect += 2;

   }
}
  

//———————————————————————————————————————————————————————————————————|

void DoWork( int iPeriod , int xMult )
{ 
   double XX01, XX02, high = 0, low = 0, open = 0, close = 0, mid = 0;
   double high1 = 0, low1 = 0, open1 = 0, close1 = 0, mid1 = 0;

        
   int limit = 5;
   int i;


   XX01 = 0;
   XX02 = 0; 

   for( i = 0;  i < ArraySize(DefaultPairs);  i ++ )
   {
      open  = iOpen ( i, iPeriod, 5 ); //I've Changed These NULL s to Arrays of all Symbols, But, to Output 
      high  = iHigh ( i, iPeriod, 5 ); //it in the Bulls Down there, but it ain't working yet..   
      low   = iLow  ( i, iPeriod, 5 );
      close = iClose( i, iPeriod, 5 );

      open1  = iOpen ( i, iPeriod, 5+1 );
      high1  = iHigh ( i, iPeriod, 5+1 );
      low1   = iLow  ( i, iPeriod, 5+1 );
      close1 = iClose( i, iPeriod, 5+1 );

      mid   = ( high + low ) * 0.5;
      mid1  = ( high1 + low1 ) * 0.5;

      if( close > mid1 )
      {
         XX01 = XX01 + 1;
      }
      else
      {
         if( close < mid1 )
         {
            XX02 = XX02 + 1;
         }
      }


      if( close > close1 )
      {
         XX01 = XX01 + 1;
      }
      else
      {
         if( close < close1 )
         {
            XX02 = XX02 + 1;
         }
      }
   }

   bull[i] = bull[DefaultPairs] + XX01 * xMult; // This is the bull outputting the values...
   bear{DefaultPairs] = bear[i] + XX02 * xMult; // And, the bear outputting its own type of value also
}


//———————————————————————————————————|

string periods()
{

   switch ( _Period )
   {
      case 0x000001 : return( "M1"  );
      case 0x000005 : return( "M5"  );
      case 0x00000F : return( "M15" );
      case 0x00001E : return( "M30" );
      case 0x00003C : return( "H1"  );
      case 0x0000F0 : return( "H4"  );
      case 0x0005A0 : return( "D1"  );
      case 0x002760 : return( "W1"  );
      case 0x00A8C0 : return( "MN"  );

   default : return (     "default" );

   }
}

//————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————|

void TxtFln( string main, string text, int pos_x, int pos_y, int fontsize, string fontname, color namecolor, bool backs, double angle )
{
   string name = StringConcatenate( "FLN_", main );

   if( ObjectFind( name ) != 1 )  ObjectCreate( name, OBJ_LABEL, 0, 0, 0 );

   ObjectSet     ( name, OBJPROP_BACK,                 backs );
   ObjectSet     ( name, OBJPROP_ANGLE,                angle );
   ObjectSet     ( name, OBJPROP_CORNER,                   0 );
   ObjectSet     ( name, OBJPROP_XDISTANCE,            pos_x );
   ObjectSet     ( name, OBJPROP_YDISTANCE,            pos_y );
   ObjectSetText ( name, text, fontsize, fontname, namecolor );
}

//————————————————————————————————————————————————————————————|

void obj_delete( string prefix )
{
   int obj_total = ObjectsTotal();  string name;

   for( int i = obj_total - 1; i >= 0; i -- )
   {
      name = ObjectName(i);

      if( StringFind( name, prefix ) == 0 ) ObjectDelete( name );
   }
}

//———————————————————— end of the algorithm ————————————————————|


I've tried making the High, Low, Close Become array of all the currencies, but i don't know how to output the value for each separately...

It's just bringing 13% for all and not refreshing..


Thanks So Much if you can help me rewrite this...

avatar
13000
WHRoeder 2015.07.31 13:40 #
 
noobshow:

But, am having problem doing that....

      open  = iOpen ( NULL, iPeriod, i ); //I've Changed These NULL s to Arrays of all Symbols, But, to Output 
      high  = iHigh ( NULL, iPeriod, i ); //it in the Bulls Down there, but it ain't working yet..   

I've tried making the High, Low, Close Become array of all the currencies, but i don't know how to output the value for each separately...

  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. You comment you changed them but you didn't post them. There are no mind readers here.
  3. You can't change the predefined arrays High, Low, Close. but you already know how to use iHigh...
  4. separate value means separate buffers or in this case all your TxtFln calls will have to be modified with symbol and symbol index.
  5. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
avatar
40
noobshow 2015.08.01 01:13 #
 
WHRoeder:
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. You comment you changed them but you didn't post them. There are no mind readers here.
  3. You can't change the predefined arrays High, Low, Close. but you already know how to use iHigh...
  4. separate value means separate buffers or in this case all your TxtFln calls will have to be modified with symbol and symbol index.
  5. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.

I didn't know i'll ever come across this template of yours...

I Updated the Code Up there..


avatar
40
noobshow 2015.08.02 01:30 #
 

Please Help Me!..


Thanks.

avatar
Moderator
3418
GumRai 2015.08.02 02:37 #
 
noobshow:

Please Help Me!..


Thanks.

The problem is that in order to help you,

we have to know exactly what you need help with.

If you tell us that you are trying to do something specific with a specified block of code, show your coding attempt and inform us the expected result and the actual result 

somebody may be able to help you.

Just showing the whole code and telling us that you want to make it multi symbol is not specific enough. 

 

avatar
40
noobshow 2015.08.02 14:26 #
 
GumRai:

The problem is that in order to help you,

we have to know exactly what you need help with.

If you tell us that you are trying to do something specific with a specified block of code, show your coding attempt and inform us the expected result and the actual result 

somebody may be able to help you.

Just showing the whole code and telling us that you want to make it multi symbol is not specific enough. 

 

The Indicator Shows Strength for the Current Symbol, and i want Some list of Pair(Not Just One).

string DefaultPairs[];

I changed the Maths of Close/High/Open/Low from NULL to the Array of DefaultPairs, which i expect the OutPut In the TxtFln to Play along with that rule, but instead it Output the Total of all the Pairs(e.g, a Pair should be 100%, 40% might be Green(Buy) and 60% might be Red(Sell). But, the Drawing Increased the result to something around 400% for sell and 600% for buy on a Pair)...I'm just stuck at Getting The Value Of All the OHLC(Open/High/Low/Close) into a list of array and Drawing it using TxtFln() to Create The Objects Per Currency Pairs. I don't know much about drawing indicator.

I think this should be clear,

And, a Suggestion came to my mind(Which i hope might work), i think of Splitting the Dowork into Many Functions like Dowork1,Dowork2....The Dowork1 will be calculating for GBPUSD, Dowork2 for EURUSD and so on....But, wen it comes to Drawing....I'm sure i'll be stuck also at Splitting them..

Somebody, Please Help...


Thanks In Advance

avatar
40
noobshow 2015.08.03 19:16 #
 

Anyone to help?


avatar
40
noobshow 2015.08.04 22:17 #
 

Is everyone as noob as am i?

I think this forum is meant for some kinda language help....

 Hell No!.

avatar
Moderator
3418
GumRai 2015.08.05 00:53 #
 
noobshow:


I changed the Maths of Close/High/Open/Low from NULL to the Array of DefaultPairs, which i expect the OutPut In the TxtFln to Play along with that rule, but instead it Output the Total of all the Pairs(e.g, a Pair should be 100%, 40% might be Green(Buy) and 60% might be Red(Sell). But, the Drawing Increased the result to something around 400% for sell and 600% for buy on a Pair)...I'm just stuck at Getting The Value Of All the OHLC(Open/High/Low/Close) into a list of array and Drawing it using TxtFln() to Create The Objects Per Currency Pairs. I don't know much about drawing indicator.

I think this should be clear,


You think that is clear??
avatar
40
noobshow 2015.08.05 14:58 #
 
GumRai:
You think that is clear??

Thanks,

I don't even need anyone help here no more...

Bunch of kids live here who they think they are the best(They're always good at sending templates like "Doesn't work is meaningless")..

fucking noob forum.

Pains me i don't know much about MQL5 Indics the way i know C/C++...

Thanks,

GumRai...

Talk to y'all in the near future and the fucking "Doesn't work Kid"(Fool).

Mmstcheew!.

Back to topics list  

To add comments, please log in or register