NexusFi: Find Your Edge


Home Menu

 





How to replace Marketposition?


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one alko with 5 posts (0 thanks)
    2. looks_two kevinkdog with 4 posts (0 thanks)
    3. looks_3 garyfritz with 1 posts (1 thanks)
    4. looks_4 jdtrujillo1015 with 1 posts (0 thanks)
    1. trending_up 4,554 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 11 posts
    2. attach_file 2 attachments




 
Search this Thread

How to replace Marketposition?

  #1 (permalink)
jdtrujillo1015
Medellin Colombia
 
Posts: 7 since Jul 2012
Thanks Given: 0
Thanks Received: 0

Some easy language functions say: "This function can only be used in the evaluation of strategies." So I'm wondering how this functions can be replaced when the system start to work in a demo or in real money, specially the function marketposition.

Thanks.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Are there any eval firms that allow you to sink to your …
Traders Hideout
Build trailing stop for micro index(s)
Psychology and Money Management
Futures True Range Report
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
  #2 (permalink)
garyfritz
Fort Collins, CO, United States
 
Posts: 2 since Oct 2012
Thanks Given: 0
Thanks Received: 1

MarketPosition works on real or demo accounts, but only in strategies.

If you want the MarketPosition functionality in an indicator, use I_MarketPosition.

Reply With Quote
Thanked by:
  #3 (permalink)
 alko 
San Diego, USA
 
Experience: Intermediate
Platform: MC
Trading: All
Posts: 48 since Aug 2016
Thanks Given: 7
Thanks Received: 14



garyfritz View Post
MarketPosition works on real or demo accounts, but only in strategies.

If you want the MarketPosition functionality in an indicator, use I_MarketPosition.


marketposition function does not work the same in LIVE trading as in backtesting.

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


alko View Post
marketposition function does not work the same in LIVE trading as in backtesting.

alko,

would you mind showing an example of the differences you are seeing and the "marketpostion function" that you are referring to?

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #5 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


alko View Post
marketposition function does not work the same in LIVE trading as in backtesting.

Can you explain?

Follow me on Twitter Reply With Quote
  #6 (permalink)
 alko 
San Diego, USA
 
Experience: Intermediate
Platform: MC
Trading: All
Posts: 48 since Aug 2016
Thanks Given: 7
Thanks Received: 14

what i found is the following:
say you have a position oped today and you want to close it next day at the open (use daily bars), then in a backtest i used the following line to do so:

if marketposition <> 0 then begin
buy next bar open;
sell next bar open;
end;

In live trading for some reason, this does not work and close of the position is not executed (even order are not created). May be i am doing smth wrong, not sure.

Reply With Quote
  #7 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


alko View Post
what i found is the following:
say you have a position oped today and you want to close it next day at the open (use daily bars), then in a backtest i used the following line to do so:

if marketposition <> 0 then begin
buy next bar open;
sell next bar open;
end;

In live trading for some reason, this does not work and close of the position is not executed (even order are not created). May be i am doing smth wrong, not sure.

I think what you are seeing is normal behavior for backtest. Take a look at the two examples below.

In the first one, when the code runs on July 5 at bar close, the strategy thinks marketposition=0. So, on the open of the 6th, it does not try to exit the position opened at close of the 5th. But it does close position on open of 7th. That is correct behavior.

In the second one, when the code runs on July 5 at bar close, the strategy thinks marketposition=0. It does not recognize a position until it evaluates the bar on the 6th at close, at which point it sees the open position that was opened at the open on the 6th. So it does close position on open of 7th. Again, it seems to be correct.

Live trading should fire off orders the same way as shown in backtest.



Hopefully this makes sense.

If you experience something different, please post full code and chart showing what you think is odd/wrong. One thing you can do is put print(marketposition); statements in code and see when the marketposition is actually changing.





Follow me on Twitter Reply With Quote
  #8 (permalink)
 alko 
San Diego, USA
 
Experience: Intermediate
Platform: MC
Trading: All
Posts: 48 since Aug 2016
Thanks Given: 7
Thanks Received: 14

Kevin, i fully agree with the logic in your examples.
Somehow, your example 2 does not work in my case. I enter the position with the stop and then marketposition should be checked at the bar close and then it should be 1 and thus it should be closed next bar open, but it does not. I have no idea why it works in a backtest and does not work live. it might be related to order settings somehow. I will post the results when i figure this out.

Reply With Quote
  #9 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


alko View Post
Kevin, i fully agree with the logic in your examples.
Somehow, your example 2 does not work in my case. I enter the position with the stop and then marketposition should be checked at the bar close and then it should be 1 and thus it should be closed next bar open, but it does not. I have no idea why it works in a backtest and does not work live. it might be related to order settings somehow. I will post the results when i figure this out.

Are you saying you run the exact code in backtest example 2, but get different results than what I show? Or are you saying it works the same as mine in backtest, but did not work live?

Follow me on Twitter Reply With Quote
  #10 (permalink)
 alko 
San Diego, USA
 
Experience: Intermediate
Platform: MC
Trading: All
Posts: 48 since Aug 2016
Thanks Given: 7
Thanks Received: 14



kevinkdog View Post
Are you saying you run the exact code in backtest example 2, but get different results than what I show? Or are you saying it works the same as mine in backtest, but did not work live?

Yes.
and it is definitely smth wrong with the order placement rather than the startegy logic, since the strategy closes the position, but in live the order does not follow through somehow.

Reply With Quote




Last Updated on August 17, 2017


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts