How can i record the closing price of a specific candle
save it as a global variable (double).
then do something like
double bar_close; if(Close[1]>bar_close) { bar_close=Close[1];// save new high. }
Hi
Try this example:
// Rates Structure for the data of the Last complete BAR MqlRates BarData[1]; CopyRates(Symbol(), Period(), 1, 1, BarData); // Copy the data of last complete BAR // Highest value of the CLOSE price. static double dMy_Highest_Close_Price = 0; // Use a static double to keep the value in the memory or use a global variable. // Check of new close price is higher than the saved close price. if(BarData[0].close > dMy_Highest_Close_Price) { dMy_Highest_Close_Price = BarData[0].close; // Update the new highest close price. } Print("My highest close price = ", dMy_Highest_Close_Price, " Current close price = ", BarData[0].close);
and save it until a higher closing price is achieved?
eg: prev candle's closing price is 1.0950, which is saved as a variable. I want to save this price until a candle shows a higher closing price, in which case, the new closing price wil be the value of my variable.
If I try to set the closing price as a static, it gets saved, but then i cant replace it with a new value.
If I try to set it as a double, it gets saved only for the duration of that bar, and changes with each bar.
Any ideas?