NexusFi: Find Your Edge


Home Menu

 





FloatingPL for custom strategy


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,812 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

FloatingPL for custom strategy

  #1 (permalink)
ext99
New York
 
Posts: 5 since Oct 2019
Thanks Given: 0
Thanks Received: 0

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 NexusFi?
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
ext99
New York
 
Posts: 5 since Oct 2019
Thanks Given: 0
Thanks Received: 0



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
  #4 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
ext99
New York
 
Posts: 5 since Oct 2019
Thanks Given: 0
Thanks Received: 0


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
  #6 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
ext99
New York
 
Posts: 5 since Oct 2019
Thanks Given: 0
Thanks Received: 0


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
  #8 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #9 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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");

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
ext99
New York
 
Posts: 5 since Oct 2019
Thanks Given: 0
Thanks Received: 0



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




Last Updated on October 27, 2019


© 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