need coding for swing trading ea

saambasp

Member
Hi sd,
i know indicator trading is bit dissappointing.but we have them only to identify market strength.
Ok there is old comment in wall street that is
' buy in strong market and sell in weak market'
defferent traders use defferent strtegies for this,i have my manual trading simple strategy
here it is:
Indicators:1.sma
2.cci
time frame:h1 or above
entry : Buy-look for price above 200 sma then look for cci crosing zero line frome below
sell-look for price below 200sma then look for cci crossing zero line frome below
exit :1.cci opposite closing
2.stoploss 10 pips below 200 sma
addition : 1.in swing trading we have to use break even that if price move 70 pips in our way then our confirm profit is 20 pip like that
2.when price moves 300 pips in our way then close half of the lot size

------------------------------------------------------------
iam attaching some screen shots
 

Attachments

  • swing trading 1.jpg
    swing trading 1.jpg
    27.3 KB · Views: 0
  • swing trading 2.jpg
    swing trading 2.jpg
    27.2 KB · Views: 0

maximo

Member
Hi saambasp,

I like the simplicity of this strategy and it should work well. Trading in the direction of the longer trend and buying-selling after a pullback using the CCI.

I will code this EA for you if I may?

Just a couple of questions.

When using the 200 sma for market strength, how do you want it to be identified?

I have 3 suggestions, you may have another:
1. The Slope of the 200 average is sloping by a certain amount or
2. A certain number of bars closing below the 200 average for sell or above for buy.
3. Lowest Low or Highest High in certain number of periods.
4. A combination of more than 1 of the above rules.

Then the EA can look for a pullback of CCI and trade in direction of 200ema.

I can add that initial stop 10 pips from 200ema and then breakeven and profit targets :D
 

saambasp

Member
Hi saambasp,

I like the simplicity of this strategy and it should work well. Trading in the direction of the longer trend and buying-selling after a pullback using the CCI.

I will code this EA for you if I may?

Just a couple of questions.

When using the 200 sma for market strength, how do you want it to be identified?

I have 3 suggestions, you may have another:
1. The Slope of the 200 average is sloping by a certain amount or
2. A certain number of bars closing below the 200 average for sell or above for buy.
3. Lowest Low or Highest High in certain number of periods.
4. A combination of more than 1 of the above rules.

Then the EA can look for a pullback of CCI and trade in direction of 200ema.

I can add that initial stop 10 pips from 200ema and then breakeven and profit targets :D

HI MAXIMO,
it is good idea to look moving average slope for more perfection.for this we can use moving average angle indicator or other good ones.
i think in this stratege entry is good[we have trend as a friend] but as usual exit is bit dofficult to comramise .iam working on some best exit strategies.most of swing trading eas fail in exit identification.ok i mentioned 2 options in my forst post ,we look into them first later we can improve better.
thank you for working on this
 

saambasp

Member
hi max,
thank you for working on this strategy. if you have any good techniques to improve exit strategy,better insert into this.
thank you
 

maximo

Member
Hiya,

I've done a basic outline-framework for the EA. You can adjust the default parameters to see what works.

There's a few good exit strategies, we can add them when the basics are sorted. Just SL,TP,BreakEven and Trailing for the moment.
Oh I just remembered the initial stop of 10 pips above 200 sma, does that mean SL= setting will not be used?

The slope of the 200 sma is measured over 3 hourly bars, needs tweeking.

Arrows will be left where signal was, can add alerts?

Going to be busy for the next 2 days, but I'll try and find time to add bits.

Cheers!
 

saambasp

Member
Hiya,

I've done a basic outline-framework for the EA. You can adjust the default parameters to see what works.

There's a few good exit strategies, we can add them when the basics are sorted. Just SL,TP,BreakEven and Trailing for the moment.
Oh I just remembered the initial stop of 10 pips above 200 sma, does that mean SL= setting will not be used?

The slope of the 200 sma is measured over 3 hourly bars, needs tweeking.

Arrows will be left where signal was, can add alerts?

Going to be busy for the next 2 days, but I'll try and find time to add bits.

Cheers!
HI MAX,
thank you for working on this.as i said entry is good almost for every entry we atleast getting 50 pips.i seen in back test.out line frame work ok
.exit cci opposite closing not working.
thank you
 

saambasp

Member
Some back tests

Some back tests

HI MAX,
i tried some optimised back test .i think iit is worth to improve .if we can made some changes in exit strategy it is good
 

Attachments

  • scalping settings.jpg
    scalping settings.jpg
    17.2 KB · Views: 0
  • trend settings.jpg
    trend settings.jpg
    17 KB · Views: 0

maximo

Member
Hi Saam,

I added 2 exit strategies. The initial 10 pips from the trend SMA and a HiLo one. Actually the 2nd exit is best explained with the PriceChannel indicator included in the zip. Both exits are optional.

Setting HiLo_stop = True; it will exit on a 5th Lower Low bar in an uptrend (Buy) or a 5th Higher Higher in a downtrend (Sell). The price channel indicator will show this if set on 5. It acts more like a tighter trailing stop, but it can be set to any value. 5 would be more for scalping exit. A larger value like 50 looks to be better for trending.

