時間ではなくバー単位で範囲を定義する
12件の返信
Good day everyone,
I would like to set a strategy that is range based to enter a trade. I see in EA wizard where ranges is basically based on start time and end time. However I would like to setup range that is based on number or bars instead.
For example: to enter a sell order if EMA has a certain value for X bars(or X shifts if you please).
So If I want my expert advisor to enter a sell market order when the value of EMA for the past 10 bars is less than that of the current EMA value (shift 0), I have no idea how to go about it. Instead I have to use this long tedious process:
もし
EMA (1) < EMA (0)
そして
EMA(2) < EMA (0)
そして
EMA(3) < EMA (0)
そして
EMA(4) < EMA (0)
そして
EMA(5) < EMA(0) ……… and so on.
You can imagine how long and tedious this would be if i were to use larger periods, like 20 or 30 bars, rather than having one strategy that says ‘last 20 EMA values less than current EMA value’.
I hope you understand what I’m trying o explain. Please Help
ありがとう
ディーン
0
Hi again Threshold.
Where is this ‘counter’ created? Is it written in SQ EA wizard?
0
Yes, you define the counter as a new variable
0
Forgive me I don’t know anything about coding. When defining the counter does it matter how I name it or does it have to be in the format ‘abcdefCounter’ with counter at the end?
0
The name does not matter. You just use this variable to store a calculated value
0
Hope I’m not bothering you too much. I’ll give you a specific example to help me.
I want to set up a strategy where SQ will enter a long market order once the following conditions are met:
1. EMA has been above SMA for the past 20 bars and
2. SMA (1) crosses above EMA(1)
Its very hard to put in EMA above SMA individually for 20 bars plus I can’t optimize the number of historical bars( for eg if i ant to change it to 15 or 50 historical bars)
またありがとうございます
ディーン
0
0
Sorry the file didn’t attach in the previous thread
0
こんにちは,
you don’t need to “hard-code” all the bars. Thats what is a counter for. I will create an example for this and upload here
0
Thank you. I am looking forward to it.
0
こんにちは,
find the example attached. Both EMA and SMA have the same period setting
0
12件の返信を表示中 - 1 - 12件目 (全12件中)