Hello,
Lets say I've entered a long position on a MA crossover and wish to add to my position as the price increases -
1.Is it possible to express the following in wealthscript code?
Add to my position every time the price goes up by, say, 10% of the entry price, up to a maximum number of, say, 4 times.
eg. entry @ 100
add to position @ 110
add to position @ 120
etc. (maximum 2 more times)
2. Continuing on from the above, is it possible to express the following in wealthscript code?
Lets say I have a StopLoss in place of 5% below entry price, move this StopLoss up 10% every time I add to my position.
eg. entry @ 100
stop @ 95
add to position @ 110
move stop up to 105
3. Finally, would it be possible to choose the size of the position added?
eg. same position size as orignal entry
or, say, 50% of previous position size
If someone could provide the code for any of the above scenario's, I would be most grateful.
Size:
Color:
QUOTE:
3. Finally, would it be possible to choose the size of the position added?
Sorry, that's an enhancement for one of the future builds of WL5 (like 5.5 - Robert will correct me).
QUOTE:
1.Is it possible to express the following in wealthscript code?
CODE:
Please log in to see this code.
Size:
Color:
Hi,
Thanks for the code.
I'm trying to 'decipher' it and have a couple of questions.
1. Should it run as it is or would I insert the relevant sections into my strategy? - at the moment I'm getting a Runtime Error even though it's triggering buy/sell signals.
2. The code triggers an initial Buy order after every 100 bars (and exits the entire position after every 100 bars) , however, the 3 additional orders generally all seem to occur roughly within a few bars of each other - I'm not understanding what criteria is actually triggering the additional positions?
I hope I've explained my concept properly - just to recap,
eg
Entry @ 100
Add @ 110
Add @ 120
Add @ 130
Excuse my ignorance, and many thanks for your help.
Size:
Color:
1. Whenever you get an error, please post its details.
2. Oops, now I see what you mean. Here's the amended code:
CODE:
Please log in to see this code.
The code is only an example.
Size:
Color:
Hi,
Still getting the runtime error (tried to copy & paste the long message but couldn't), however, I found the following adjusted code works without errors and also gives me much better entry signals:
CODE:
Please log in to see this code.
As you will see I have changed the BuyAtLimit to BuyAtClose orders & removed the "+ 1" and "limitPrice" from within the brackets.
A couple more questions please -
1. At the moment, a buy order is created at the close of the bar where the price has gone up 10% - ideally I would want to enter at the exact price of the 10% gain. Is this possible? (I'm guessing this is what you was trying to achieve with the limit order but it wasn't working in that way)
2. Referring back to my original post (Question 2), is it posible to code the stoploss scenario described?
Thank you very much for your help this far.
Size:
Color:
Hello,
Continueing from above, I have tried to incorporate the relevant code into my strategy (simple MA crossover with stoploss) but failed miserably.
Please could you show me how its done?
CODE:
Please log in to see this code.
Size:
Color:
I got your point.
Entries are made now when the price has gone up 10%, and the trailing stop scenario has been integrated:
CODE:
Please log in to see this code.
Size:
Color:
PERFECT!
That seems to do exactly what I was after.
Eugene, thank you very much.
Size:
Color: