Meysam1984
New member
hi i want create something like Tenkan future so i use this code and worked correctly.
but in this form If i change Tenkan period to more the 8 i can not calculate it. I use the above code because this code is not working and I get error on i variable that not the const value
also in first code block the plot draw with last loop, but i want each candle calculate separately and differently.
for more information i want create this for mql to thinkscript.
the mql code is like:
how can create first code block in second block. so my code is reduce and work with any period?
Code:
def futureTenkan = fold i = 0 to tenkanPeriod with result = Double.NaN do
if i == 1 then
(Highest(high, tenkanPeriod - 8) + Lowest(low, tenkanPeriod - 8)) / 2
else if i == 2 then
(Highest(high, tenkanPeriod - 7) + Lowest(low, tenkanPeriod - 7)) / 2
else if i == 3 then
(Highest(high, tenkanPeriod - 6) + Lowest(low, tenkanPeriod - 6)) / 2
else if i == 4 then
(Highest(high, tenkanPeriod - 5) + Lowest(low, tenkanPeriod - 5)) / 2
else if i == 5 then
(Highest(high, tenkanPeriod - 4) + Lowest(low, tenkanPeriod - 4)) / 2
else if i == 6 then
(Highest(high, tenkanPeriod - 3) + Lowest(low, tenkanPeriod - 3)) / 2
else if i == 7 then
(Highest(high, tenkanPeriod - 2) + Lowest(low, tenkanPeriod - 2)) / 2
else
(Highest(high, tenkanPeriod - 1) + Lowest(low, tenkanPeriod - 1)) / 2;
def shiftedFutureTenkan = futureTenkan[tenkanPeriod];
plot TenkanFuture = if IsNaN(close[0]) then shiftedFutureTenkan else Double.NaN;
TenkanFuture.SetDefaultColor(Color.CYAN);
TenkanFuture.SetPaintingStrategy(PaintingStrategy.LINE);
but in this form If i change Tenkan period to more the 8 i can not calculate it. I use the above code because this code is not working and I get error on i variable that not the const value
Code:
def futureTenkan = fold i = 0 to tenkanPeriod with result = Double.NaN do
if i == 0 then
Double.NaN
else
(Highest(high, tenkanPeriod - i) + Lowest(low, tenkanPeriod - i)) / 2;
for more information i want create this for mql to thinkscript.
the mql code is like:
Code:
TenkanFutureBuffer[9]=EMPTY_VALUE;
TenkanFutureBuffer[8]=TenkanBuffer[0];
for(int q=7 ; q>=0; q--)
{
highest = high[ArrayMaximum(high,0,q+1)];
lowest = low[ArrayMinimum(low,0,q+1)];
T = (highest + lowest)/2;
TenkanFutureBuffer[q]=T;
}
Last edited: