Calling an indicator value that isn't an index value

 

Hello all,

I've been searching throughout the internet on a way to call an indicator's value that has registered after an elapsed time and my search has been confusing and fruitless. The reason is because when calling an indicator in your EA, it gives you index values but in actual usage, this values are very different after an elapsed time.

I am guessing that i should copy data into an array when the time has reached. How do i do this?

 

Can you show an example of your code and explain what you are trying to achieve and what is actually happening.

 
ratata:

Hello all,

I've been searching throughout the internet on a way to call an indicator's value that has registered after an elapsed time and my search has been confusing and fruitless. The reason is because when calling an indicator in your EA, it gives you index values but in actual usage, this values are very different after an elapsed time.

I am guessing that i should copy data into an array when the time has reached. How do i do this?

May be you have an "repainting" indicator? Do you know the name or can you post the code?
 
  1. Your post is almost unintelligible. If you are using mechanical translation, you must use simple language structure.
  2. ratata: it gives you index values but in actual usage, this values are very different after an elapsed time.
    If the indicator's values change over time (except for the current bar) then it is a repainting indictor and is useless.
  3. ratata: I am guessing that i should copy data into an array when the time has reached. How do i do this?
    double values[10];
    for(int i=0; i<10; ++i) values[i] = iCustom(..., i);
    Is that so hard? 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.
 

Hello once again,

Sorry i'm just seeing your replies. Anyway, this is what i coded;

void OnTick()
  {
   if(TradeClosureMode > 0)
    {
    StopLoss = 0;
    TakeProfit = 0;
    }
    DisableTrading = 0;
    ShiftVal = 0;
  for(i=0;i<OrdersTotal();i++)
     {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
     if(OrderType()==OP_BUYLIMIT) DisableTrading = 1;
     }
    
  for(i=0;i<OrdersTotal();i++)
  {
  if (OrderSelect (i,SELECT_BY_POS,MODE_TRADES) == True && OrderMagicNumber() == MagicNumber)
  {
  DisableTrading = 1;
  break;
  }    
    }
      
    if (DisableTrading == 0 && CalculateOnBarClose == False)
    {
    CheckForOpen();// Does what it says
    CheckForModify();
    }
    else
    {
    if (DisableTrading == 0 && CalculateOnBarClose == False)
    {
    ShiftVal = 1;
    CheckForOpen();
    CheckForModify();
       }
    }
    if (DisableTrading == 1 && CalculateOnBarClose == False)
    {
    ToCloseOrder();
    CheckForClose();
    }

     if (DisableTrading == 1 && CalculateOnBarClose == True)
    {
    ShiftVal = 1;
    }
    else
    {
    ToCloseOrder();
    CheckForClose();
         }
    }
//Remainder of code
void Stoc()//For stoc calculations
{
  CurrentSlowD =  iStochastic(Symbol(),0,KPeriod,DPeriod,Slowing,0,1,MODE_SIGNAL,ShiftVal);
  PreviousSlowD = iStochastic(Symbol(),0,KPeriod,DPeriod,Slowing,0,1,MODE_SIGNAL,ShiftVal+1);
  CurrentSlowK = iStochastic(Symbol(),0,KPeriod,DPeriod,Slowing,0,1,MODE_MAIN,ShiftVal);
  PreviousSlowK = iStochastic(Symbol(),0,KPeriod,DPeriod,Slowing,0,1,MODE_MAIN,ShiftVal+1);

if (CurrentSlowD <= 20 && CurrentSlowK <= 20 && CurrentSlowD <= CurrentSlowK && PreviousSlowD > PreviousSlowK) 
     {
     StocBuy = True;
     }
if (CurrentSlowD >= 80 && CurrentSlowK >= 80 && CurrentSlowD >= CurrentSlowK && PreviousSlowD < PreviousSlowK)
     {
     StocSell = True;
     }
  }

Initially, i added the code below to handle the time feature, but after backtesting, it gave the same response as the code on top (minus the ShiftVal).

CalcTime = (Period()*60)-(TimeCurrent()-Time[0]);

if (CalcTime <= SecondsToClose)

I went back to reading and found that when calling an indicator, it always gives the index value regardless of when you run it...so a time delay never works.

When i asked this question, i was hoping that someone would have dealt extensively with arrays and would know if it actually works to get the most recent value of the current bar (0), as calculated by the indicator and not the index value that is always used by the EA.

As for this talk about a repainting indicator, i apologize if i did not mention that i was dealing with the current bar and not the values that have been established in the previous bar. Current bar values are not established until the bar is fully developed but they can be called by an EA. In which case, it would call the index value and set the actual value after close of bar, right?

Reason: