Moderator comment: @Muli - you must follow forum rules and use CODE TAGS.
//***************************//
// Get values for fib levels //
//***************************//
StartBar = SelectedValue(BarIndex());
FinishBar = EndValue( BarIndex() );
i = startbar;
period = FinishBar - StartBar;
Lo = Ref(LLV(C,period),-1);
Hi = Ref(HHV(C,period),-1);
Line0 = 0;
Line1 = 0;
Line2 = 0;
Line3 = 0;
Line4 = 0;
Line5 = 0;
Line6 = 0;
Line7 = 0;
Line8 = 0;
Line9 = 0;
Line10 = 0;
Line100 = 0;
for( i = startbar; i < finishbar; i++ )
{
if(EndValue(C) > SelectedValue(C))
{
Line0 = EndValue(Lo);
Line100 = EndValue(Hi);
Line1 = Line0 + abs(Line100-Line0)*0.236;
Line2 = Line0 + abs(Line100-Line0)*0.382;
Line3 = Line0 + abs(Line100-Line0)*0.500;
Line4 = Line0 + abs(Line100-Line0)*0.618;
Line5 = Line0 + abs(Line100-Line0)*0.764;
Line6 = Line0 + abs(Line100-Line0)*1.000;
Line7 = Line0 + abs(Line100-Line0)*1.270;
Line8 = Line0 + abs(Line100-Line0)*1.618;
Line9 = Line0 + abs(Line100-Line0)*2.000;
Line10 = Line0 + abs(Line100-Line0)*2.240;
}
else
{
Line100 = EndValue(Lo);
Line0 = EndValue(Hi);
Line1 = Line0 - abs(Line100-Line0)*0.236;
Line2 = Line0 - abs(Line100-Line0)*0.382;
Line3 = Line0 - abs(Line100-Line0)*0.500;
Line4 = Line0 - abs(Line100-Line0)*0.618;
Line5 = Line0 - abs(Line100-Line0)*0.764;
Line6 = Line0 - abs(Line100-Line0)*1.000;
Line7 = Line0 - abs(Line100-Line0)*1.270;
Line8 = Line0 - abs(Line100-Line0)*1.618;
Line9 = Line0 - abs(Line100-Line0)*2.000;
Line10 = Line0 - abs(Line100-Line0)*2.240;
}
}
// external fib lines begining fom selecetdbarindex()
fib0 = LineArray(startbar, Line0, finishbar, Line0, 0, 1);
fib100 = LineArray(startbar, Line100, finishbar, Line100, 0, 1);
// depth of middle lines
n = round((finishbar-startbar)/2);
// middle lines
fib1 = LineArray((finishbar-n), Line1, finishbar, Line1, 0, 1);
fib2 = LineArray((finishbar-n), Line2, finishbar, Line2, 0, 1);
fib3 = LineArray((finishbar-n), Line3, finishbar, Line3, 0, 1);
fib4 = LineArray((finishbar-n), Line4, finishbar, Line4, 0, 1);
fib5 = LineArray((finishbar-n), Line5, finishbar, Line5, 0, 1);
fib6 = LineArray((finishbar-n), Line6, finishbar, Line6, 0, 1);
fib7 = LineArray((finishbar-n), Line7, finishbar, Line7, 0, 1);
fib8 = LineArray((finishbar-n), Line8, finishbar, Line8, 0, 1);
fib9 = LineArray((finishbar-n), Line9, finishbar, Line9, 0, 1);
fib10 = LineArray((finishbar-n), Line10, finishbar, Line10, 0, 1);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
Plot(fib0,"", colorDarkGreen);
Plot(fib100,"", colorDarkRed);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
Plot(fib1,"", colorYellow); //23.6%
Plot(fib2,"", colorYellow); //38.2%
Plot(fib3,"", colorYellow); //50.0%
Plot(fib4,"", colorYellow); //61.8%
Plot(fib5,"", colorYellow); //76.4%
Plot(fib6,"", colorYellow); //100.0%
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
if ( Number ==1 )
{
Plot(fib7,"", colorYellow); //127.0%
}
if ( Number ==2 )
{
Plot(fib7,"", colorYellow); //127.0%
Plot(fib8,"", colorYellow); //161.8%
}
if ( Number ==3 )
{
Plot(fib7,"", colorYellow); //127.0%
Plot(fib8,"", colorYellow); //161.8%
Plot(fib9,"", colorYellow); //200.0%
}
if ( Number ==4 )
{
Plot(fib7,"", colorYellow); //127.0%
Plot(fib8,"", colorYellow); //161.8%
Plot(fib9,"", colorYellow); //200.0%
Plot(fib10,"", colorYellow);//224.0%
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//