Hello, fellow traders/coders!
I have a basic idea about 2 sets of scripts for buy/sell with tp and sl. I tried to code them myself but never really got them working. So I was hoping someone kind enough here with experience might be able to help.
First set of buy/sell scripts will have the option to set% of balance your want to risk and how many pips it will be.(risk:reward ratio is 1:1, so if i risk 3% i gain 3%)
Example: I want to risk 5% on the next buy trade and the 5% will correspond to 10 pip tp. So i set one variable to 5 since i want to risk/gain 5% and other to 10(pip) which will mean the script automatically opens position with 10 pip tp/10pip sl and corresponding lot height to match the 5% risk/gain of max balance.
The problem I ran into when i was trying to do this on my own, was the spread, in other words even if i set sl/tp to 10 because of spread it would still never be clean +5%gain/loss because the sl/tp is modified by spread. So i was wondering if there was a way to put the spread value into the code and the script would have tp counted as the amount of pips you set beforehand, for example 10 - spread value and viceversa for stop loss where the stop loss value of 10 would have spread value added to it. Only then you really get your +5% gain/risk.
The second set of buy/sell scripts would be pretty similiar to the first one with a couple of changes to it.
Buy/sell script would each open two corresponding positions each risking a set % of account balance and much like the previous you would be able to set how many pips will the % risk/gain correspond to. Now the difference would be one of the positions would work pretty much like the previous scripts but the second position will have a trailing stop in place instead of a set tp. The trailing stop will be as big as the sl.
To summarize everything:
1.)buy script to open buy position with sl/tp with the option to set% of max balance u want to risk on the trade and how many pips that tp/sl willbe
and the script opens the position according to the two set variables with the correct lot size
spread value accounted for in the code (if i set the second variable to 10 pip, then real tp should be 10 - spread value, viceversa sl will be 10 + spread value so that we truly risk/gain 5% of our max balance)
2.)sell script pretty much the same as the above but its a sell script
3.) buy script opens two buy positions with the option to set % of max balance u want to risk on the trade and how many pips that tp/sl will be
and the script opens the position according to the two set variables with the correct lot size. first position is basically unchanged 1.) but second position wont have a set tp but a trailing stop which size corresponds with the amount of pips we set for sl/tp in the variable of the script
4.) sell script that opens two sell positions.. everything else just like 3.)
Thanks a lot for your time!
Should anything be unclear do not hesitate to reply here or contact me via message. Any kind of help is appreciated!
Best regards,
ruth
I have a basic idea about 2 sets of scripts for buy/sell with tp and sl. I tried to code them myself but never really got them working. So I was hoping someone kind enough here with experience might be able to help.
First set of buy/sell scripts will have the option to set% of balance your want to risk and how many pips it will be.(risk:reward ratio is 1:1, so if i risk 3% i gain 3%)
Example: I want to risk 5% on the next buy trade and the 5% will correspond to 10 pip tp. So i set one variable to 5 since i want to risk/gain 5% and other to 10(pip) which will mean the script automatically opens position with 10 pip tp/10pip sl and corresponding lot height to match the 5% risk/gain of max balance.
The problem I ran into when i was trying to do this on my own, was the spread, in other words even if i set sl/tp to 10 because of spread it would still never be clean +5%gain/loss because the sl/tp is modified by spread. So i was wondering if there was a way to put the spread value into the code and the script would have tp counted as the amount of pips you set beforehand, for example 10 - spread value and viceversa for stop loss where the stop loss value of 10 would have spread value added to it. Only then you really get your +5% gain/risk.
The second set of buy/sell scripts would be pretty similiar to the first one with a couple of changes to it.
Buy/sell script would each open two corresponding positions each risking a set % of account balance and much like the previous you would be able to set how many pips will the % risk/gain correspond to. Now the difference would be one of the positions would work pretty much like the previous scripts but the second position will have a trailing stop in place instead of a set tp. The trailing stop will be as big as the sl.
To summarize everything:
1.)buy script to open buy position with sl/tp with the option to set% of max balance u want to risk on the trade and how many pips that tp/sl willbe
and the script opens the position according to the two set variables with the correct lot size
spread value accounted for in the code (if i set the second variable to 10 pip, then real tp should be 10 - spread value, viceversa sl will be 10 + spread value so that we truly risk/gain 5% of our max balance)
2.)sell script pretty much the same as the above but its a sell script
3.) buy script opens two buy positions with the option to set % of max balance u want to risk on the trade and how many pips that tp/sl will be
and the script opens the position according to the two set variables with the correct lot size. first position is basically unchanged 1.) but second position wont have a set tp but a trailing stop which size corresponds with the amount of pips we set for sl/tp in the variable of the script
4.) sell script that opens two sell positions.. everything else just like 3.)
Thanks a lot for your time!
Should anything be unclear do not hesitate to reply here or contact me via message. Any kind of help is appreciated!
Best regards,
ruth