I am trying create an AFL in which we will go Long when current day close is greater than last 20days low candles's high value.
The stop loss going to be 20day low candles low.
I am able to find last 20 day low candles low using the following
twentyDayLowPrice = Ref(LLV(Low,period), -1) ;
Can somebody help me to find High value of the twenty day low candle .
This is the logic what i am trying to put
Buy = Cross(Close,20DayCandlesHighValue)
BuyStopLoss = twentyDayLowPrice
@rajuptb , you are probably looking for the "valuewhen" function.
something like valuewhen(llv( 20,c), H, 1);
nsm51
June 6, 2019, 12:46pm
4
I think this topic can be helpful to you.
While studying, i bookmark this one to use and is similar to your case for coding the stop loss.
Helo , guys
I want to code AFl with following requirements
Its an example
Buy=c>ref(hhv(h,20),-1);
Sell=c<ref(llv(l,20),-1);
Now I want to code low of buy entry bar as stoploss (how to do it?) and will continue long till sell conditions are met.
If I get stoploss (price going below low of entry bar) .my next trade will be short trade when I get sell signal.
Once short is initiated again stoploss is high of short entry bar , and will continue to ride trend till buy conditions are met
…
another one also i can search
Hi -
I am not sure why the following code is not triggering ApplyStop() function for max stop loss. I appreciate much any suggestions.
rsiLength = 2;
buySignal = Cross(RSI(rsiLength), 10);
buyLimitPrice = ValueWhen(buySignal, Close) - (0.1 * ATR(10));
Buy = Ref(buySignal, -1);
Buy = Hold(Buy,2) AND (Low < buyLimitPrice); //Buy = Buy AND (Low < buyLimitPrice);
BuyPrice = Min(Open, buyLimitPrice);
sellSignal = Cross(90, RSI(rsiLength));
Sell = sellSignal;
Buy = ExRem(Buy, Sell);
Sell = Ex…
@snoopy.pa30
HighOfLowest = Ref(H, -LLVBars(L, period));
2 Likes
Thank you. This one worked