I test the strategy below (you can look the attachement)
Code: Select all
[IntrabarOrderGeneration = true]
Input:
Price(close),
Length(20);
Variables:
intrabarpersist top(false),
intrabarpersist bottom(false),
intrabarpersist average_jtJMA (0),
intrabarpersist var0 (0),
intrabarpersist var1 (0);
//compute moyenne mobile
average_jtJMA = jtHMA(price, length);
//when the average changes direction : (moving average is going up)
if average_jtJMA[2] > average_jtJMA[1] and average_jtJMA[1] < average_jtJMA then
var0 = 1
else
//when the average changes direction : (moving average is going down)
if average_jtJMA[2] < average_jtJMA[1] and average_jtJMA[1] > average_jtJMA then
var0 = -1
else
var0 = 0 ;
//LONG
If ( var0=1 ) Then
Begin
bottom = true;
top = false;
End;
If bottom then buy ("LE") this bar at close ;
If ( Marketposition = 1 ) and top then sell ("LEX") 1 contract next bar market ;
//SHORT
If ( var0=-1 ) Then
Begin
bottom = false;
top = true;
End;
If top then sellshort ("SE") this bar at close ;
if ( Marketposition = -1 ) and bottom then buytocover ("SEX") 1 contract next bar market ;
I don't understand why some entries are executed whereas "var0" doesn't equal to 1 or -1..
Anybody would have an idea?
best regards