Good evening!
How do I express the following in a script for buying and selling stocks;
1. “Only selling when minimum profit % achieved”. I thought it would be SET TARGET %PROFIT, but when I simulate it does not matter if I insert that function.
2. “That I spend a certain % of my Cash when I buy. I thought it would be “BUY 96% CASH ROUNDEDDOWN AT MARKET “, but I get error in code.
Thanks in advance!
Björn
%PROFIT is in price percentage, not in percentage of your account. ProOrder has no way to know how much cash you have in your wallet if you not tell him first in a variable for instance.
You’ll have to make your own calculation of how much is 1% of price for the bought shares and then make a simple rule of 3 to set the target.
You can calculate your money balance this way:
// wallet is the amount of money of your account when you launch the strategy
// the first time + the profit generated by the strategy currently running
wallet = 10000 + STRATEGYPROFIT
Than you very much for your prompt reply, even on a Sunday! Truly appreciated! Also a big thank you for a fantastic software and for all the opened code with different indicators, very helpful!!
- My wish of creating a setting with a minimum of profit when selling the stocks is basically that do not want to sell with loss. Of course everyones dream, but I rather hold to the stock than selling it with loss. My previous script settings in another stock robot software was the following:
//Mininum profit 1%
min_profit:=1.010
profit=gt(c,mult(min_profit,
lasttrade(b,p)))
2. In the same software I could set different in data variables for a certain stock, such as “stake”, for example -97 that would instruct the software to buy that certain stock with 97% of my money balance. That was very helpful as it enabled you to reinvest automatically the profits. Do note that it was in the settings of the software, not in the buy/sell script.
Thanks for your time!