Click here to Login





                                                   NewPosition.IsLong working correctly?

  0

0
Russ
2010-10-07 22:34:34


Not sure if I am coding this incorrectly, if I do not understand the NewPosition.IsLong command, or if it is a bug, thought I would post it just to be safe.

Again, I am just trading one symbol with my current code. I wanted to execute both long and short trades and be 100% invested. Thus I originally planned to use the code listed below (I retyped this from memory so hopefully it is free from errors):



OnNewPosition:


if (NewPosition.IsLong == True)
{
Portfolio.UpdateCategorySettings("long", 100, 1, null);
}


if (NewPosition.IsLong == False)
{
Portfolio.UpdateCategorySettings("short", 100, 1, null);
}



This code worked when going long, I would have 100% of my equity invested in all long trades however it failed to work for any short trade executed. (I had to allow for 2 positions and this originally split my equity 50/50 between long and short trades. With this code my long trades would use 100% of my equity but my short trades would only use 50%)


I checked my outputs with the following code:

OnNewPosition:

Divers.Output(Convert.ToString(NewPosition.IsLong));


The output would return the boolean value of True anytime a new position, regardless of whether it was a short or long position. It is my understanding that NewPosition.IsLong would return a value of True if the new position is a long position and False if it was a Short position. Is this correct?


I successfully changed my script to where I do now have it working as I wish, with 100% invested on both long and short trades. I just thought it was weird the results I had with the above script.



QuantShare
2010-10-08 06:05:32

  0

Best Answer
You are right "NewPosition.IsLong" always returns True.
I have already fixed it. The new version will be available today or tomorrow.

Thanks for reporting this.



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
Analyst comments
Advanced Quotes and Custom Databases Function
Convert Seconds to Trading Bars
Penny Stock News Picks
Geometric Moving Average Indicator

How-to Lessons
How to speed up watchlist and screener plug-ins when working with...
How to install the previous version of QuantShare
How to copy and paste drawing tools
How to hide a trading indicator from a particular time frame
How to display two stocks on the same chart

Related Forum Threads
conditional color not working
Intraday data download is not working
Access intraday data while working on daily chart
Anyone have a working cointegration test, like Johansen?
comp function not working ok in 2.0.2?

Blog Posts
Working with the formula editor
QuantShare Trading Software: New Features in the 3.6.0 Version
Using Average True Range to Measure Intraday Volatility
QuantShare Programming Language Tutorial
How to use QuantShare screener to trade penny stocks









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.