A trend, momentum and cycle Trading System v3.0 (CSA)

B

babouin77

New member
is it hard to to a buy on first green and sell on first red strategy added to this study?
 
wtf_dude

wtf_dude

Active member
is it hard to to a buy on first green and sell on first red strategy added to this study?
Not sure what you mean. It's a pretty clear signal. Are you talking about what time to aim for execution?
 
B

babouin77

New member
i meant to create a strategy from this rather than an indicator
 
I

irishgold

Member
i meant to create a strategy from this rather than an indicator
# A very basic order entry, repaint is a problem, as the strategy looks great on backtest but not so good in real time
# I used a 2 min time frame
#END OF CSA - trend, a momentum and a cycle based indicator for ThinkorSwim V3.2
#This is strictly a bullish by order type, adding this code at the end of the study, copy and selecting strategy tab create strategy, paste code.
input Contracts = 5;
def open_order = bullish[-displace];
def close_order = bearish[-displace];
#ORDERS
AddOrder(type = OrderType.BUY_TO_OPEN, open_order, tradeSize = Contracts, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Long");
AddOrder(type = OrderType.SELL_TO_CLOSE, close_order, tradeSize = Contracts, name = "Close", tickcolor = Color.GRAY, arrowcolor = Color.GRAY);
 
T

TreeDT

New member
Newbie here. Trying to learn how to create my own strategy within TOS. How are you backtesting, I don't see a script? Is the backtesting not in TOS? Also, does any of the studies repaint which would alter the backtest?
 
I

irishgold

Member
Newbie here. Trying to learn how to create my own strategy within TOS. How are you backtesting, I don't see a script? Is the backtesting not in TOS? Also, does any of the studies repaint which would alter the backtest?
Click on Studies then you will see a TAB for Strategies, click Create, then you must include some sort of AddOrder statement at the end of what ever you are using to signal the buy or sell
 
T

TraderKevin

New member
First off, thanks so much for the work you put into this @diazlaz!

Second, anyone else not able to get the global color settings to actually change the color of the paintbars function? I have no experience working with that function in thinkscript, so I wasn't able to fix it myself, either.
 
K

kinetic

New member
VIP
I am brand new here myself working on a different coding task, but I wonder during back-testing the scoring threshold numbers were changed... Maybe at one point there were more than 3 Bullish or Bearish indicators needed to color bars...

Have you tried increasing the thresholds and tested the results?

How would one go about editing the code to tweak the thresholds required to paint the bars?
 
T

TraderKevin

New member
As a very small contribution to the project, here is a modification I made to the paintbars section of the code in order to "show more gray" in the choppy areas as an indication you may want to stay out of the market (or trade using a strategy designed for choppiness). All it does is paint bars light gray if the ADX indicates it is a choppy market, and only paints green/red if it is trending. Just copy/paste this over the equivalent section in @diazlaz phenomenal code:

Code:
#COLORBARS
AssignPriceColor(
if PaintBars then
    if ADXPaintBarsMode then if ADX > ADXTrending then COLOR.ORANGE else COLOR.DARK_GRAY
    else
    if ADX < ADXTrending then color.light_gray
    else
    if bullish then COLOR.uptick else if bearish then COLOR.downtick
     else
     if enableNeutralMACDPainter then
      if macd_Val_1 > macd_Avg1 then COLOR.DARK_GREEN else COLOR.DARK_RED
     else
    COLOR.GRAY
else COLOR.CURRENT);
 
K

kinetic

New member
VIP
What does the Cyan/Grey/Yellow bar at the bottom of the chart indicate?
 
T

TraderKevin

New member
What does the Cyan/Grey/Yellow bar at the bottom of the chart indicate?
It indicates if the ADX is indicating a trending or choppy market. Gray means choppy, yellow means trending. In the options section of the study you can disable this by turning off the ADX bar. I recommend doing this if you use my code posted above, since it would be redundant (the candles would turn light gray if ADX was indicating a choppy market).
 
T

TOSTrader

New member
VIP
def open_order = bullish[-displace];
def close_order = bearish[-displace];
#ORDERS
AddOrder(type = OrderType.BUY_TO_OPEN, open_order, tradeSize = Contracts, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Long");
AddOrder(type = OrderType.SELL_TO_CLOSE, close_order, tradeSize = Contracts, name = "Close", tickcolor = Color.GRAY, arrowcolor = Color.GRAY);

This worked great for the buy signal. I reversed the code to get a short signal but it doesnt work? Can you guide me on how to add the short signal as well so I can back test the strategy?

#Short Order
AddOrder(type = OrderType.SELL_TO_OPEN, close_order, tradeSize = Contracts, tickcolor = Color.RED, arrowcolor = Color.red, name = SHORT");
AddOrder(type = OrderType.SELL_TO_CLOSE, open_order, tradeSize = Contracts, name = "Close short", tickcolor = Color.GRAY, arrowcolor = Color.GRAY);
 
I

irishgold

Member
#Short Order
AddOrder(type = OrderType.SELL_TO_OPEN, close_order, tradeSize = Contracts, tickcolor = Color.RED, arrowcolor = Color.red, name = SHORT");
AddOrder(type = OrderType.SELL_TO_CLOSE, open_order, tradeSize = Contracts, name = "Close short", tickcolor = Color.GRAY, arrowcolor = Color.GRAY);
You were close, name = SHORT needed a " and its not SELL_TO_CLOSE its BUY_TO_CLOSE
 
T

TOSTrader

New member
VIP
You were close, name = SHORT needed a " and its not SELL_TO_CLOSE its BUY_TO_CLOSE

ah seems even with that correction, it plots every bar to sell and buy lol. I'd like to know when to begin my short but i Guess i can just juse the close indicator.
 
B

bubz

New member
VIP
Whats the most current code for this? Can anyone share a TOS link
 
T

TOSTrader

New member
VIP
Three questions after reading 11 Pages of comments.

1 - Should this be added as a strategy or as a Study.
2 - I dont see anything but different colored bars. Should there be arrows of some sort or bubbles?
2b - How can I add indicator or alerts/arrows?
 
Last edited:
I

irishgold

Member
The Original posting is a Study, think of it as an information traffic light. It's got multiple signals it is monitoring. Some of them are not reliable to trade as a definitive, no repaint signal, So to make it a strategy as I posted a few times here you can add AddOrder statements and decide which of the many signals you want to create entry and exit signals from. Then once added create new Strategy under the Strategy tab
 
Vince Field

Vince Field

New member
@HighBredCloud I have some questions for ya in relation to the chart you shared in post #66.

Do you still use this setup? If not, what have you changed and why?

How do you incorporate all of the studies in your strategy? You have a lot going on there! I was hoping to get a little insight into how you use each indicator to direct you to buy and sell.

Thanks!
 

Similar threads

Top