Back

Trying to import strategy, how to do EMA crosses based on minute data?

Hi,

I've had a strategy with EMA crosses for a while now, and I'm trying to automate my trades.

I don't have much experience in C#, though from the basic tutorials and university, I've made a little bit of progress.

I keep running into issues, though, when I try to do say...for example....a 5/10 min EMA cross. I try changing the resolution but that doesn't seem to change anything, looking for help :)!

Update Backtest








I'm trying to tweak the one used in the university tutorial, but it doesn't pass my "sanity check" persay.....doesn't seem to go off min data...

1

I've got an EMA cross that I built with my strategy template. I can get it to barely beat the market with daily data, but I have to tweak the settings to the point where I don't trust it to actually beat the market.  It seems to mostly lose money with minute data no matter what configuration I put it in. Don't forget to set the dates to a shorter time period if you are going to test it with minute data. It's draft so try and be forgiving if you find any bugs.

1


Haha yeah you don't want to be curve fitting...although judging by your profile you know that and more...

Thanks a lot, this seems a bit complex fo rme so I'm going to have to dig in :P

Perhaps these last few months have just been luck for me, I guess i'll see when I can get the backtest to fully work :)

1

I hope I'm not asking too much, but could you isolate which parts specifically deal with the custom indicator and the crossing of it? Alternatively, annotate what each part does? I'm trying to learn through the university and such, but it's all a bit overwhelming for me so far..I'd greatly appreciate it!

1

The lines you are most likely to want to modify are:

        int maPeriodFast=20; //you probably want to set this to 5
        int maPeriodSlow=180;  //you probably want to set this to 10

Resolution resolution = Resolution.Daily; //you will likely want to change Daily to Minute

SetStartDate(2012, 1, 1); //this should be a reasonable date for minutes, sometime in 2016 most likely if you don't want to wait too long for your backtest

string tickersString =.....   //I've got the whole s&p 500 in here. You probably didn't get lucky. You might want to just trade the stocks you've been trading, they might behave appropriately where EMA crosses are concerned.

where stockData.EMAFast>stockData.EMASlow //this one is further down in the Buy routine and indicates that one should buy when the EMAFast is greater than the EMASlow, you can reverse that.

if (stockData.EMAFast < stockData.EMASlow) //this one is further down in the Sell routine. It indicates that one should sell when the EMAFast is less than the EMASlow. You can reverse that.

1

Thanks!

 

I've actually been trading FX, I (and I think many others) find that it responds better to minute trading than the S&P, what lines should I delete/add (and where) to change it as such?

 

Something like this...? Where would I add this and what to remove? AddSecurity(SecurityType.Forex, "USDJPY", Resolution.Second);
1

I'm adding tickers from the tickersString in a loop. It makes it easy to deal with ticker lists. You can comment off the big long line of s&p 500 tickers and replace that line with your list of FX tickers. Then change the SecurityType to Forex in the AddSecurity line. I haven't worked with FX much so I'm not sure if you have to do anything else.

1

I replaced the tickers and changed securitytype to Forex. The build shows no errors, but when I backtest nothing happens. I think more has to be changed... if I were to put it in my own code what would be the bare minimum? I think all of your other layers are messing it up somewhere along the line :P
1

I'm not sure. I swapped in a forex symbol myself and changed the security type but got a flat line for a backtest. My template has been built with equities in mind so it simply might not be suitable for forex. If limit orders aren't supported with forex as an example then my template will be largely useless.

0

Been trying all day and i'm stumped. (I'm also new to C# though too). I just want something where I can do stuff like 5/10 min EMA crosses, preferably using seconds (300/600 second). Doesn't have to be too complex like it doesn't have to account for slippage, etc. I just need to get the base going.

I'm also not getting High-res data past Nov 1, is there a reason for this? Is recent hi-res FX a premium feature?
0

Been trying all day and i'm stumped. (I'm also new to C# though too). I just want something where I can do stuff like 5/10 min EMA crosses, preferably using seconds (300/600 second). Doesn't have to be too complex like it doesn't have to account for slippage, etc. I just need to get the base going.

I'm also not getting High-res data past Nov 1, is there a reason for this? Is recent hi-res FX a premium feature?
0

I have attached a simple FX (EURUSD) EMA cross based on the QuantConnect University example "Moving Average Cross". Did you follow it?

Could you please attach your backest for community help?

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


If you figure this out, please share with me. I'm in the same boat
0

If you figure this out, please share with me. I'm in the same boat
0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed