Click here to Login





                                                   Random variable

  0

0
umair
2013-04-16 23:57:01


Hi I want to create a logic where a random variable is applied to an indicator

a= indicator1;
b= random(0,100);
c= a+b;

when back testing this, how can I make the B variable random for each and every trade instead of staying constant for all trades.

for example, on day 1, there are 10 different symbols. each have their unique indicator1 value. i want B to be unique and random for each one of the symbols

day 1=

stock A random value = 1
stock B random value = 4
stock C random value = 2
stock D random value = 99
etc

day 2=

stock A random value = 50
stock B random value = 30
stock C random value = 6
stock D random value = 1
etc

Thank you




QuantShare
2013-04-17 12:27:10

  0

Here is the random indicator you are looking for:
Random Value for Each Trading Bar





Random Value for Each Trading Bar (by QuantShare, uploaded several months ago)
No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads Notes Report an item

umair
2013-04-23 22:20:34

  0

The above indicator is not what I am looking for. It's similar to what I am looking for. The above indicator assigns a random variable to EACH NEW BAR. I just want it to assign a random variable ONCE to each new stock. So for example, if I have 10 stocks, I want each of the 10 stocks to have their own random variable. The default random indicator gives one random item and assigns the same item to all stocks. The randomvalues indicator assigns different random items to each stock but does it for every single bar. I just want it to do it at the beginning of the day.


umair
2013-04-23 22:21:11

  0

Also, any way to get random values that are not whole numbers?
random(0,10) only gives whole numbers. what happened to 1.19 etc..



QuantShare
2013-04-24 10:28:49

  0

Create a custom indicator (Tools -> Create Functions) and 2 parameters (min and max):

Random rand = new Random();
int value = rand.Next((int)min[0], (int)max[0]);
result.Assign(value);



To get random values that are not whole numbers, you can use for example: random(0, 1000) / 100




No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Random Value for Each Trading Bar
Strategy Optimization on Random in-sample and out-of-sample Perio...
Random Walk Index
Set Global Variable
Random Bar Value

How-to Lessons
How to automatically start a downloader every few minutes?
How to detect stocks trading near all time highs
How to calculate the average of a time series using the money man...
How to get trading orders from a portfolio programmatically
How to plot two different time frames in the same chart

Related Forum Threads
Best practices for using a Global Variable
Date variable not showing up in Debug
Set Global Variable Between Strategy and AMM
how do i create Random indices at Binary.com to this software
Plot text and variable in the same line

Blog Posts
Example of a trading system implemented in QuantShare Software
Automatically create historical quotes charts
Troubleshooting a Trading System
Backtesting Your Trading Systems: Symbol Segmentation
Trading System: Buy stocks with the highest Sharpe ratio









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.