Howard
Always appreciate your replies.
Had hoped to be able to access the differing Sell values as per
Sell = whatever; // is Sell == 1 value
Applystop( StoptypeLoss, .......); // is Sell == 2 value
Applystop( StopTypeProfit, ...); // is Sell == 3 value etc
to do this but I cannot get it to work.
However I have tried your loop solution and it works well.
Thank you.
Regards
ChrisB.
Howard B wrote:
>
> Greetings --
>
> Having the price hit a stop does not set Sell to True.
>
> Run the following code as a backtest and look at the trades. Many of
> the months the exit is made at the profit target.
>
> // TestApplyStop. afl
>
> Buy = Month()!=Ref( Month(),- 1);
> ApplyStop(stopTypeP rofit,stopModePe rcent,2);
> Sell = BarsSince(Buy) >=15;
>
> Filter = 1;
> AddColumn(Buy,"Buy",1.0);
> AddColumn(Sell,"Sell",1.0);
>
>
> Run it again as a exploration. Buy is True on the first trading day
> of the month, and Sell is always True 15 days later, but is never True
> earlier than that, even when the exit was made at the profit target.
>
> So --- you probably need to write a loop to set the entry in the array
> you want to use in your Flip statement for whatever conditions you
> want it set. In your loop, test the condition that hits your stop and
> set StopHit (or whatever else you want to call it) when the price
> triggers the stop. Then, after that loop, use Flip.
>
>
>
>
> //pseudo code
> Buy = xxxx;
> ApplyStop(xxxx) ;
>
> StopHit = 0;
> for (i=0; i<BarCount; i++)
> {
> If (Close[i] >= xxx) StopHit[i] = 1;
> }
>
> InLong = Flip(Buy,StopHit) ; // or whatever
>
>
>
>
>