Split take profit may work well with a similar idea. Like exit half at a 5th higher high for buy and the other half exit at a 10th higher high. Don't know how to code this yet, but there's a demark indicator that counts higher highs and lower lows.

There's another forward looking take profit idea. It would set a 2 bar trailing stop if the price moves 6 atr into profit from entry.

Good Testing!
 
F

fifi

Greetings to you
Has one of his own experience
I wish to give us the results and settings Successful
 

saambasp

Member
Hi Saam,

I added 2 exit strategies. The initial 10 pips from the trend SMA and a HiLo one. Actually the 2nd exit is best explained with the PriceChannel indicator included in the zip. Both exits are optional.

Setting HiLo_stop = True; it will exit on a 5th Lower Low bar in an uptrend (Buy) or a 5th Higher Higher in a downtrend (Sell). The price channel indicator will show this if set on 5. It acts more like a tighter trailing stop, but it can be set to any value. 5 would be more for scalping exit. A larger value like 50 looks to be better for trending.

Split take profit may work well with a similar idea. Like exit half at a 5th higher high for buy and the other half exit at a 10th higher high. Don't know how to code this yet, but there's a demark indicator that counts higher highs and lower lows.

There's another forward looking take profit idea. It would set a 2 bar trailing stop if the price moves 6 atr into profit from entry.

Good Testing!

hi max,
after adding price channel stop,there is a problem in taking new orders or closing orders.when back testin,it continuosly hitting 3 usd loss and made zero,may be there is small error or i may be wrong somewhere.checking this
thank you

MS R
 

maximo

Member
Channel stop only begins working when a trade has been opened, so it cannot be from this feature. Perhaps it's because the market is currently closed and the spread in MT4 backtester is bad. Test when market is open.
 

saambasp

Member
You must be registered for see images

hi maximo,
thank for your work in this ea
can you make stoploss as swing low /high with riskreward ratio 1:1 or 1:2.
for example ea takes a buy entry at 1.3960 there the swing low is 1.3890 so our stoploss is 70 pips ,the in 1:1 risk reward our take profit is 1.4030.
in 1:2 risk reward ratio our take profit is 1.4100.
please make risk reward ratio as input option

thankyou
 

maximo

Member
I'm not sure that is such a good idea saambasp. As you can see the trades on the chart have made 3:1 risk reward. Why would you not want that extra third more profit? :D

That was the idea for introducing the High/Low exit with option to switch off exit on big_MA. In the pic I post you can see the initial stoploss will be the same as introducing a new option, but the profit will be often larger than 2:1
It's possible to make what you say. I just dont see the need for an early exit in a trend following strategy.
 

Attachments

  • SwingTraderGOLD.jpg
    SwingTraderGOLD.jpg
    16.2 KB · Views: 0

saambasp

Member
yes you are right maximo,
if you keep it as an option to use riskreward with true/false.we can use it as scalping ea.now the ea is perfect for trend trading,the same if we want to use as scalping we can insert rr into the ea input option it will be good.
and another thing price channel stop not working correctly to me,iam using without price channel stop ea
thank you for your work
 

maximo

Member
Hiya,

Here's an update. Fixed a couple of things. Bug fix for HiLo_Stop short, was Bid instead of Ask. Slope angle improvement using MathPow for charts with less digits like Gold/Jpy. Display update for MA size being used.

I will add RiskReward option next. It will simply have a value like 10.0 as default. If set smaller it will exit at that ratio of risk to reward. That value will be multiplied by the HiLo_Stop price minus the OpenOrderPrice(). = Risk. Then giving the exit price from the RiskReward setting. Will set the exit price as a global variable incase of disconnection, so it cannot forget our exit price.
 

maximo

Member
Hiya,

Had time to make the additions for the EA today.

RiskReward setting will work if TakeProfit = 0 and/or StopLoss = 0
Otherwise TakeProfit and StopLoss will be according to setting.

The RiskReward is calculated from the HiLo_stop channel setting,
even when HiLo_stop is set to false it will calculate from this.

The StopLoss, TakeProfit, Breakeven, Trailing are now in points if
on gold or indices.

Number of bars above or below the big_MA is now a setting called
Xcloses. Default is now 2 bars, was 10 bars in previous versions.
Also the exact number of current bars is shown in display.

Happy Trading!
 

grood

Member
Here is my optimized setting, tickdata backtest for 2010 attached. It has some drawdowns, but overall it looks very good.

Would it be possible to add MM to the EA?
 

Attachments

  • StrategyTester.jpg
    StrategyTester.jpg
    18.2 KB · Views: 0

grood

Member
Hi maximo,

something seems wrong with the MM function, I start e.g. with 100k$, first two trades are 2 lots, after that I only get ordersend error 131. Minimum lotsize for the mt4 I am testing with is 0.1, then increase by 0.01 lots.
 

saambasp

Member
HI MAX.,
thankyou for working on this.it is better if you add opposite close option and opposite trade option in the input variables as true or false.it would give more flexiblity to use this EA.
thnkyou
 

maximo

Member
Thanks guys!

I'll add some code to check minimum lotsize as mine is .01 and didn't worry about checking for .1 lot brokers, missed that hihi




[edit] ok had some time to fix the lots
 

Aurix Exchange
Top