PureBytes Links
Trading Reference Links
|
Hello togehter,
hope this is a simple coding question but I can't get it.
I want to have a very simple system:
I want to buy half of the position if fast MA crosses over mid MA nad the
rest of the position if mid MA crosses above slow MA.
I want to sell half of position if fast crosses below and the rest if mid MA
crosses below slow MA.
But I want to reenter the position if fast MA crosses again above mid MA.
But in this code I can't get the second entry. Can anyone help me?
Thanks a lot
Laura
input: avglen1(3), avglen2(10), avglen3(50);
condition1 = average(close,avglen1) crosses above average(close,avglen2);
condition2 = average(close,avglen2) crosses above average(close,avglen3);
condition3 = average(close,avglen1) crosses below average(close,avglen2);
condition4 = average(close,avglen2) crosses below average(close,avglen3);
condition5 = condition1 and barssinceentry =2 and close <
average(close,avglen1);
if condition1 then begin buy ("1.Buy") 1 contract at close; end;
if condition2 then begin buy ("2.Buy") 1 contract at close; end;
if condition3 then exitlong ("1.Sell") 1 contract total close;
if condition4 then exitlong ("Rest Sell") all contracts at close;
if condition5 then exitlong ("Stop Sell") all contracts at close;
|