Buffer static and non static

 
Please
    double USDCADOPEN = iOpen("USDCAD",PERIOD_D1,0);
   double USDCHFOPEN = iOpen("USDCHF",PERIOD_D1,0);
   double USDJPYOPEN = iOpen("USDJPY",PERIOD_D1,0);
   double AUDUSDOPEN = iOpen("AUDUSD",PERIOD_D1,0);
   double EURUSDOPEN = iOpen("EURUSD",PERIOD_D1,0);
   double GBPUSDOPEN = iOpen("GBPUSD",PERIOD_D1,0);
   double NZDUSDOPEN = iOpen("NZDUSD",PERIOD_D1,0);
  
   double USDCAD = SymbolInfoDouble("USDCAD"+SymSuffix,SYMBOL_BID);   
   double USDCHF = SymbolInfoDouble("USDCHF"+SymSuffix,SYMBOL_BID);      
   double USDJPY = SymbolInfoDouble("USDJPY"+SymSuffix,SYMBOL_BID);      
   double AUDUSD = SymbolInfoDouble("AUDUSD"+SymSuffix,SYMBOL_BID);      
   double EURUSD = SymbolInfoDouble("EURUSD"+SymSuffix,SYMBOL_BID);      
   double GBPUSD = SymbolInfoDouble("GBPUSD"+SymSuffix,SYMBOL_BID);      
   double NZDUSD = SymbolInfoDouble("NZDUSD"+SymSuffix,SYMBOL_BID);                     
//---
   double USDIndex =  pow(((USDCHF*USDJPY*USDCAD)/(EURUSD*GBPUSD*AUDUSD)),0.142857142857142855714285714);
   double AUDIndex = USDIndex*AUDUSD;                                                           
   double CADIndex = USDIndex/USDCAD;                                                           
   double CHFIndex = USDIndex/USDCHF;                                                           
   double EURIndex = USDIndex*EURUSD;                                                           
   double GBPIndex = USDIndex*GBPUSD;                                                           
   double NZDIndex = USDIndex*NZDUSD;                                                           
   double JPYIndex = USDJPY/USDIndex;   
  
  
  

double  BufferUSDOPEN1= pow(((USDCHFOPEN*USDJPYOPEN*USDCADOPEN)/(EURUSDOPEN*GBPUSDOPEN*AUDUSDOPEN)),0.142857142857142855714285714);

   double USDHIGH()
{
   double USDINDEX=pow(((USDCHF*USDJPY*USDCAD)/(EURUSD*GBPUSD*AUDUSD)),0.142857142857142855714285714);
   if(USDINDEX > BufferUSDOPEN1) BufferUSDOPEN1=USDINDEX;
   return(BufferUSDOPEN1);
} 

double  BufferUSDOPEN2= pow(((USDCHFOPEN*USDJPYOPEN*USDCADOPEN)/(EURUSDOPEN*GBPUSDOPEN*AUDUSDOPEN)),0.142857142857142855714285714);

   double USDLOW()
{
   double USDINDEX=pow(((USDCHF*USDJPY*USDCAD)/(EURUSD*GBPUSD*AUDUSD)),0.142857142857142855714285714);
   if(USDINDEX < BufferUSDOPEN2) BufferUSDOPEN2=USDINDEX;
   return(BufferUSDOPEN2);
}  
Please can this be modified to work based on non static usdindex?
once i run it it doesn't recalculate anymore
 
double USDCADOPEN, USDCHFOPEN, USDJPYOPEN, AUDUSDOPEN, EURUSDOPEN, GBPUSDOPEN, NZDUSDOPEN;
double USDCAD, USDCHF, USDJPY, AUDUSD, EURUSD, GBPUSD, NZDUSD;
double BufferUSDOPEN1, BufferUSDOPEN2;

