So I’m pretty new to this whole thing, what I wanted to do was open a new position every time a price goes down. I assume that I have to compare the latest price to the previous one but I could be wrong. Also in doing it this way would there be any restrictions on what timeframes it would work or would it allow me to do it from 1 second all the way through to the day? I have had a play around but I’m not getting anywhere, any pointers would be appreciated.
The below code place a pending limit order x points (step) below the last opened price. It will accumulate orders for ever, there is no coded exit, you’ll have to add your own.
defparam cumulateorders=true
step = 20
if rsi[14] crosses over 50 then
buy 1 contract at market
buy 1 contract at tradeprice-step*pointsize limit
endif
if longonmarket then
buy 1 contract at tradeprice-step*pointsize limit
endif
You can use any TF, at your choice, since, say, a 5% drop is such on a Daily TF and 1-second TF.
There you go:
Defparam CumulateOrders = True
Once MyPrice = close //First price to start
Once PerCent = 5 //5% drop
If Not OnMarket and OnMarket[1] then
MyPrice = close
Endif
If close <= (MyPrice * (1 - (PerCent / 100))) then
MyPrice = close
Buy 1 contract at Market
Set Stop pLoss 100 //100-pip SL
Set Target pProfit 200 //200-pip TP
Endif
AhAhAh…. two is always better than one!
Thanks guys I’ll give them a spin and let you know how I get on
It seems to work close to how I would like in back test but there are some results that don’t make sense to me.
However as soon as I try it out on a demo account I keep getting an error message about stop limits despite removing all of the stops. I don’t know if I am over or underthinking the code or I just don’t know wtf I am doing.
I basically want it to ignore market conditions
and then execute the following flow
IF //Price drops 1 Point ---(either of these should work)--- IF Current price < previous price// THEN
buy x Contract at Market
SET TARGET pPROFIT x
ENDIF
I don’t want it to close any positions unless it hits that profit target or I manually go in and close the.
Also is there a way to remove the number of trades that can be made per day or increase it over 1000?
Brokers have minimum distances and it is not possible to place orders under these minimum distances. Nothing can be done to change this.
Brokers also have a maximum number of trades that can be placed in a day – this is to save you from yourself and to save them from having to cope with high frequency trading. Nothing can be done to change this.
Unless you have a bank roll the size of a hedge funds then I would avoid your trading idea as one day you will buy your first entry at the top just before a market crash and then continue buying all the way to the bottom only stopping when all your money runs out.
Note: Please follow the forum rules and:
- Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Your post has been edited.
I have already taken into account the possibility of that happening and will be limiting the amount of open contracts at any one time
As for the other issues I have duplicated the system manually it’s just an absolute pain doing it that way hence the automation
I have already taken into account the possibility of that happening
The possibility of it happening is 100% – and the only way to take that into account is to have a bank account that you don’t mind emptying… or to be trading using other peoples money.
They call it ‘catching a falling knife’ for a very good reason.
Have you even considered how much margin is required to trade in such a way? You will get a margin call (or lots of margin calls!) long before your account is empty and your trades will be closed out one by one at a loss by the broker.
Got to risk it for the biscuit mate and I get where your coming from however the most I would be loosing using my idea would be 70k which I am prepared to dust a couple of times and it would only his that point if the entire market went to zero, which is an absolutely catastrophic event and I’m sure the least of anyone’s problems will be the money at that point. I’m certainly not going into this blind and I will be running a lot of tests before I actually put my money on the line.
If you are insistent on giving money away then this discussion that I started a while back might be of interest to you:
Catching a falling knife ideas
perfect that’s exactly the help what I needed to read cheers for that