Hi guys, Iím quite new to programming and need some help for a system Iím trying to code.
I want the TS to buy at MovingAverage Ė X points (first trade).
Then buy every time the price drops Y points following a ďgrid styleĒ.
X = 40
Y = 30
Moving average @ 240
First buy limit @ 200
Second buy limit @ 170
Third buy limit @ 140
4th buy limit @ 110
5th buy limit @ 80
And close all open positions once the price touch the MovingAverage.
This is the code I tried to write:
The problems I find are:
1) The levels arenít always respected (honestly I canít understand why sometime the levels are correct and sometime not)
2) In this way (next bar limit) the orders are executed no more than once per bar, even if a single bar drop more than Y points (that would mean more than a single trade per bar)
Can you guys please help me with this code?
Thank you in advance
hi mwtzzz, I think I can exclude that the different levels the TS buys are due to better price fills because it happens for example that the TS buys few candles after the candle that closed under the theoretical price to buy..
example: the TS bought at 130, next theoretical price to buy is 100
it happens that there are candles that close at let's say 95 and the TS still don't buys the next contract...