void OnTick()
{
    // Update the opening prices
    USDCADOPEN = iOpen("USDCAD", PERIOD_D1, 0);
    USDCHFOPEN = iOpen("USDCHF", PERIOD_D1, 0);
    USDJPYOPEN = iOpen("USDJPY", PERIOD_D1, 0);
    AUDUSDOPEN = iOpen("AUDUSD", PERIOD_D1, 0);
    EURUSDOPEN = iOpen("EURUSD", PERIOD_D1, 0);
    GBPUSDOPEN = iOpen("GBPUSD", PERIOD_D1, 0);
    NZDUSDOPEN = iOpen("NZDUSD", PERIOD_D1, 0);

    // Update the current bid prices
    USDCAD = SymbolInfoDouble("USDCAD" + SymSuffix, SYMBOL_BID);
    USDCHF = SymbolInfoDouble("USDCHF" + SymSuffix, SYMBOL_BID);
    USDJPY = SymbolInfoDouble("USDJPY" + SymSuffix, SYMBOL_BID);
    AUDUSD = SymbolInfoDouble("AUDUSD" + SymSuffix, SYMBOL_BID);
    EURUSD = SymbolInfoDouble("EURUSD" + SymSuffix, SYMBOL_BID);
    GBPUSD = SymbolInfoDouble("GBPUSD" + SymSuffix, SYMBOL_BID);
    NZDUSD = SymbolInfoDouble("NZDUSD" + SymSuffix, SYMBOL_BID);

    // Calculate the indices
    double USDIndex = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    double AUDIndex = USDIndex * AUDUSD;
    double CADIndex = USDIndex / USDCAD;
    double CHFIndex = USDIndex / USDCHF;
    double EURIndex = USDIndex * EURUSD;
    double GBPIndex = USDIndex * GBPUSD;
    double NZDIndex = USDIndex * NZDUSD;
    double JPYIndex = USDJPY / USDIndex;

    // Update the BufferUSDOPEN1 and BufferUSDOPEN2 variables
    BufferUSDOPEN1 = USDHIGH();
    BufferUSDOPEN2 = USDLOW();

    // Add your additional code here
}

double USDHIGH()
{
    double BufferUSDOPEN1 = pow(((USDCHFOPEN * USDJPYOPEN * USDCADOPEN) / (EURUSDOPEN * GBPUSDOPEN * AUDUSDOPEN)), 0.142857142857142855714285714);
    double USDINDEX = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    if (USDINDEX > BufferUSDOPEN1) BufferUSDOPEN1 = USDINDEX;
    return (BufferUSDOPEN1);
}

double USDLOW()
{
    double BufferUSDOPEN2 = pow(((USDCHFOPEN * USDJPYOPEN * USDCADOPEN) / (EURUSDOPEN * GBPUSDOPEN * AUDUSDOPEN)), 0.142857142857142855714285714);
    double USDINDEX = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    if (USDINDEX < BufferUSDOPEN2) BufferUSDOPEN2 = USDINDEX;
    return (BufferUSDOPEN2);
}
NOTE: if you're using a script instead of an EA you'll need to replace the OnTick() function with the OnCalculate()
 
perfect, thank you, it's probably not possible for him to remember the highest and lowest value of low and high?
 
Zbynek Liska #:
perfect, thank you, it's probably not possible for him to remember the highest and lowest value of low and high?

Possible Zbynek possible:

double USDCADOPEN, USDCHFOPEN, USDJPYOPEN, AUDUSDOPEN, EURUSDOPEN, GBPUSDOPEN, NZDUSDOPEN;
double USDCAD, USDCHF, USDJPY, AUDUSD, EURUSD, GBPUSD, NZDUSD;
double BufferUSDOPEN1, BufferUSDOPEN2;
double USDHighest, USDLowest;

void OnTick()
{
    // Update the opening prices
    USDCADOPEN = iOpen("USDCAD", PERIOD_D1, 0);
    // ... (update other opening prices)

    // Update the current bid prices
    USDCAD = SymbolInfoDouble("USDCAD" + SymSuffix, SYMBOL_BID);
    // ... (update other bid prices)

    // Calculate the indices
    double USDIndex = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    double AUDIndex = USDIndex * AUDUSD;
    // ... (calculate other indices)

    // Update the BufferUSDOPEN1 and BufferUSDOPEN2 variables
    BufferUSDOPEN1 = USDHIGH();
    BufferUSDOPEN2 = USDLOW();

    // Update the highest and lowest values of USDIndex
    USDHighest = MathMax(USDHighest, USDIndex);
    USDLowest = MathMin(USDLowest, USDIndex);

    // Add your additional code here
}

double USDHIGH()
{
    double BufferUSDOPEN1 = pow(((USDCHFOPEN * USDJPYOPEN * USDCADOPEN) / (EURUSDOPEN * GBPUSDOPEN * AUDUSDOPEN)), 0.142857142857142855714285714);
    double USDINDEX = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    if (USDINDEX > BufferUSDOPEN1) BufferUSDOPEN1 = USDINDEX;
    return (BufferUSDOPEN1);
}

