Swing peak and valley value to find between signals

helo i want to find swing highest high value and swing lowest low value after buy(long) intitated tilll sell(buy exit) occurs . and vice versa when short(sell) to cover(sell exit). so purpose is to find high and low swing between your buy and short signals.
now i want to find out once buy occur and sell signals come how much high price went and how much low price went . purpose is to find swing high and low averages with each loop of buy or short to decide average of stoploss and target to expect with particular type of strategies

See How to ask a good question.

Perhaps this function would help you get started: https://www.amibroker.com/guide/afl/highestsince.html

1 Like

helo all, look forward to afl which gives highest high value when buy loop is active after buy entry before buy exit comes and lowest low value when short loop is active after short entry before short exit comes. In short i want to know max excursion of price after each buy(up side ) or sell (downside excursion) in exploration .

This Knoledge base article: http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/
contains the code that tracks highest high and uses loop.

Alternatively, if that is for exploration only, you can also track highesthigh since even using HighestSince function as was advised earlier:

Buy =.. your rules
Sell =.. your rules
Short = .. your rules
Cover = ..  your rules
Equity(1); // evaluates stops and filters out extra signals (for later exploration code)
InLongTrade = Flip( Buy, Sell ) ;
InShortTrade = Flip( Short, Cover );
Filter = InLongTrade OR InShortTrade;
AddColumn( InLongTrade , "InLongTrade " );
AddColumn( InShortTrade , "InShortTrade " );
AddColumn( HighestSince( Buy, High ), "highest since buy" );
AddColumn( LowestSince( Short, Low ), "lowest since short" );

In the above example Equity(1) (http://www.amibroker.com/f?equity) was used instead of ExRem() because it also evaluates stops (just in case you have used stops as well). But if you don't you could use ExRems as well.

1 Like

thank you sir regards!!