Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 31

 

Please advise, I have made an indicator based on the movement of several currency pairs, but it happens to recalculate. Nothing cosmic - it's referring to candlestick parameters. Perhaps, it screws up because

the candlesticks start to open only at the moment of the first tick for a certain candlestick and if a new candlestick for one instrument has already started, it hasn't formed for the second one. I think this is where the problem lies.

Do you know, maybe there is a way to make it calculate only when all the new candles have formed? Maybe iTime(symbol1,,1)==iTime(symbol2,,1)?

 

Good afternoon colleagues!

Please advise if the logic in the code is correct.

The gist of the code is the formula:

TRIN = (Growing pairs/Decreasing pairs)/ (Volume of growing pairs/Decreasing pairs)

double Index[];
double instr_up, instr_dn, vol_dn, vol_up;
//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0,Index);
   SetIndexStyle(0,DRAW_LINE);   
   string Tf;
   if(Period()==1) Tf="M1";
   if(Period()==5) Tf="M5";
   if(Period()==15) Tf="M15";
   if(Period()==30) Tf="M30";
   if(Period()==60) Tf="H1";
   if(Period()==240) Tf="H4";
   if(Period()==1440) Tf="D1";
   if(Period()==10080) Tf="W1";
   if(Period()==43200) Tf="MN";         
        string short_name="TRIN("+Depth+","+Tf+")";
        IndicatorShortName(short_name);
   IndicatorDigits(0);
   return(0);
}

//---- функция проверки цены закрытия на максимум Доллара США за период Depth
int newh(string symbol,int i)
      {
         datetime time_bar = Time[i];
         int bar_no = iBarShift(symbol, Period(), time_bar, false);
                
         if(symbol=="EURUSD" || symbol=="GBPUSD" || symbol=="AUDUSD" || symbol=="NZDUSD")
            {

               int j=iLowest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     int nh=1;                                                 
                  }
               else                                                                 
                  {
                     nh=0;                                              
                  }       
            }
         else
            {
               j=iHighest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     nh=1;                                                 
                  }
               else                                                                 
                  {
                     nh=0;                                              
                  }             
            }
         return(nh);      
      }

//---- функция проверки цены закрытия на минимум Доллара США за период Depth
int newl(string symbol,int i)
      {
         datetime time_bar = Time[i];
         int bar_no = iBarShift(symbol, Period(), time_bar, false);      
      
         if(symbol=="EURUSD" || symbol=="GBPUSD" || symbol=="AUDUSD" || symbol=="NZDUSD")
            {
               int j=iHighest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     int nl=1;                                                 
                  }
               else                                                                 
                  {
                     nl=0;                                              
                  }       
            }
         else
            {
               j=iLowest(symbol,Period(),MODE_CLOSE,Depth,bar_no);
               if (iClose(symbol,Period(),bar_no)==iClose(symbol,Period(),j))                    
                  {
                     nl=1;                                                 
                  }
               else                                                                 
                  {
                     nl=0;                                              
                  }             
            }
         return(nl);      
      }
//+------------------------------------------------------------------+
int start()
{
   int limit=Bars-IndicatorCounted();
   for(int i=1; i<limit; i++)
          {       
            if (newh("EURUSD",i) > 0                              //-- Если пара росла, то
             {instr_up=instr_up+1;vol_up+=iVolume("EURUSD",0,i);}   //-- instr_up - увеличиваем на 1 и vol_up - увеличиваем на Volume по этой паре   
           else //if (newl("EURUSD",i) > 0)                         //-- иначе
              {instr_dn=instr_dn+1;vol_dn+=iVolume("EURUSD",0,i);}  //-- instr_dn - увеличиваем на 1 и vol_dn - увеличиваем на Volume по этой паре
              
            if (newh("GBPUSD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("GBPUSD",0,i);}
           else //if (newl("GBPUSD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("GBPUSD",0,i);}
            
            if (newh("USDCHF",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("USDCHF",0,i);}
           else //if (newl("USDCHF",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("USDCHF",0,i);}
            
            if (newh("USDJPY",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("USDJPY",0,i);}
           else if (newl("USDJPY",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("USDJPY",0,i);}
            
            if (newh("AUDUSD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("AUDUSD",0,i);}
           else //if (newl("AUDUSD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("AUDUSD",0,i);}
            
            if (newh("USDCAD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("USDCAD",0,i);}
           else //if (newl("USDCAD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("USDCAD",0,i);}
            
            if (newh("NZDUSD",i) > 0)
             {instr_up=instr_up+1;vol_up+=iVolume("NZDUSD",0,i);}
           else //if (newl("NZDUSD",i) > 0)
              {instr_dn=instr_dn+1;vol_dn+=iVolume("NZDUSD",0,i);}   
     
     if (instr_dn == 0)instr_dn=EMPTY;  // -- Если 
     if (vol_dn == 0)vol_dn=EMPTY;      // -- значения
     if (instr_up == 0)instr_up=EMPTY;  // -- нулевые
     if (vol_up == 0)vol_up=EMPTY;
     
     Index[i]=(instr_up/instr_dn)/(vol_up/vol_dn);  // -- TRIN
     
     instr_up=0;instr_dn=0;vol_up=0;vol_dn=0;  // -- Обнуление
     }
     
        return(0);
}

This is what came out:

TRIN

Thank you!

 

Could you please advise

1 Expert Advisor can add funds to balance

2 if the trader has % of free funds - how can this be implemented in the tester or does it work as it is?

 

1. If for testing purposes, it's easier to set a good initial amount and build the MM based on the right amount.

2. For testing purposes it is absolutely unnecessary. The spread is more important.

 
splxgf:

1. If for testing purposes, it's easier to set a good initial amount and build the MM based on the right amount.

2. For testing purposes it is absolutely unnecessary. The spread is more important.


and 1 and 2 do you know how and what i test and why i need it? do you see my expert? are you going to tell me what i need better?

And for a snack, the spread is not important to me, but swap is critical ))))

 
sdm:


and 1 and 2 do you know how and what i test and why i need it? do you see my expert? are you going to tell me what i do best?

and one more thing for a bite, i don't care about the spread, but i do care about the swap )))) there are different types of experts


Or you are this way. Or you haven't learned how to ask questions?
 
sdm:


and 1 and 2 do you know how and what i test and why i need it? do you see my expert? are you going to tell me what i need better?

and for a snack, i don't care about the spread, but i do care about the swap ))))


Well, what is there to know, if interest is charged, I'd better refrain from commenting... As for swaps my orders last for a year and swaps don't bother me at all.

Do interest rates have time to change during this time or do you have it all scheduled with projections for the future?

 
Vinin:

Or it's this way. Or maybe you haven't learned how to ask questions.
These questions are rhetorical and not meant for everyone, but only as part of a comment and your link is inappropriate.
 
sdm:
These questions are rhetorical and not meant for everyone but as part of a comment and your link is inappropriate.

One more stunt and you're in the doghouse. For treating other members of the forum improperly by asking lengthy questions
 
splxgf:


Well, what is there to know, if interest is accruing, I'd rather refrain from commenting... As for swaps I have orders for a year, swaps don't bother me at all.

Do interest rates have time to change during this time or do you have it all timetabled with projections for the future?

I repeat all experts (systems) are different, i have swap eaten away all my profit after a year (on some deals) and i get good balance growth with low free money growth and it doesn't matter what it is, i don't make predictions, i try to use what i have.