PureBytes Links
Trading Reference Links
|
You did say Monday, not first trading day. See if this does it.
==Indicator==
{Plots 1 for buys}
n:=Input("% of high to trail stop:",91,99,98);
Mon:=DayOfWeek()=1;
{Highest High Since Monday}
hhsMon:=HighestSince(1,Mon,H);
{Trail Stop Calc 1}
TScalc1:=hhsMon*n/100;
{Exit Calc 1}
exitCalc1:=L{C}<TScalc1;
BuyCalc1:=If(Mon AND
BarsSince(Ref(exitCalc1,-1))<=
BarsSince(Ref(Mon,-1)),1,0);
hhsBC1:=HighestSince(1,BuyCalc1,H);
TS:=hhsBC1*n/100;
exit:=L{C}<TS;
Buy:=If(Mon AND
BarsSince(Ref(exit,-1))<=
BarsSince(Ref(Mon,-1)),1,0);
Buy;
------------------------
==Indicator==
--{Plots Monday-only-Buy trailing stop and highest high}--
n:=Input("% of high to trail stop:",91,99,98);
Mon:=DayOfWeek()=1;
{Highest High Since Monday}
hhsMon:=HighestSince(1,Mon,H);
{Trail Stop Calc 1}
TScalc1:=hhsMon*n/100;
{Exit Calc 1}
exitCalc1:=L{C}<TScalc1;
{Buy Calc 1}
BuyCalc1:=If(Mon AND
BarsSince(Ref(exitCalc1,-1))<=
BarsSince(Ref(Mon,-1)),1,0);
hhsBC1:=HighestSince(1,BuyCalc1,H);
TS:=hhsBC1*n/100;
TS;
hhsBC1;
------------------------
======Test=========
==ENTER LONG:==
Mon:=DayOfWeek()=1;
{Highest High Since Monday}
hhsMon:=HighestSince(1,Mon,H);
{Trail Stop Calc 1}
TScalc1:=hhsMon*opt1;
{Exit Calc 1}
exitCalc1:=L<TScalc1;
BuyCalc1:=If(Mon AND
BarsSince(Ref(exitCalc1,-1))<
BarsSince(Ref(Mon,-1)),1,0);
hhsBC1:=HighestSince(1,BuyCalc1,H);
TS:=hhsBC1*opt1;
exit:=L<TS;
Buy:=If(Mon AND
BarsSince(Ref(exit,-1))<
BarsSince(Ref(Mon,-1)),1,0);
Buy;
----------------------------
-------------------------
==CLOSE LONG:==
Mon:=DayOfWeek()=1;
{Highest High Since Monday}
hhsMon:=HighestSince(1,Mon,H);
{Trail Stop Calc 1}
TScalc1:=hhsMon*opt1;
{Exit Calc 1}
exitCalc1:=L<TScalc1;
BuyCalc1:=If(Mon AND
BarsSince(Ref(exitCalc1,-1))<
BarsSince(Ref(Mon,-1)),1,0);
hhsBC1:=HighestSince(1,BuyCalc1,H);
TS:=hhsBC1*opt1;
exit:=L<TS;
exit;
|