FloatingPL for custom strategy - futures io
futures io futures trading



FloatingPL for custom strategy


Discussion in ThinkOrSwim

Updated by ext99
    1. trending_up 807 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 9 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

FloatingPL for custom strategy

(login for full post details)
  #1 (permalink)
New York
 
 
Posts: 5 since Oct 2019
Thanks: 0 given, 0 received

Hi everyone,

I am trying to build a simple strategy to backtest: buy if there's been 3 days of consecutive down days ... the problem is, the floatingPL only appears to show the very first buy trade, then it completely ignores all the other signals which don't even show on the chart.

This is what I have on ThinkScript, I would really appreciate it if someone can please help me get this working, to show all the signals on the chart + to work with the FloatingPL - I am not a programmer and really appreciate the help!


Quoting 
AddOrder(OrderType.BUY_AUTO, open is less than close from 1 bars ago and close from 1 bars ago is less than close from 2 bars ago and close from 2 bars ago is less than close from 3 bars ago, open[-1], 100, Color.YELLOW, Color.YELLOW, "Buy");


Reply With Quote

Can you help answer these questions
from other members on futures io?
Historical option expirations
Brokers
Order Data Export Plugin-- Is it possible?
NinjaTrader
Das Trader Pro
Platforms and Indicators
Market Replay and Fills (Denali data)
Sierra Chart
converting useful Pine Script into Multicharts code
EasyLanguage Programming
 
 
(login for full post details)
  #2 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 723 since Dec 2018
Thanks: 2,054 given, 1,617 received

I don't know how to get TOS to take multiple entries off of the same order. One work around which is kind of cumbersome is to add a separate order that includes "close is less than close 4 days ago", "5 days ago" etc...

If you just want to know results I can run it through tradestation and give you some figures. Just let me know which stocks/symbols you want it tested on as well as start and end dates.

Cheers,
Zimmer

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #3 (permalink)
New York
 
 
Posts: 5 since Oct 2019
Thanks: 0 given, 0 received



mtzimmer1 View Post
I don't know how to get TOS to take multiple entries off of the same order. One work around which is kind of cumbersome is to add a separate order that includes "close is less than close 4 days ago", "5 days ago" etc...

If you just want to know results I can run it through tradestation and give you some figures. Just let me know which stocks/symbols you want it tested on as well as start and end dates.

Cheers,
Zimmer

Thanks for your reply.

I built an indicator that successfully shows the occurrences on the 1 year daily chart (3 days consecutive down)... maybe as a workaround, we can code the strategy to Buy whenever the custom study is true? I'm not sure how I'd be able to do that, though.

Using the indicator alone (without having this work as a Strategy with FloatingPL) would be very cumbersome to go through the chart of each stock (and for different time periods), and manually try to figure out the P/L and the # of times a buy (after 3 consecutive downs) is actually successful

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 723 since Dec 2018
Thanks: 2,054 given, 1,617 received

I think you can do

"condition1 = ...."

in thinkscript. Then "buy if condition1" etc

//Revision
On second thought, I don't think that will work. You need separate lines or code for each order. Each buy command can only open 1 order as far as I am aware.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #5 (permalink)
New York
 
 
Posts: 5 since Oct 2019
Thanks: 0 given, 0 received


mtzimmer1 View Post
I think you can do

"condition1 = ...."

in thinkscript. Then "buy if condition1" etc

//Revision
On second thought, I don't think that will work. You need separate lines or code for each order. Each buy command can only open 1 order as far as I am aware.

But then, how is that if you look at MACD Strategy, there are so many buy/sell orders displayed on the chart with the working FloatingPL, while if you look at the code, you'll see there's only one buy and one sell order

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 723 since Dec 2018
Thanks: 2,054 given, 1,617 received

Oh I understand your question now.

Do you have a sell condition? Thinkscript needs a sell condition to exit the position before opening a new long position. It may be easier if you post the whole code.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #7 (permalink)
New York
 
 
Posts: 5 since Oct 2019
Thanks: 0 given, 0 received


mtzimmer1 View Post
Oh I understand your question now.

Do you have a sell condition? Thinkscript needs a sell condition to exit the position before opening a new long position. It may be easier if you post the whole code.

I don't have a sell, no... I guess if anything I would want to exit at the close of the bar following the buy bar... This is the code:
-----------------

Def x = open is less than close from 1 bars ago and close from 1 bars ago is less than close from 2 bars ago and close from 2 bars ago is less than close from 3 bars ago;

AddOrder(OrderType.BUY_TO_OPEN, x is true, open[-1], 100, Color.YELLOW, Color.YELLOW, "Buy");

AddOrder(OrderType.SELL_TO_CLOSE, x[1], close[-1], 100, Color.YELLOW, Color.RED, "Buy");

-----------------
thanks

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 723 since Dec 2018
Thanks: 2,054 given, 1,617 received

What if the fourth day is a down day? Do you still want to exit? Perhaps an exit after the first up day is a good idea.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #9 (permalink)
Legendary Market Wizard
Upstate NY
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 723 since Dec 2018
Thanks: 2,054 given, 1,617 received

AddOrder(OrderType.BUY_TO_OPEN, close<close[1] and close[1]<close[2] and close[2]<close[3], close, 100, Color.green, Color.green, "Buy");

AddOrder(OrderType.SELL_TO_CLOSE, close>close[1], close, 100, Color.red, Color.RED, "Sell");

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #10 (permalink)
New York
 
 
Posts: 5 since Oct 2019
Thanks: 0 given, 0 received



mtzimmer1 View Post
AddOrder(OrderType.BUY_TO_OPEN, close<close[1] and close[1]<close[2] and close[2]<close[3], close, 100, Color.green, Color.green, "Buy");

AddOrder(OrderType.SELL_TO_CLOSE, close>close[1], close, 100, Color.red, Color.RED, "Sell");

I switched the buy to buy at the open, otherwise the indicator has more of a lag to give a signal...

I'm wondering how to set the sell to close, to simply close 1 day after the buy to open

Reply With Quote


futures io Trading Community Platforms and Indicators ThinkOrSwim > FloatingPL for custom strategy


October 27, 2019


Upcoming Webinars and Events
 

Bookmap

Nov TBD
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts