Thread: Float
View Single Post
  #4 (permalink)  
Old 11-29-2005, 01:15 AM
marketjouster marketjouster is offline
Junior Member
 
Join Date: Nov 2005
Location: Amman, Jordan
Posts: 22
marketjouster is on a distinguished road
Rewrite Float Indicator into .mq4 ?

Hello New Digital,
Has anyone rewritten the Float indicator into .mq4 script for MT4? I see there's an .mql version here. On the SB forum there's discussion about this indicator plus an expert was written but the indicator (written by Barry Stander) acts buggy, and no one can locate the source code. I found the following script by 'Bigblock' posted on the Gordago site. I'm not sure what script it is but perhaps the logic is clear to some ambitious soul who'd like to make it work as an .mq4 file? It may be the same as the barry S. 'Float' although this one is longer (I'm no coder)
Of the Float indicators posted above, the one I prefer is the one which creates the ramp of blue histogram lines. I've also attached the buggy Float file from the SB forum.

-MJ
-----------------------------
/*[[
Name := FLOAT
Author := Bigblockfw
Separate Window := Yes
First Color := Blue
First Draw Type := histogram
First Symbol := 217
Use Second Data := Yes
Second Color := Red
Second Draw Type := Line
Second Symbol := 218
Changing the value of Float to 100 will alow it to display properly on 15 min chart,
200 = 30 min 20 = 5 min
]]*/
input : float(100),use_fibos(1),Backtesting(0);
Variable :
shift(0),f(0),c1(0),high_bar(0),Low_bar(0),bars_hi gh(0),bars_low(0);
Variable :
cumulativeV(0),FLOATV(0),cumulativeV2(0),loopbegin 2(0),swing(0),swing_time(0);
Variable : swingv(0),loopbegin1(0),cnt(0);
Variable : first(True),first1(True), prevbars(0);
Variable : cvstart(0),cvend(0),bar(0),newcv(0),CV(0),CV2(0);
Variable : fib23(0),fib38(0),fib50(0),fib62(0),fib76(0);
Variable : dinap0(0),dinap1(0),dinap2(0),dinap3(0),dinap4(0), dinap5(0);
Variable : CVL(0),CVL1(0),CVL2(0),CVL3(0),CVL4(0);

cumulativeV=0;
cumulativeV2=0;

SetLoopCount(0);
If Bars < prevbars Or Bars-prevbars>1 Then
first = True;
first1 = True;
prevbars = Bars;
FLOATV=0;

If first Then Begin
loopbegin1 = Bars-float-1;
loopbegin2 = Bars-float-1;
first = False;

loopbegin1 = loopbegin1+1;
For shift = loopbegin1 Downto 0 Begin
//find high and low
high_bar = H[Highest(MODE_HIGH,float,float)];
Low_bar = L[Lowest(MODE_LOW,float,float)];
//find bar counts
bars_high = highest(MODE_HIGH,float,float);
bars_low = lowest(MODE_LOW,float,float);
//find swing price differance
swing = H[Highest(MODE_HIGH,float,float)]-
L[Lowest(MODE_LOW,float,float)];
//find float time barcount
swing_time = abs(bars_low-bars_high);

//find cumulative volume for float period
IF bars_high < bars_low then
{
cvstart=bars_low;
cvend=bars_high;
}
else
{
cvstart=bars_high;
cvend=bars_low;
}
If first1 and FLOATV=0 Then Begin
for shift = cvstart downto cvend Begin {
FLOATV=FLOATV+V[shift];
first1 = False;}
end;

//find cumulative volume since last turnover
for shift = cvstart downto 0 Begin
cumulativeV=cumulativeV+V[shift];

if cumulativeV>=FLOATV then{
cumulativeV=0;
}

SetIndexValue(shift,cumulativeV*0.001);//Blue
SetIndexValue2(shift,FLOATV*0.001);//red

comment(
"\n","high was ",bars_high," bars ago",
"\n","Low was ",bars_low," bars ago","\n",
"\n","Float time was = ", swing_time," bars",
"\n","Float Vol. left = ",FLOATV-cumulativeV,
"\n","Float Volume = ",FLOATV
);

MoveObject("swingtop",OBJ_TRENDLINE,Time[cvstart],high_bar,Time[1],high_bar,Blue,1,STYLE_SOLID);
MoveObject("swingbottom",OBJ_TRENDLINE,Time[cvstart],Low_bar,Time[1],Low_bar,Blue,1,STYLE_SOLID);

//fibos
If use_fibos=1 then{
fib23=((high_bar-Low_bar)*0.236)+Low_bar;
fib38=((high_bar-Low_bar)*0.382)+Low_bar;
fib50=((high_bar-Low_bar)/2)+Low_bar;
fib62=((high_bar-Low_bar)*0.618)+Low_bar;
fib76=((high_bar-Low_bar)*0.764)+Low_bar;
dinap0=(Low_bar+fib23)/2;
dinap1=(fib23+fib38)/2;
dinap2=(fib38+fib50)/2;
dinap3=(fib50+fib62)/2;
dinap4=(fib62+fib76)/2;
dinap5=(high_bar+fib76)/2;
MoveObject("fib23",OBJ_TRENDLINE,Time[cvstart],fib23,Time[1],fib23,Green,1,STYLE_DASH);
SetObjectText("23","23.6","Arial",8,green);
MoveObject("23",OBJ_TEXT,time[0],fib23,time[0],fib23,Green);
MoveObject("fib38",OBJ_TRENDLINE,Time[cvstart],fib38,Time[1],fib38,Green,1,STYLE_DASH);
SetObjectText("38","38.2","Arial",8,green);
MoveObject("38",OBJ_TEXT,time[0],fib38,time[0],fib38,Green);
MoveObject("fib50",OBJ_TRENDLINE,Time[cvstart],fib50,Time[1],fib50,Red,2,STYLE_SOLID);
SetObjectText("50","50","Arial",8,green);
MoveObject("50",OBJ_TEXT,time[0],fib50,time[0],fib50,Green);
MoveObject("fib62",OBJ_TRENDLINE,Time[cvstart],fib62,Time[1],fib62,Green,1,STYLE_DASH);
SetObjectText("62","61.8","Arial",8,green);
MoveObject("62",OBJ_TEXT,time[0],fib62,time[0],fib62,Green);
MoveObject("fib76",OBJ_TRENDLINE,Time[cvstart],fib76,Time[1],fib76,Green,1,STYLE_DASH);
SetObjectText("76","76.4","Arial",8,green);
MoveObject("76",OBJ_TEXT,time[0],fib76,time[0],fib76,Green);
MoveObject("dinap0",OBJ_TRENDLINE,Time[cvstart],dinap0,Time[1],dinap0,Red,1,STYLE_DOT);
MoveObject("dinap1",OBJ_TRENDLINE,Time[cvstart],dinap1,Time[1],dinap1,Red,1,STYLE_DOT);
MoveObject("dinap2",OBJ_TRENDLINE,Time[cvstart],dinap2,Time[1],dinap2,Red,1,STYLE_DOT);
MoveObject("dinap3",OBJ_TRENDLINE,Time[cvstart],dinap3,Time[1],dinap3,Red,1,STYLE_DOT);
MoveObject("dinap4",OBJ_TRENDLINE,Time[cvstart],dinap4,Time[1],dinap4,Red,1,STYLE_DOT);
MoveObject("dinap5",OBJ_TRENDLINE,Time[cvstart],dinap5,Time[1],dinap5,Red,1,STYLE_DOT);
}

//vert. float lines. these draw the lines that calculate the float
//if you change "trendline" to "Vline" it will draw through oscillators too.might be fun
MoveObject("CVSTART",OBJ_TRENDLINE,Time[cvstart],high_bar,Time[cvstart],Low_bar*point,Blue,1,STYLE_SOLID);
MoveObject("CVEND",OBJ_TRENDLINE,Time[cvend],high_bar,Time[cvend],Low_bar*point,Blue,1,STYLE_SOLID);

//vert float predictions. These are only time based.
//see blue histogram for real float values.
//if you change "trendline" to "Vline" it will draw through oscillators too.might be fun
if cvend-swing_time>0 then {
MoveObject("swingend",OBJ_TRENDLINE,Time[(cvend-swing_time)+5],high_bar,Time[cvend-swing_time+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend",0,0,0,0);
if cvend-(swing_time*2)>0 then {
MoveObject("swingend2",OBJ_TRENDLINE,Time[(cvend-(swing_time*2))+5],high_bar,Time[cvend-(swing_time*2)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend2",0,0,0,0);
if cvend-(swing_time*3)>0 then {
MoveObject("swingend3",OBJ_TRENDLINE,Time[(cvend-(swing_time*3))+5],high_bar,Time[cvend-(swing_time*3)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend3",0,0,0,0);
if cvend-(swing_time*4)>0 then {
MoveObject("swingend4",OBJ_TRENDLINE,Time[(cvend-(swing_time*4))+5],high_bar,Time[cvend-(swing_time*4)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend4",0,0,0,0);
if cvend-(swing_time*5)>0 then {
MoveObject("swingend5",OBJ_TRENDLINE,Time[(cvend-(swing_time*5))+5],high_bar,Time[cvend-(swing_time*5)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend5",0,0,0,0);
if cvend-(swing_time*6)>0 then {
MoveObject("swingend6",OBJ_TRENDLINE,Time[cvend-(swing_time*6)+5],high_bar,Time[cvend-(swing_time*6)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend6",0,0,0,0);
if cvend-(swing_time*7)>0 then {
MoveObject("swingend7",OBJ_TRENDLINE,Time[cvend-(swing_time*7)+5],high_bar,Time[cvend-(swing_time*7)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend7",0,0,0,0);
if cvend-(swing_time*8)>0 then {
MoveObject("swingend8",OBJ_TRENDLINE,Time[cvend-(swing_time*8)+5],high_bar,Time[cvend-(swing_time*8)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend8",0,0,0,0);
if cvend-(swing_time*9)>0 then {
MoveObject("swingend9",OBJ_TRENDLINE,Time[cvend-(swing_time*9)+5],high_bar,Time[cvend-(swing_time*9)+5],Low_bar,Red,1,STYLE_DOT);
}
else DelObject("swingend9",0,0,0,0);

//comment out anything you"re not using it will help with speed.
If Backtesting = 1 then {
SetGlobalVariable("fib23",fib23);
SetGlobalVariable("fib38",fib38);
SetGlobalVariable("fib50",fib50);
SetGlobalVariable("fib62",fib62);
SetGlobalVariable("fib76",fib76);
SetGlobalVariable("dinap0",dinap0);
SetGlobalVariable("dinap1",dinap1);
SetGlobalVariable("dinap2",dinap2);
SetGlobalVariable("dinap3",dinap3);
SetGlobalVariable("dinap4",dinap4);
SetGlobalVariable("dinap5",dinap5);
SetGlobalVariable("swingtop",high_bar);
SetGlobalVariable("swingbottom",Low_bar);
SetGlobalVariable("CVSTART",CVSTART);
SetGlobalVariable("CVEND",CVEND);
SetGlobalVariable("FLOATV",FLOATV);
SetGlobalVariable("cumulativeV",cumulativeV);
SetGlobalVariable("swing_time",swing_time);
SetGlobalVariable("bars_high",bars_high);
SetGlobalVariable("bars_low",bars_low);
if cvend-swing_time>0 then
SetGlobalVariable("swingend",(cvend-swing_time)+5);
if cvend-(swing_time*2)>0 then
SetGlobalVariable("swingend2",cvend-(swing_time*2)+5);
if cvend-(swing_time*3)>0 then
SetGlobalVariable("swingend3",cvend-(swing_time*3)+5);
if cvend-(swing_time*4)>0 then
SetGlobalVariable("swingend4",cvend-(swing_time*4)+5);
if cvend-(swing_time*5)>0 then
SetGlobalVariable("swingend5",cvend-(swing_time*5)+5);
if cvend-(swing_time*6)>0 then
SetGlobalVariable("swingend6",cvend-(swing_time*6)+5);
if cvend-(swing_time*7)>0 then
SetGlobalVariable("swingend7",cvend-(swing_time*7)+5);
if cvend-(swing_time*8)>0 then
SetGlobalVariable("swingend8",cvend-(swing_time*8)+5);
if cvend-(swing_time*9)>0 then
SetGlobalVariable("swingend9",cvend-(swing_time*9)+5);
}
End;
end;
end;
end;
Attached Files
File Type: mq4 Float.mq4 (3.2 KB, 390 views)

Last edited by marketjouster; 11-29-2005 at 01:22 AM.
Reply With Quote