Hallo,
I am not a programmer but i do my best.
Can anyone help me with this staff. I just want test only a single Symbol. I know, i can create a DataSet with one single Symbol. But i want test different Symbols with different Price Action.
CODE:
Please log in to see this code.
Thanks.
Size:
Color:
Hi,
What do you mean by testing different symbols with different price action? What do different symbols have to do with testing on single symbol then?
Please clarify your task in plain English and we'll find a solution.
Size:
Color:
Hi,
What I mean is this:
I want to buy for example 10 different stocks (AAPL, XOM and so on). And I want to buy each one at a certain price. The prices are different. For example XOM at $ 50, AAPL $ 100 and so on. I hope it is more understandable now - i am working on it.
Size:
Color:
You naturally buy each symbol at a different price, don't you? But what is the logic behind buying XOM at $50 etc in your example? Let's lay down your cards. I'd like to understand your objective rather than to just show a sample code.
Size:
Color:
The logic is simple as it is.
I look at the chart for the last 5-15 years and after that, i will set a Price lower Limit. This means, if the Price fall under the Limit i will buy the stock. And i will sold the stock at a certain Price. I will set this individuell. I don't want read every day the chart of a certain stock, i would like to automate this. Every day i want looking for interesting stocks, and if i finded one, i want extend the code with this new stock and set a Price lower Limit + Price highest Limit. This is more a fundamental Strategy.
Size:
Color:
It's getting clearer. At some point it occurred to me that you might be thinking about
backtesting historical trades.
So you're saying, "
if the Price fall under the Limit i will buy the stock. And i will sold the stock at a certain Price." Assuming you enter
and exit at certain prices, create a text file called AAPL.csv (same for XOM with its own prices etc.) at
C:\temp with this contents:
CODE:
Please log in to see this code.
Below is a quick and dirty parser (no error handling, no bells & whistles):
CODE:
Please log in to see this code.
Size:
Color:
Thanks Eugene.
I do not know what I'm doing wrong with the exit conditions. For Example, Close APPL 30.04.2019: 200.67
this my values to test the exit conditions:
CODE:
Please log in to see this code.
And the result is: See Attachment.
I think i should get a sell Alert!
Can anyone help me.
CODE:
Please log in to see this code.
Size:
Color:
Size:
Color:
Hi Eugene,
cvs. is pretty cool stuff.
It seems that I need a time Priority! And there is no other way?
I have tried using AtMarket - it seems the same "operate on the last bar".
Size:
Color:
Hi Damir,
The script is made to work on the
last bar only. For this reason it cannot be used to exit a position using any order as it cannot keep track of it. Its "memory" spans just the last bar, "forgetting" about the rest.
For auto-trading you might be interested in RiskStopLevel and AutoProfitLevel. This requires auto-trading enabled (either Paper Trading or a 3rd party broker provider). More detail in the Help menu > Preferences > Trading >
Allow Same Bar Exits for Auto-Trading. Check out Cone's detailed explanation in this thread:
Same Bar Exit, post #6
Size:
Color:
Thanks Eugene,
i will check this but honestly it is enough for me mechanically.
Size:
Color:
Anyway, a time-based Priority wouldn't help your task since it's not about backtesting.
Size:
Color:
i am seeing the forest for the trees - and what would help?
Size:
Color:
For starters, try to read and understand Cone's explanation. I can't say any better.
Size:
Color:
Thanks.
Size:
Color:
You're welcome.
Size:
Color:
Hi,
i am not a programmer but i do my best. Can someone give me a hint - something is mixed up.
I am getting 4 alerts although the Entry and the Exit Price is above the Close Price. See Attachments.
I am getting 4 alerts. Two Buys, two Shorts. Although the Entry Price is above the close price and the Exit Price above the Close Price. See Attachments.
QUOTE:
AAPL 205;230, ABT 80;110
CODE:
Please log in to see this code.
Size:
Color:
Look, it's not possible to tell whichever of your two limit Alerts gets executed on the next bar. And since the Position is still null the control falls to the short entry order. Therefore both are staged. This is not backtesting.
Size:
Color:
I tried to follow the instructions from Cone Post#6 Same Bar Exit.
It seems that my RiskStopLevel are useless. Maybe someone is here who can help me and solve the task? Until then i try it further.
greetings
damir
Size:
Color:
Don't complicate it for now with your same bar long/short entries.
Take version from post #7, pay more attention to my reply in post #8 and #10 (this is crucial and still
not fixed in your code), add RiskStopLevel and/or an AutoProfitLevel. At the risk of repeating, there is no "memory" of signals as you've eliminated it yourself:
QUOTE:
The script is made to work on the last bar only. For this reason it cannot be used to exit a position using any order as it cannot keep track of it. Its "memory" spans just the last bar, "forgetting" about the rest.
I repeated it twice and your code in #17 still persists in the error:
CODE:
Please log in to see this code.
Size:
Color:
Ih Eugene, i cannot use for-loop on the last bar! Because the script is made on the last bar.
The box is activated.
QUOTE:
Help menu > Preferences > Trading > Allow Same Bar Exits for Auto-Trading.
I have read the post x-times but I will not be smarter.
This one also works not correctly.
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
Because the script is made on the last bar.
Sadly we're going in circles. :(
If the strategy's purpose is to trade on the last bar only i.e. "from Bars.Count-1 to Bars.Count-1" then it
cannot establish a Position. Or in other words you've made a screener out of it. You can develop better understanding of the concept if you read the WealthScript Programming Guide:
Techniques >
Creating a ScreenerProgramming Trading Strategies >
Trading LoopOne bar is not enough to create an entry alert (at
bar), record the trade for
bar+1, and then issue an exit signal (on what essentially is "
bar+2").
QUOTE:
This one also works not correctly.
Because the code above does not make sense. If you take a minute of your time to review the QuickRef for RiskStopLevel and AutoProfitLevel, you'd notice that you're overlooking some key points:
Prior to issuing the BuyAt*, you should set RiskStopLevel ... as the initial stop level for the long Position.
...
Once a RiskStopLevel is established for a Position, do not change it. ...Reassigning its value after the Position is established is effectively a peeking error.It's all documented and exemplified. Hope this is clear as I've got nothing else to comment on this.
Size:
Color:
Thanks Eugene.
Size:
Color: