How do i code a Sell signal based on a Trail on a moving average indicator?
- The logic is - if the moving avg drops by 10% off its nearest High, issue a Sell signal?
- A variation would be to make the X% a function of the ATR of the moving avg indicator.
Are there indicators/functions that can help with trailing the High?
I'm using an indicator vs price to smoothen the price trend and avoid whipsaws
thanks
Kiran
Size:
Color:
Take ExitAtTrailingStop and SellAtTrailingStop in the QuickRef as an example. They illustrate it with a similar concept: exiting on a Chandelier exit (X ATRs from a nearby highest high). Pass your moving average to the Highest.Series instead of the Bars.High by default.
Size:
Color:
The challenge is that even though the exit level represents the exit level of the Moving Average (not the price level), the function ExitAtTrailingStop function will compare the Level to the nearest highest Price and exit based on comparing current Price (which is noisy with intra-day swings) not the Current moving average (see sample code given in Quick Ref Guide).
How do i make the ExitAtTrailingStop code compare the Level to the nearest Highest Moving Average peak and to the current Moving Average to generate a close signal?
Size:
Color:
There appears to be a misconception. The function ExitAtTrailingStop function will compare the level with whatever you instruct it to compare from a preceding "if" condition, when programming your rules in code.
CODE:
Please log in to see this code.
Size:
Color:
In the code above, the hh (Highest point) is calculated with a fixed lookback of 5 bars.
How can i write code so it returns the highest point since the position was entered? The trailing stop should be using this highest point.
Pl advise
thanks
Kiran
Size:
Color:
CODE:
Please log in to see this code.
You'll find description of EntryBar in the QuickRef.
Size:
Color: