I wonder if there is a possibility to run a test with Moving Average (Offset).
For example:
- arithmetic moving average of the minimum of two periods, with a displacement of 1
- arithmetic moving average of the maximum of two periods, with a displacement of 1
- Logic: buy the asset when it touches the arithmetic moving average of the minimum of the last two candles (not including the current one, hence the offset); sell the asset when it touches the arithmetic moving average of the maximum of the last two candles (not including the current one, hence the offset).
- Practice: touched the minimum average is bought and sells when touching the average maximum.
I'm a beginner, I appreciate help!
Size:
Color:
"Anything's possible" Rodrigo, so the question should be "How do I..."
To move a series forward in time, i.e., access a delayed series, use the >> operator. In this case, it would be useful to show the plotted series this way, but you don't need to do this offset in the trading rules because it happens "automatically". Maybe the code will make it clear:
CODE:
Please log in to see this code.
Size:
Color:
Size:
Color:
Thank you very much Cone, that was exactly it!
Eugene,
but how could i do it using Rule-based strategies (using the ShiftedMA indicator)?
Size:
Color:
Choose it as an
Indicator parameter for conditions from the "General Indicators" group.
There's a walkthrough in post #2 (for a pretty specific case, I admit) which should show you how to use it:
Condition true today and yesterday
Size:
Color:
Eugene, thank you very much, I managed to configure the ShiftedMA, but the rule (General Indicator) to buy and sell at the exact points, I couldn't, could you help me again?
Size:
Color:
Help with what exactly?
Size:
Color:
Which General Indicator, should I use for the points to buy and sell?
- Practice: touched the minimum average is bought and sells when touching the average maximum.
Because, I didn't find one that was suitable.
Thank you for your attention!
Size:
Color:
Perhaps "Price crosses X% [0.01] below (above) indicator". But a trade would happen on the next bar unlike Cone's code in post #2.
Size:
Color:
Thank you very much Eugene, even managing to change to buy and sell, in the current bar, it was not possible to start the operation at the exact point (touched the minimum average is bought and sells when touching the maximum maximum). I used the attached rule, but I think the problem would be the "close" setting in "Limit Price" and "Price".
I really appreciate your help!
Size:
Color:
Well, Rule-based strategies have their limitations. You can use code in post #2.
Size:
Color:
It's okay, Eugene, thank you very much for your attention!
Cone, thank you again for your attention!
Thank you very much for your help!!!
Size:
Color:
You're welcome!
Size:
Color: