Hello everyone!
Since I am very bad at keeping my plan when I trade manually, I would like to have an algo that helps me with that.
Example: When I see a good setup. I want to go long and I know my Stop and Target. I write down my stoploss and target in my algon. And the algo does the rest.
After I type SL=40p/TP=80p and startded the algo I want it to take 4 contracts.
When it has 20p profit from entry, it should close 1 contract. My profit will be 20p/4contracts=5. Then my new SL will be 45p.
f the price goes in my favor to 40p, it will close 1 more contract. My profit will then be 20p/3 contracts=6.66p
Then my new SL = 51.6 From entry. and so on until the price reaches my SL or TP.
It would help me a lot.
Hello, here is a possible solution.
Once you want to enter the market then you can start the system. The best thing to do is to do it at a low timeframe so that it starts as soon as possible.
defparam cumulateorders=false
once check=1
if not onmarket and check=1 then
buy 4 contracts at market
set stop ploss 40
set target pprofit 80
endif
if onmarket and not onmarket[1] then
check=0
buyprice=tradeprice
newsl=buyprice-40*pipsize
tp1=buyprice+20*pipsize
tp2=buyprice+40*pipsize
tp3=buyprice+80*pipsize
firstlevel=0
secondlevel=0
endif
if onmarket and close > tp1 and firstlevel=0 then
firstlevel=1
sell 1 contract at market
set stop ploss 45
newsl=buyprice-45*pipsize
endif
if onmarket and close>tp2 and secondlevel=0 then
secondlevel=1
sell 1 contract at market
set stop ploss 51.6
newsl=buyprice-51.6*pipsize
endif
//graphonprice newsl coloured("red")
//graphonprice tp1 coloured("blue")
//graphonprice tp2 coloured("green")
//graphonprice tp3 coloured("orange")
Thank you very much. Exactly what I was looking for. Could you please help me with a code that can go short?
I’ve tried, but can’t get it to work.
You can manually pause the algo when needed and restart it later, but be careful with position sizes and potential conflicts. A simple button-based intervention might work for quick manual adjustments.