double USDLOW()
{
    double BufferUSDOPEN2 = pow(((USDCHFOPEN * USDJPYOPEN * USDCADOPEN) / (EURUSDOPEN * GBPUSDOPEN * AUDUSDOPEN)), 0.142857142857142855714285714);
    double USDINDEX = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    if (USDINDEX < BufferUSDOPEN2) BufferUSDOPEN2 = USDINDEX;
    return (BufferUSDOPEN2);
}


NOTE: if you wish to reset the highest and lowest values at the beginning of trading session or new day, you need to initialize USDHighest and USDLowest with appropriate values on start.

 
void OnTick()

{
    USDCADOPEN = iOpen("USDCAD", PERIOD_D1, 0);
    USDCHFOPEN = iOpen("USDCHF", PERIOD_D1, 0);
    USDJPYOPEN = iOpen("USDJPY", PERIOD_D1, 0);
    AUDUSDOPEN = iOpen("AUDUSD", PERIOD_D1, 0);
    EURUSDOPEN = iOpen("EURUSD", PERIOD_D1, 0);
    GBPUSDOPEN = iOpen("GBPUSD", PERIOD_D1, 0);
    NZDUSDOPEN = iOpen("NZDUSD", PERIOD_D1, 0);

    // Update the current bid prices
    USDCAD = SymbolInfoDouble("USDCAD" + SymSuffix, SYMBOL_BID);
    USDCHF = SymbolInfoDouble("USDCHF" + SymSuffix, SYMBOL_BID);
    USDJPY = SymbolInfoDouble("USDJPY" + SymSuffix, SYMBOL_BID);
    AUDUSD = SymbolInfoDouble("AUDUSD" + SymSuffix, SYMBOL_BID);
    EURUSD = SymbolInfoDouble("EURUSD" + SymSuffix, SYMBOL_BID);
    GBPUSD = SymbolInfoDouble("GBPUSD" + SymSuffix, SYMBOL_BID);
    NZDUSD = SymbolInfoDouble("NZDUSD" + SymSuffix, SYMBOL_BID);

    // Calculate the indices
    double USDIndex = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    double AUDIndex = USDIndex * AUDUSD;
    // ... (calculate other indices)

    // Update the BufferUSDOPEN1 and BufferUSDOPEN2 variables
    BufferUSDOPEN1 = USDHIGH();
    BufferUSDOPEN2 = USDLOW();

    // Update the highest and lowest values of USDIndex
    USDHighest = MathMax(USDHighest, USDIndex);
    USDLowest = MathMin(USDLowest, USDIndex);

    // Add your additional code here
ObjectCreate(0,"Test13",OBJ_LABEL,0,0,0,0,0,0,0);
ObjectSetString(0,"Test13",OBJPROP_TEXT,"Low "+DoubleToString(USDLOW(),4)+" Bid  "+DoubleToString(USDIndex,4)+" Lowest "+DoubleToString(USDLowest,4));
ObjectSetInteger(0,"Test13",OBJPROP_XDISTANCE,800);
ObjectSetInteger(0,"Test13",OBJPROP_YDISTANCE,50);
ObjectSetInteger(0,"Test13",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
ObjectSetInteger(0,"Test13",OBJPROP_COLOR,clrBlack);
ObjectSetInteger(0,"Test13",OBJPROP_FONTSIZE,16);
ObjectSetString(0,"Test13",OBJPROP_FONT,"Baskerville Old Face"); 
    
    
}

double USDHIGH()
{
    double BufferUSDOPEN1 = pow(((USDCHFOPEN * USDJPYOPEN * USDCADOPEN) / (EURUSDOPEN * GBPUSDOPEN * AUDUSDOPEN)), 0.142857142857142855714285714);
    double USDINDEX = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    if (USDINDEX > BufferUSDOPEN1) BufferUSDOPEN1 = USDINDEX;
    return (BufferUSDOPEN1);
}

double USDLOW()
{
    double BufferUSDOPEN2 = pow(((USDCHFOPEN * USDJPYOPEN * USDCADOPEN) / (EURUSDOPEN * GBPUSDOPEN * AUDUSDOPEN)), 0.142857142857142855714285714);
    double USDINDEX = pow(((USDCHF * USDJPY * USDCAD) / (EURUSD * GBPUSD * AUDUSD)), 0.142857142857142855714285714);
    if (USDINDEX < BufferUSDOPEN2) BufferUSDOPEN2 = USDINDEX;
    return (BufferUSDOPEN2);
}
i got it right please?  it shows this