Click here to Login

Trading Software Trading objects Features How-to Blog Search


                                                   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
Geometric Moving Average Indicator
Stock Analysts Recommendations
Base or Counter Currency
Business Outlook Survey

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

Related Forum Threads
comp function not working ok in 2.0.2?
Working offline
How do I use variables in Money Management Scripts?
Detachable Charts
NSE Indices - P/E, P/B & Div object

Blog Posts
Working with the formula editor
Custom Indicator: Relative Strength
Day Trading: A trading system that combines intraday and EOD data
Reducing risk and increasing return by combining several trading ...
New Ranking and Percentile Composite Functions









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 © 2012 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items