What is the function that provides a command to sell when the price has crossed back under a value after it has first over it ( for example, sell at market when rsi[bar]<70 after rsi[bar] has crossed over 70) I've searched Wiki and run a search of the site without locating it; but I've seen it somewhere. Thanks
Size:
Color:
Size:
Color:
well,using rsi for illustration,this is an example of the sequence I would like to script:
rsi[bar] crosses above 70
then, sell when rsi[bar] next crosses back under 70
( so it would appear that CrossOverBar and CrossUnderBar would need to work in succession to get there)
I believe that I saw either a function or a snippet of code that achieved this
Size:
Color:
maybe I'm over-thinking the problem.
If rsi[bar] is now 45 and the strategy wishes to sell when rsi next crosses under 70 (obviously it would have had to have gotten there first)will the CrossUnderBar function achieve this?
Size:
Color:
CrossUnderBar tells you the bar on which the DataSeries crossed under the specified value.
(If you're at 45, it's not obvious if the previous value was 71 or 0.)
Size:
Color:
QUOTE:
will the CrossUnderBar function achieve this?
No, the purpose of the function is to return the bar where the series have already crossed. The correct sequence is:
1)
rsi[bar] crosses above 70... and you're saving the bar in a variable.
2)
then, sell when rsi[bar] next crosses back under 70... you sell and reset the variable.
Actually, you don't need no extra indicators. Example:
CODE:
Please log in to see this code.
Size:
Color:
Thanks greatly. I am planning to use this (the sell part of the code), like an MFE-triggered stop based on price, except with technical levels as triggers
Size:
Color:
Size:
Color:
rptrader1 asked:
QUOTE:
I tried using the Cross Back Under System strategy.
It gives great results with VXX and VXZ securities,100% Win rate!!
It does well with the index ETFs too - like DIA, SPY.
However, with other stocks and Closed End Funds, some trades result in large losses.
I would like to introduce a stop loss statement, ex.
Position p = LastPosition;
SellAtStop( bar+1, p, p.EntryPrice * 0.95, "5% Stop Loss" );
I do not udnerstand the code well enough to know how to do this.
Can you please help?
Here you go:
CODE:
Please log in to see this code.
Size:
Color:
Thanks very much, Eugene.
Size:
Color:
Hello Eugene,
Tested the code and results are very good.
I did find one case where the stop loss did not work.
For IWM, the strategy entered a Buy on Feb 23, 2007, and exited on July 30, 2009, for a loss of 32.41%.
I noticed that on 2/22, the RSI hit a high of 70.6954 (threshhold = 70).
On 2/23, the stock was bought.
On 2/23, RSi closed at 65.28, less than the threshhold.
However, the trade was not exited until 2009.
Is it because, after the Buy sttaement, the xOver flag is not set?
Appreciate your help.
Thanks and Regards
Size:
Color:
Please note that I ran the strategy for 5 yearsdata range.
Thanks
Size:
Color:
Ravi,
For me the exit was made on 02/27/2007, 3 bars since, for a loss of -5% plus costs. Ran it on most recent 5 years of Yahoo! data in both single symbol and portfolio sim. modes.
Size:
Color:
Eugene,
The result I reported was using Fidleity data.
I ran it against Yahoo data, and I get the same resultys:
With 5 Years data:
The Buy is on 2/23/2007, and the trade is exited on 7/30/2009, for -32% loss.
While the difference between your results and mine is perplexing, and needs explanation, I would also like to focus on the code, and what it will do if:
a) The RSI crosses threshhold on Day 1
b) Buy is initiated on Day 2 at open
c) RSI Close for Day 2 is below the threshhold
Will the code initiate a sell for Day 3 at the Open?
Can you please review the code?
Also, how can we troubleshoot the difference between your result and mine?
I can provide screenshots.
Appreciate your help.
Thanks
Size:
Color:
I also found other symbols where the trade is not exited immediately after the thresshold is crossed back.
These are based on Fidelity data.
1. CEE - 1 Year Data
On 4/1, RSI crossed over the 70 threshhold, and closed at 71.58
Buy on 4/4@Open
On 4/12, RSI Crossed under the 70 threshhold, and closed at 63.98
Thye trade is still open, for a loss of 26.52%
Other examples:
2. CH - Trade open 3/25/2011, still open, -31.50% loss
3. IFN - Open 3/31/2011, still open, -31.99% loss
4. TDF - Open 4/1/2011
5. PEO - open 2/22
etc.
Appreciate your help.
Thanks
Size:
Color:
The code provided for example purposes appears fully working to me.
Try providing more info on your single-symbol IWM backtest using Yahoo! data (keep in mind that I do not work with WLP and/or Fidelity data): position sizing (Raw Profit mode or Port.Simulation), Preferences (Backtest settings, Slippage
Symbol(s), Advanced Options).
Size:
Color:
Eugene,
Position Size - $25000, raw profit Mode
Preferences -
a) Back test Settings - None checked
b) Slippage - For Equities - 0.10 Percentage slippage
c) Adv Options -
The followinga re checked - Show the Home Page on startup, Expand First Data Set in Tree on Start Up, Open teh Oredrs window when a Trade is staged or placed, Also, switch to view the orders for taht trade's account
Decimal Places - pricing - 2, Indicator - 4
Hope this helps.
Thanks
Size:
Color:
I definitely am NOT able to reproduce anything of that. You must be using wrong code (previous version) inadvertently.
Size:
Color: