Forex Trading Software





 
Methods of technical analysis

Custom Search



























Programming the Parallel Function

Now, let's detail the programming of the parallel function which must behave exactly as the system but without the use of the system statements buy, sell, exitlong and exitshort.

Here's the parallel function, which I've named OMW_BO for (Omega World Breakout).

Inputs:   Delay(numeric), Tgt(numeric), Stp(numeric);

Vars:   NuHi(0), NuLo(0), Bpt(0), Spt(0), tt(0), Lng(false), Sht(false);

If D<>D[1] then begin

    NuHi = H;

    NuLo = L;

    Bpt = 9999999;

    Spt = 0;

    Lng = false;

    Sht = false;

    Value1 = 0;

    tt = 0;

end;

If H>NuHi then NuHi = H;

If Lthen NuLo = L;

If T = CalcTime(Sess1StartTime,Delay)   then begin

    Bpt = NuHi + .1;

    Spt = NuLo -   .1;

end;

If H > Bpt and tt = 0 then Lng = true;

If Lng then begin

   

    If H > Bpt + Tgt then begin

    If tt = 0 then Value1 = tgt;

    tt = 1;

    end;

    If L < Bpt - Stp and lng[1] = true then begin

    If tt = 0 then Value1 = -stp;

    tt = 1;

    end;

    If tt = 0 and T = Sess1EndTime then Value1 = C - Bpt;

     

end;

   

If L < Spt and tt = 0 then sht = true;

If sht then begin

     

    If L < Spt - tgt then begin

    If tt = 0 then Value1 = tgt;

    tt = 1;

    end;

    If H >= Spt + stp and sht[1] = true then begin

    If tt = 0 then Value1 = -stp;

    tt = 1;

    end;

   

    If tt = 0 and T = Sess1EndTime then Value1 = Spt - C;

     

end;

OMW_BO = Value1;

Now, lets detail the parallel function code, pointing out the changes necessary to enable the function to perform as a system.

The input declarations are similar, except that the default values are set up to receive numeric inputs from the indicator / system using this function.

Inputs:   Delay(numeric), Tgt(numeric), Stp(numeric);

In the variables declaration section the first 4 variables are identical. It is necessary to add three more variables for our function: tt, which will record total trades, Lng and Sht, which will be reset to true if the market takes a long "Lng" or short "Sht" position.

Vars:   NuHi(0), NuLo(0), Bpt(0), Spt(0), tt(0), Lng(false), Sht(false);

The reset section adds reset lines for the newly added variables as they will need to store new values for each new day. We also reset value1 to 0 here which stores the ultimate value for the function.

If D<>D[1] then begin

    NuHi = H;

    NuLo = L;

    Bpt = 9999999;

    Spt = 0;

    Lng = false;

    Sht = false;

    Value1 = 0;

    tt = 0;

end;

The next six lines are identical to the system code.

If H>NuHi then NuHi = H;

If Lthen NuLo = L;

If T = CalcTime(Sess1StartTime,Delay)   then begin

    Bpt = NuHi + .1;

    Spt = NuLo -   .1;

end;

    Here's where the major changes begin.

    The next line tells the function when a long breakout has occurred. The statement says that if the high of a bar is greater than our buy point then the market has traded through our buy stop and system is in a long position. Additionally, since our system is designed to take only one trade per day, the tt=0 statement will only allow the Lng variable to be set to true if this is the first time that the high of a bar goes through our buy point.

If H > Bpt and tt = 0 then Lng = true;

Inside the next bracket we calculate the results of our long trade.

If Lng then begin

 

    The next line is activated when the high of a bar exceeds our buy point plus our target objective, or when our system has taken a profit on the long position. If this condition (H > Bpt + Tgt) is true then the program returns the value of the target for value1 (Value1 = tgt), only if we are on the first occurrence of the breakout (tt=0). Therefore, the function will return the value for the target stop when the high of a bar has exceeded the breakout point plus the target value.

    The last line in this bracket (tt = 1) sets the total trades to 1 which prevents the function from reporting any more values for the day.

   

    If H > Bpt + Tgt then begin

    If tt = 0 then Value1 = tgt;

    tt = 1;

    end;

    The next bracket calculates a function value when the system is stopped out for a loss. In the same fashion as the bracket above, the function value is set to the value of the stop loss (stp) when the low of a bar goes below our buy point minus the stop loss value.

    If L < Bpt - Stp and lng[1] = true then begin

    If tt = 0 then Value1 = -stp;

    tt = 1;

    end;

    The last line in this bracket returns the result of the system should we reach the end of the day and the position is liquidated on the close.

    If tt = 0 and T = Sess1EndTime then Value1 = C - Bpt;

     

end;

    The next several lines of the function program calculate the value for the function in the case of a short position for the system.

   

If L < Spt and tt = 0 then sht = true;

If sht then begin

     

    If L < Spt - tgt then begin

    If tt = 0 then Value1 = tgt;

    tt = 1;

    end;

    If H >= Spt + stp and sht[1] = true then begin

    If tt = 0 then Value1 = -stp;

    tt = 1;

    end;

   

    If tt = 0 and T = Sess1EndTime then Value1 = Spt - C;

     

end;

    The last line assigns to the function the calculated value for value1.

OMW_BO = Value1;



Category: Methods of technical analysis




Copyright © 2007 fxtrading-software.com