|
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.
|
|