Hello All - I am currently working full time and trying to teach myself to trade. This is proving hard as there aren't enough hours in the day for studying!! When not in work I am studying for the markets, looking at training/trading videos or listening to audio training. I am getting close to starting to trade but want to develop a few strategies and backtest them. I learned a lot about technical analysis from 2 books, one is Technical Analysis of the Financial Markets by John J. Murphy and the other is Technical Analysis Explained by Martin J. Pring. Both were heavy but good! I have subscribed to TradeStation and gone through the online tutorials and read the reference materials on Easy Language and viewed the online tutorials also.
To get to the point, I would like someone to help me with the code for 2 strategies. The first is to generate a long entry when 3 conditions are met.
1. MACD has had crossover and is heading towards 0 or "north" again.
2. RSI indicates that the item is in oversold territory.
3. There is a Parabolic SAR buy confirmation.
The code I have so far for that one is:
Does anyone know how to add an exit condition into that? I have a couple I'd like to test but it's taking me ages to find code examples.
The secound strategy I'd like to create is one based on daily charts with Parabolic SAR. I'd like it to scan back at 21 days and generate a buy signal on the first long entry dot or a sell signal on the first short entry dot, i.e a long or short entry on the Parabolic reversal then a stop or sell signal on the next reversal. This strategy I would run on daily charts. I havent got as far with this one as I am having trouble with certain word entries and else statements. For the Parabolic SAR strategy exit I'd like to generate a sell signal upon the SAR reversal. Does anyone know the code I could use for that?
The code I have so far for that is just the very beginning:
Any help at all would be greatly appreciated!!!!!
Thanks - Gavin.
To get to the point, I would like someone to help me with the code for 2 strategies. The first is to generate a long entry when 3 conditions are met.
1. MACD has had crossover and is heading towards 0 or "north" again.
2. RSI indicates that the item is in oversold territory.
3. There is a Parabolic SAR buy confirmation.
The code I have so far for that one is:
PHP:
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
inputs: Price( Close ), Length( 14 ), OverSold( 30 ) ;
inputs: AfStep( 0.02 ), AfLimit( 0.2 ) ;
variables: MyMACD( 0 ), MACDAvg( 0 ), MACDDiff( 0 ) ;
variables: MyRSI( 0 ) ;
variables: oParCl( 0 ), oParOp( 0 ), oPosition( 0 ), oTransition( 0 ) ;
MyRSI = RSI( Price, Length ) ;
MyMACD = MACD( Close, FastLength, SlowLength ) ;
MACDAvg = XAverage( MyMACD, MACDLength ) ;
MACDDiff = MyMACD - MACDAvg ;
if CurrentBar > 2 and MACDDiff crosses over 0 then { CB > 2 check used to
avoid spurious cross confirmation at CB = 2 (at CB = 1, MyMACD and MACDAvg will be
the same) }
{Buy ( "MacdLE" ) next bar at market ;}
if Currentbar > 1 and MyRSI crosses over OverSold then
{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }
{Buy ( "RsiLE" ) next bar at market ;}
{ The IntrabarOrderGeneration attribute is set to false in this strategy because this
strategy is intended to place an order on a given bar that is valid for the entire
duration of the next bar. It is not intended, in this strategy, for any of the order
parameters to vary be recalculated intra-bar. }
[IntrabarOrderGeneration = false]
Value1 = ParabolicSAR( AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition ) ;
if oPosition = -1 then
Buy ( "ParLE" ) next bar at oParOp stop ;
Does anyone know how to add an exit condition into that? I have a couple I'd like to test but it's taking me ages to find code examples.
The secound strategy I'd like to create is one based on daily charts with Parabolic SAR. I'd like it to scan back at 21 days and generate a buy signal on the first long entry dot or a sell signal on the first short entry dot, i.e a long or short entry on the Parabolic reversal then a stop or sell signal on the next reversal. This strategy I would run on daily charts. I havent got as far with this one as I am having trouble with certain word entries and else statements. For the Parabolic SAR strategy exit I'd like to generate a sell signal upon the SAR reversal. Does anyone know the code I could use for that?
The code I have so far for that is just the very beginning:
PHP:
{ The IntrabarOrderGeneration attribute is set to false in this strategy because this
strategy is intended to place an order on a given bar that is valid for the entire
duration of the next bar. It is not intended, in this strategy, for any of the order
parameters to vary be recalculated intra-bar. }
[IntrabarOrderGeneration = false]
inputs: AfStep( 0.02 ), AfLimit( 0.2 ) ;
variables: oParCl( 0 ), oParOp( 0 ), oPosition( 0 ), oTransition( 0 ) ;
Value1 = ParabolicSAR( AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition ) ;
if oPosition = -1 then
Buy ( "ParLE" ) next bar at oParOp stop ;
else
if oPosition = 1 then
Sell Short ( "ParSE" ) next bar at oParOp stop ;
end;
Any help at all would be greatly appreciated!!!!!
Thanks - Gavin.