kilowatt39
New member
hello @Svanoy that script that you modified for @aCuddlyTurtle ,i am trying to use it with a 9ema and HMA but having some problems,i am a novice when it comes on to coding,would you be able to look at it for me
EXTREMELY good Idea keep us posted U just may have the work around .I'm taking a different approach but its a work in progress. I'm using the real time account to monitor the strategy. The main issue with TOS is now you see it now you don't until it goes to a solid visual signal. Using higher timeframes help. Using only the "AddOrder" arrows not "buy" signals or other painted arrows helps, I am using an image recognition python app just on the arrows. Friday there wasn't a lot of trades on the 15 min NQ but it did fairly good. I'm also sending the trades to Ninjatrader, they have what is called OIF Order Instruction File that as the trade activates it sends a txt file to a certain folder. NT is watching that folder and activates your order. It all happens in milliseconds. Since using python I could also send the order to TDA-api but the api only allows real trading. Also you can use Interactive Broker TWS api they do allow paper trading. So there are a bunch of ways to do this.
@Gilgameash nice setup, it's some what similar to what @Svanoy is doing with his autohotkey, still it requires a lot of setup on the TOS screen to isolate the text. On my app I need to have TOS visually present but don't need to configure the screen other than in the strategy, to set the arrow colors of the buy and sell and close orders.
Kudos to the auto-traders !!!
I changed from using the HullMA ,am now using the RSI with the center line also for entry,problem is when the price keep breaking below and above in a short time its giving me too much signals.Anyway see if you can fix it for me,thanks in advance, The script is a mess but i am using it@kilowatt39
Post what you've got and I'll take a look.
#rsi
input longEntries = yes;
input ShortEntries = yes;
input price = close;
input tradesize = 1;
input StartTrading = 930;
input StopTrading = 1600;
input ShowTodayOnly = {"No", default "Yes"};
def s=ShowTodayOnly;
def today=if s==0 OR getday()==getlastday() AND secondsfromtime(StartTrading)>=0 then 1 else 0;
def t2trade = today and secondsFromTime(StartTrading) > 0 and secondsFromTime(StopTrading)<0 ;
## ema stoploss ##############
input emaStopLoss = yes;
input emaStopLenght = 9;
input emaLongDisplace = 0;
input emaShortDisplace = 0;
def emaX = MovingAverage(AverageType.EXPONENTIAL, close, emaStopLenght);
input rsiStopLoss = yes;
input rsiEntryOffset = 0;
input rsiStopOffset = 0 ;
input length = 14;
input OB = 70;
input OS = 30;
input neutral= 50;
input rsiAverageType = AverageType.WILDERS;
def over_bought = OB;
def over_sold = OS ;
def rsi = reference RSI(price = price, length = length, averageType = rsiAverageType);
##### Stop Loss / Profit Target ####
input offsetType = {default VALUE,percent, tick};
input longTarget = 50;
input shortTarget = 50;
input longStop = 50;
input shortStop = 50;
def entryPrice = open;#EntryPrice();
def mult;
switch (offsetType) {
case percent:
mult =entryPrice / 100;
case value:
mult = 1;
case tick:
mult = TickSize();
}
def longstopPrice;
def shortstopPrice;
def longTargetPrice;
def shortTargetPrice;
if high[1] >= shortStopPrice[1]{
longstopPrice = Double.NaN;
shortstopPrice = Double.NaN;
longTargetPrice = Double.NaN;
shortTargetPrice = Double.NaN;
}else if low[1] <= shortTargetPrice[1]{
longstopPrice = Double.NaN;
shortstopPrice = Double.NaN;
longTargetPrice = Double.NaN;
shortTargetPrice = Double.NaN;
}else if high[1] >= longTargetPrice[1]{
longstopPrice = Double.NaN;
shortstopPrice = Double.NaN;
longTargetPrice = Double.NaN;
shortTargetPrice = Double.NaN;
}else if low[1] <= longstopPrice[1]{
longstopPrice = Double.NaN;
shortstopPrice = Double.NaN;
longTargetPrice = Double.NaN;
shortTargetPrice = Double.NaN;
}else if rsi[1] crosses above over_bought[1] and IsNaN(longstopPrice[1]) {
longstopPrice = entryPrice - longstop * mult;
shortstopPrice = Double.NaN;
longTargetPrice = entryPrice + longtarget * mult;
shortTargetPrice = Double.NaN;
}else if rsi[1] crosses below over_sold[1]and IsNaN(shortstopPrice[1]) {
longstopPrice = Double.NaN;
shortstopPrice = entryPrice + shortstop * mult;
longTargetPrice = Double.NaN;
shortTargetPrice = entryPrice - shorttarget * mult;
}else{
longstopPrice = longstopPrice[1];
shortstopPrice = shortstopPrice[1];
longTargetPrice = longTargetPrice[1];
shortTargetPrice = shortTargetPrice[1];}
def long = rsi[0] crosses above over_bought[0];
def long2 = rsi[0] crosses above neutral ;
def longStopT = !isnan(longstopprice) and low <= longstopprice;
def longProfit = !isnan(longTargetPrice) and high >= longTargetPrice;
def short = rsi[0] crosses below over_sold[0] ;
def short2 = rsi[0] crosses below neutral ;
def shortStopT = !isnan(shortstopprice) and high >= shortstopprice;
def shortProfit = !isnan(shortTargetprice) and low <= shortTargetprice;
def OpenOrders = GetQuantity();
def ordfill = OpenOrders > 0 ;
def ordempty = OpenOrders < 1 ;
def orderx; if ordfill {orderx = 1;} else if ordempty {orderx = 0;} else {orderx = orderx[1];}
## Ema Stoploss ######
def emaLongStopT = close crosses below emaX[emaLongDisplace] ;
def emaShortStopT = close crosses above emaX[emaShortDisplace] ;
def emaBelow = emaLongStopT;
def emaAbove = emaShortStopT;
def emaLongStopTrigger = if emaBelow[1] then 1 else 0;
def emaShortStopTrigger = if emaAbove[1] then 1 else 0;
## Rsi Stoploss #######
def rsiLongStopT = rsi crosses below over_bought[rsiStopOffset] ;
def rsiShortStopT = rsi crosses above over_sold[rsiStopOffset];
def rsiBelow = rsiLongStopT;
def rsiAbove = rsiShortStopT;
def rsiLongStopTrigger = if rsiBelow[1] then 1 else 0;
def rsiShortStopTrigger = if rsiAbove[1] then 1 else 0;
#### Orders ####
AddOrder(OrderType.BUY_AUTO, (longEntries) and t2trade and long[-1], price = open[-2], tickcolor = GetColor(6), arrowcolor = GetColor(6), name = "Long Entry", tradeSize= tradesize);
AddOrder(OrderType.BUY_AUTO, (longEntries) and t2trade and long2[-1] , price = open[-2], tickcolor = Color.CYAN, arrowcolor = Color.CYAN, name = "nLong Entry", tradeSize= tradesize);
AddOrder(OrderType.SELL_TO_CLOSE, t2trade and longStopT[-1], price = longstopPrice[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "Long Stop", tradeSize= tradesize);
AddOrder(OrderType.SELL_TO_CLOSE, t2trade and longProfit[-1], price = longTargetPrice[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "Long Profit", tradeSize= tradesize);
AddOrder(OrderType.SELL_TO_CLOSE, (longEntries) and t2trade and rsiLongStopT[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "rLong Stop", tradeSize= tradesize);
AddOrder(OrderType.SELL_TO_CLOSE, (longEntries) and (emaStopLoss) and t2trade and emaLongStopT[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "eLong Stop", tradeSize= tradesize);
AddOrder(OrderType.SELL_AUTO,(ShortEntries) and t2trade and short[-1], price = open[-2], tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "Short Entry", tradeSize= tradesize);
AddOrder(OrderType.SELL_AUTO, (ShortEntries) and t2trade and short2[-1] , price = open[-2], tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "nShort Entry", tradeSize= tradesize);
AddOrder(OrderType.BUY_TO_CLOSE, t2trade and shortStopT[-1], price = shortstopPrice[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "Short Stop", tradeSize= tradesize);
AddOrder(OrderType.BUY_TO_CLOSE, t2trade and shortProfit[-1], price = shortTargetPrice[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "Short Profit", tradeSize= tradesize);
AddOrder(OrderType.BUY_TO_CLOSE, (ShortEntries) and t2trade and rsiShortStopT[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "rShort Stop", tradeSize= tradesize);
AddOrder(OrderType.BUY_TO_CLOSE, (ShortEntries) and (emaStopLoss) and t2trade and emaShortStopT[-1], tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "eShort Stop", tradeSize= tradesize);
def LongStopTrigger = t2trade and (!IsNaN(longStopPrice) and IsNaN(longStopPrice[-1]) and IsNaN(shortStopPrice[-1]) and low <= longStopPrice);
def LongTargetTrigger = t2trade and (!IsNaN(longStopPrice) and IsNaN(longStopPrice[-1]) and IsNaN(shortStopPrice[-1]) and high >= longTargetPrice);
def ShortStopTrigger = t2trade and (!IsNaN(shortStopPrice) and IsNaN(shortStopPrice[-1]) and IsNaN(longStopPrice[-1]) and high >= shortStopPrice);
def ShortTargetTrigger = t2trade and (!IsNaN(shortStopPrice) and IsNaN(shortStopPrice[-1]) and IsNaN(longStopPrice[-1]) and low <= shortTargetPrice);
#### Labels ####
AddLabel(yes, " ", if (longEntries) and t2trade and long[1] or (longEntries) and t2trade and long2[1] then CreateColor(153, 255, 153) else Color.GRAY);
AddLabel(yes, " ", if (ShortEntries) and t2trade and short[1] or (ShortEntries) and t2trade and short2[1] then CreateColor(255, 102, 102) else Color.DARK_GRAY);
AddLabel(IsNaN(LongStopTrigger) and !ShortStopTrigger and !ShortTargetTrigger," ",Color.WHITE);
AddLabel(!LongStopTrigger and IsNaN(ShortStopTrigger) and !LongTargetTrigger, " ",Color.WHITE);
AddLabel(IsNaN(LongStopTrigger) and IsNaN(ShortStopTrigger), " ",Color.WHITE);
AddLabel(LongStopTrigger, " ", Color.YELLOW);
AddLabel(LongTargetTrigger, " ", Color.YELLOW);
AddLabel(ShortStopTrigger, " ",Color.YELLOW);
AddLabel(ShortTargetTrigger, " ",Color.YELLOW);
AddLabel(yes, " ", if emaLongStopTrigger ==1 or rsiLongStopTrigger == 1 then Color.PLUM else if emaShortStopTrigger ==1 or rsiShortStopTrigger == 1 then Color.DARK_ORANGE else Color.PINK);
AddLabel(yes, if orderx == 1 then " " else " ", if orderx == 1 then Color.Blue else Color.Magenta);
def long = rsi[0] crosses above over_bought[0];
def long2 = rsi[0] crosses above neutral ;
def short = rsi[0] crosses below over_sold[0] ;
def short2 = rsi[0] crosses below neutral ;
Hello @irishgold thank you for the encouragement. Sorry, it is a study from the premium indicator forum so I cannot share the code here. I veered off on a tangent in my previous post anyways. the script utility is AutoHotKey. It allows the ability to define certain parts of the screen to monitor and using a label to indicate buy or sell by color displayed means I only have to monitor a small static section instead of the entire screen. It also works with the computer monitor, mouse, and keyboard disconnected from the computer. It has not missed a single signal.
As far as repaint, the study I'm using does not repaint. Yes, back testing can be very misleading. Fortunately, with the modification to the study I'm using, I'm able to see the price at which to execute a trade at all times and will eventually move to running a buy stop limit order instead of buying at market. That with a standard trailing stop, makes plotting the buy and sell very easy. Market activity may change in the future and maybe not as many trade setups will present themselves or maybe more will. I keep my chart at 180 days as this is the longest amount of time that will still allow a 39 minute bar. As days pass and that May 25th live trade start date gets further away, the constant back testing of 180 days from present has matched exactly and the Win/Loss ratio has seen little change.
In regards to NT, part of this live run I started back in May, is to see if I can start with the bare minimum cost and investment, build capital, and eventually move up to /ES. Also, since not all trades are winning trades, the less it costs the less it concerns me to lose. Actually lost $180.00 dollars today, but it was money I didn't have a week ago. Low cost and a positive Win/Loss ratio allows me to worry about keeping the program running, and not what it is actually doing at the moment.
@FSUTommy I meant from the VIP section of this site. It's a custom variation built on the 'Buy the Dip' indicator.
I'm using a tool called SAT-daddy. I've been doing both paper and live trading with it; but am currently concentrating on my ThinkScript strategy code to perfect the strategy.
Because of proprietary rules. Really can't discuss this on this forum.Many thanks for your reply,
I went to SAT-daddy website, trying to learn more about that product.
The developer is asking for over $1200 for annual subscription, with listed comment:
Due to the nature of how we implement our proprietary system, there are no refunds or evaluation periods.
Also, what caught my eye, another comment :
By simply adding a few lines of ThinkScript code to your existing strategy, you can make it “SAT-daddy aware“.
We provide complete instructions and even include a sample strategy that is SAT-daddy compatible.
If it is not too much trouble, could you please share some light:
( where the Advanced Orders are configured?)
- is the SAT-daddy system monitors and trades only one instrument and/or strategy ?
- how the SAT-daddy systems integrates with strategy, what script changes are required, given earlier comment?
- if the SAT-daddy system supports Advanced Orders Trading templates (e.g., OCO, TRG w/bracket,etc)
Sorry for soo many questions, just trying to understand the SAT-daddy benefits.
Thanks
Thank you very much for your comments. Frankly, we all know the lack of automation in TOS is not a dealbreaker. As long as you have a plan - what and when to trade.Because of proprietary rules. Really can't discuss this on this forum.
Also note: because it is not possible to "hide" or "lock" ThinkScript code; none of your research will find ToS Algo sites that can offer refunds or evaluation periods.
AND as you have seen the price is not small but not really expensive considering that algo sites assume that you will be making dozens of trades daily.
ThanksBest to contact the developer directly with these questions. I think there's a contact form on the web site.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Outside Auto-Trading Solutions for Thinkorswim | Playground | 4 | ||
P | Auto entering password | Playground | 0 | |
R | ToS Trade Button script? | Playground | 5 | |
M | Trade Algo | Playground | 2 | |
M | Daily Watchlist of Stocks to Day Trade Weekly Options For ThinkOrSwim | Playground | 999 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.