Sorry for the mistakes, I'm using Google Translator.
I need to test the following setup for intraday positions in futures markets:
Mark the maximum and the minimum of the first hour
Buy the breakup of one tick of the maximum, if EMA 9 is ascending or sell the minimum of disruption if EMA 9 is descending
Exit with 500 points gain or 300, stop loss, or 16:45 at the price that is
Could help me. I can not do using Wizard
thank you very much
Size:
Color:
Here you go!
CODE:
Please log in to see this code.
Size:
Color:
That's amazing. Thanks a lot for your support.
The setup is really profitable. I hope that you friends enjoy it.
Size:
Color:
Sorry. Looking calmly saw an error. The purchase or sale should be made only 1 cent above the maxima or minima of the first hour, ie, at least in the second hour of trading, and stop the gain could be 1% and 0.5% stop loss?
grateful
Size:
Color:
I noticed a pesky typo:
CODE:
Please log in to see this code.
Should be
CODE:
Please log in to see this code.
Code above corrected.
Size:
Color:
QUOTE:
The purchase or sale should be made only 1 cent above the maxima or minima of the first hour,
The code indeed buys one 1 tick above/below the high/low. What you thought is an error, was not. You're running it on 60-minute bars, and an entry valid on the last bar was executed on first bar of the next day. Well, it's easy to filter out these entries -- see below.
QUOTE:
and stop the gain could be 1% and 0.5% stop loss?
Sure, exposed % stop/target via "Strategy Parameters".
Here's code containing these two changes:
CODE:
Please log in to see this code.
Size:
Color:
Perfect. Thanks a lot.
Size:
Color:
Sorry abuse their patience ... but I do not know programming! ... Change the position for Single position a day, it would be very difficult?
Size:
Color:
It's a simple edit... I'll add this statement:
CODE:
Please log in to see this code.
And move Position p = LastActivePosition; outside the exit logic.
Wait 1 minute and you can recopy the strategy above.
Size:
Color:
I'm not much experienced at this but it seems the ma period could go askew from the bar period; throwing results?
Size:
Color:
Not sure what do you mean, but this should be enough to stabilize the unstable EMA:
CODE:
Please log in to see this code.
Size:
Color:
Eugene.... I'm sorry for my ignorance .. I tried but it is giving error ... could put the full code? grateful
Size:
Color:
The code above is complete. Cone has already edited it for you. Just copy and paste it once again.
Size:
Color:
Sorry again. Not speaking English is very limited and very difficult. Had not understood that the code had already been moved. I tested here and may not have expressed myself right, the idea is to trade a single day with a single position. As it is a single open position but there are days when it is 3-4 trades in a single day. It would be possible to make a single trade on? Muto appreciate the patience and willingness of friends, the only thing I can offer in return is a setup quite profitable, so I already know why it uses a good time here in Brazil, Hugs
Size:
Color:
Once you copy and paste the code, make sure that you hit the Compile button. Alternatively, the Run the Strategy button compiles and then runs it.
We're sure the code will give you only one trade per day.
Size:
Color:
You were right. It's perfect. I tested here in over 200 shares in a time of 60 minutes and graphic setup proved quite profitable, pity not be possible to do so by the Wizard to be able to test variations of EMA and stop the stop loss and gain, but I think it is now much more easy to change the script, I'll try. Thankful again, without your help I would never have achieved
Size:
Color:
Seems concept primarily for 60 min bars. However the code maintains a 9 period avg while accommodating differing bar periods. This avg could change from advancing to declining pending the bar period, throwing results, could it not?
Size:
Color:
I'm trying to backtest this code for e-minis. The intraday data series begins at 12:00 AM (during overnight trading). So the code uses the 12AM - 1AM trading hour to set the High60 & Low60 values for the day. How can I change the code so that the High60 & Low60 values are set during 9:30AM - 10:30 AM.
Size:
Color:
Use GetTime(bar) when setting the first hour's range instead of this line that determines a day's first bar:
CODE:
Please log in to see this code.
You might also want to tweak the last hour:
CODE:
Please log in to see this code.
Size:
Color:
I believe I also will need to change the 'int num' setting to shift it to the bar number representing 10:30am. Does that make sense?
Size:
Color:
No.
Size:
Color:
But if I don't change 'num' won't the following code set High60 & Low60 at 1AM instead of 10:30AM?
CODE:
Please log in to see this code.
Size:
Color:
You're right, that's not enough. On second thought, the correct way is to NOT change the code at all (or you end up changing a good deal of it).
What you need is to specify the market's open time using the
Market Manager tool.
Size:
Color:
The MM isn't going to help unless sktrades wants to filter the data. I think the idea is to use the 24-hour Globex data, but set the breakout range using specified times. sk, is this correct?
Size:
Color:
Yes. I'd like to tie the High60 & Low60 for e-minis to the stock market opening hour.
I made the following change to num to align to 1st hour :
int num = 60*9/n + 30/n + (60 / n ) - 1 ; // shift for 9 1/2 hours overnight trading.
This seems to work ok now. Thanks.
Size:
Color:
This strategy is intigueing.
1. Which of the above codes is the "final" final code that corresponds to the original strategy?
2. In the 4:12pm code, is the Exit stop criteria (i.e. -- +1% or -0.5%) in "addition to" the original criteria, or is it "instead of" the original criteria?
3. If I want to use this strategy for a single Symbol during a standard trading day, which of the above codes should be used (i.e. -- which is the most comprehensive and flexible without having to change other parameters or use other Tools)? What input settings should I use?
Thanks.
Size:
Color:
1. Uploaded on the website, hence accessible through Wealth-Lab's "Open Strategy" dialog (Ctrl-O), will appear under "Breakouts".
2. Since by that time, topic starter had changed his requirements from a point-based criteria to percentages, it's "instead of".
3. The one that you have understood, thoroughly backtested, double checked that the code works as expected, and optimized to find the input settings that would work for you!
Size:
Color:
I downloaded the strategy and ran it for SPY, but the results seem odd.
My settings were: Scale = 1-min; DataRange = 1-Yr; PosSize = RawProfitFixedDollar = $10,000; MarginFactor = 1.5:1.
My results were: The Backtest Performance Report indicates 308 trades (159 Long; 149 Short). If the strategy can only trade one time per day, which is what the Entry Rules state, then this is more trades than there are trading days in one year (plus, I would presume that the Entry Trade Rules would not be "True" EVERY day, but maybe so). Average Bars Held = 195, which is a little over 3-hours per trade, which I guess is plausible. Do these results seem right to you? If not, are my input settings not appropriate for this code?
Size:
Color:
QUOTE:
If the strategy can only trade one time per day, which is what the Entry Rules state,
Where did you find it in the Strategy's code?
Where does the
Strategy Description block indicate it?
No need to answer, my questions were rhetorical. The original uploaded Strategy can trade several times a day.
One final note. Originally, the strategy was designed to trade 60-min bars. With 1-minute bars, sometimes it can delay its exit on the last bar to the first bar of the next session. I guess it has to do with how the last bar is timestamped (e.g. 16:01). Should you experience something like this, adjust the close time (to e.g. 1559) on this line:
CODE:
Please log in to see this code.
Size:
Color:
Entry rules
1.Buy at breakout of first hour's high plus one tick, if 9-period moving average is rising
2.Short at breakdown of first hour's low minus one tick, if 9-period moving average is declining
3.Take one position only during a trading session
I guess I interpeted #3 to mean that the rules would allow only one trade per day.
Size:
Color:
Thanks for the heads-up and sorry for the confusion. That was my mistake when documenting it. Of course the code does not contain such rule. Description has been fixed. You can always apply the "Max Entries Per Day" PosSizer.
Size:
Color: