north bergen
Posts: 13 since Feb 2017
Thanks Given: 3
Thanks Received: 1
|
I am having issues with writing a code that allows me to trade direction bias. To elaborate i want data2(larger size bars) to dictate the direction while Data1 ( smaller size bar) to dictate entry and exit. I wrote the code and it complies when i run the signal it trades both ways.
variables:
indicator ( 0) ,
var0( 0 ),
var1( 0 ),
data2var1(0),
VVSUP(false), //trending up
VVSDN(false);// trending DN
var1 = SwingIndex ;
indicator = iff (var1 <0 ,1,-1);
indicator = iff (var1 >0 ,1,-1);
//data2var1 = SwingIndex ;
data2var1 = iff (SwingIndex <0 ,1,-1);
data2var1 = iff (SwingIndex >0 ,1,-1);
if data2var1 > 0
then begin
VVSUP = true;
VVSDN = false;
end;
if data2var1 < 0
then begin
VVSUP = false;
VVSDN = true;
end;
if VVSUP then begin
if indicator crosses over 0 then buy next bar at market;
if marketposition = 1 and Indicator crosses under 0 then sell next bar at market;
end;
if VVSDN then begin
if Indicator crosses under 0 then sellshort next bar at market;
if marketposition =-1 and Indicator crosses over 0 then buytocover next bar at market;
end;
|