Hi, can anyone convert this TS code from profit trader into MQL? It's the "B Line" for buy/sell signals.. ideally if it could be plotted as buy/sell arrows on the charts, that would be excellent.
Here's the indicator...
Code:
{Description of Inputs}{CXOver - This oscillator can be used with a crossover, although it is usually plotted without one.CXOver is the length of the of the moving agerage of the BLine to construct the crossover. The purpose of a crossover is to improve the accuracy of an oscillator that wiggles at tops and bottoms. In most markets the BLine does not often wiggle at tops and bottoms.}
{SellLine and BuyLine are levels the osc must rise above for an osc downturn to paint a sell setup bar, or drop below for an osc upturn to paint a buy setup bar}
Inputs: CXOver(0),SellLine(70),BuyLine(30),Alrt(0);
Vars: Len1(3),Len2(3),Len3(3),OBOSMY(0),OBOSMYC(0),Sum(0),Cnt(0);
{OBOS}
Sum=0;
For Cnt=0 to Len2-1 begin
Sum=Sum+_OBOS(CXOver)[Cnt];
End;
If Len2>0 then
OBOSMY=Sum/Len2
Else
OBOSMY=0;
Sum=0;
For Cnt=0 to CXOver-1 begin
Sum=Sum+OBOSMY[Cnt];
End;
If CXOver>0 then
OBOSMYC=Sum/CXOver
Else
OBOSMYC=0;
If Alrt<>0 then begin
If OBOSMY<BuyLine then Alert=True;
If OBOSMY>SellLine then Alert=True;
End;
{Plots}
If CXOver=0 then
Plot1(Round(OBOSMY,1),"BLine");
If CXOver<>0 then begin
Plot1(Round(OBOSMY,1),"BLine");
Plot2(Round(OBOSMYC,1),"BLine_CO");
End;
Plot3(SellLine,"BLine_SL");
Plot4(BuyLine,"BLine_BL");
and here is the OBOS function...
Code:
{_OBOS:OBOB}
Inputs: CXOver(NumericSimple);
Vars: Len1(3),Len2(3),Len3(3),OBOS(0),PPr(0),Op(0),HstH(0),LstL(0),Cntr(0),
DAmt(0),UAmt(0),USm(0),DSm(0),UAvg(0),DAvg(0),MRng(0);
{OB/OS}
Op=O[Len3];
HstH=_Hst(H,Len3);
LstL=_Lst(L,Len3);
PPr=(Op+HstH+LstL+C)/4;
If CurrentBar=1 then begin
MRng=Len1;
USm=0;
DSm=0;
For Cntr=0 to MRng-1 begin
UAmt=PPr[Cntr]-PPr[Cntr+1];
If (UAmt>=0) then
DAmt=0
Else begin
DAmt=-UAmt;
UAmt=0;
End;
USm=USm+UAmt;
DSm=DSm+DAmt;
End;
UAvg=USm/MRng;
DAvg=DSm/MRng;
End
Else
If CurrentBar>1 then begin
UAmt=PPr[0]-PPr[1];
IF UAmt>=0 then
DAmt=0
Else begin
DAmt=-UAmt;
UAmt=0;
End;
UAvg=(UAvg[1]*(MRng-1)+UAmt)/MRng;
DAvg=(DAvg[1]*(MRng-1)+DAmt)/MRng;
End;
IF UAvg+DAvg<>0 then
OBOS=100*UAvg/(UAvg+DAvg)
Else
OBOS=0;
_OBOS=OBOS;
all are welcome to use this as a nice filter!
thanks!