PL Language

 

PL language is an easy  interpreted language for writing strategies. It is a simplified Lisp model language that is written with its elements separated by white space, and surrounded by parentheses.

In MT4-Progress you don’t need to use it as it is generated by the graphical editor.
There is a complete mirroring between the Graphic Editor and the PL Editor.

2016-03-19 12_55_56-Strategy

 

Syntax

The language is composed of functions and values.

  • Function :

The syntax of a function is :

(function par1 par2 par3 …)

where par1 is either a value or a function.

  • Value :

A value is either a variable or a type value  or a constant.

 

An example of a strategy written in PL :

1
2
3
4
(IF(AND (AndBS UPFRACTAL S_ABOVE P_H4)
        (AndPS HIGH S_UP P_H4))
   (START) 
   (BUY))

 

Let’s examine the syntax of the expression above

The first expression is (IF par1 par2 par3)  where in the IF function we have

par1  :  (AND par11 par12)   // AND logical function returning true or false
par2 :  (BUY)  // function
par3 : (START)  // function

in  (AND par111 par112) we have

par111 : (AndBS UPFRACTAL S_ABOVE P_H4)  // ANDBS logical function on indicators
par112 : (AndPS HIGH S_UP P_H4)  // ANDPS logical function on indicators

2015-05-31 14_51_51-7614297_ Alpari-Demo - Demo Account - [EURUSD,Daily]

Explanation

AndBS function is the AND Period Logic operation for the signal S_ABOVE  occuring on the Object UPFRACTAL for a Bar of the period H4 and not occuring on the previous bar.  Returns true/false.

So here simply it returns true if the price is above the UPFRACTAL of the period H4 on only the first bar.

On the next other bars even if the price is above the UPFRACTAL it returns false.

We use this function when we want the beginning of the signal and we don’t want to get in late.

AndPS returns true if the previous HIGH is UP (means higher high)

 

 Complete Strategy written in PL Language

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
(SETQ Bid_P (/ (abs (SValue PIVOT_POINT S_DISTANCE P_D1))
               Point))

(IF (AND (< Bid_P 6)
         (NOT (AndS PIVOT_POINT S_CROSS_UP P_D1))
         (NOT (AndS PIVOT_POINT S_CROSS_DOWN P_D1)))
     
     (IF (AND (AndS PIVOT_POINT S_BELOW P_D1)
              (AndPS BAR S_BEAR P_D1)
              (AndS BAR S_BULL P_H1))
         (START)
         (BUY))

     (IF (AND (AndS PIVOT_POINT S_ABOVE P_D1)
              (AndPS BAR S_BULL P_D1)
              (AndS BAR S_BEAR P_H1))
         (START)
         (SELL))
)