-
RECENT POSTS
-
By lucian_dinu · Posted
The scripts bellow are for LONG and SHORT, in the particular case bellow Fixed risk is 10$, (described in the script as Share=10/Price, if you want 30$ risk, change 10 to 30 ) You will choose the Stop on the Chart, Press or Execute Hotkey/script, automatically an order with assigned fixed risk will be sent to be filled, once filled automatically a range order will be placed for STOP at the price chosen on the chart and Take Profit at 2x the Risk (price difference between Average Price and STOP) Basically this is a script with stop at 1R chosen on the chart and Take Profit at 2R ---------------------------- For LONGS: How you should use it(same for shorts): 1. Double Click on the Chart for the Stop Price 2. Press Hotkey For the Long Position Risk 10$ 3. Hotkey Script will send order with the Assigned risk ($10 in this case,) will calculate the number of shares automatically for you 4. The Script will create a "range order": place a Stop order where you've double clicked on the chart and a Take Profit / TP order at 2x the risk (Risk /Reward - 1/2) If you would like to change the reward to 3, or other multiples, chance the part of the script "Price=Price*2" to Price=Price*3 for example of 3Reward --------------------------- LONG Side Script StopPrice=Price;Price=Ask-Price;Share=10/Price;ROUTE=LIMIT;Price=Ask+.05;TIF=DAY+;BUY=Send; StopPrice=StopPrice;Price=Ask-StopPrice;Price=Price*2;Price=Ask+Price;Price=Round2; TriggerOrder=RT:STOP STOPTYPE:RANGE LowPrice:StopPrice HighPrice:Price ACT:SELL QTY:POS TIF:DAY+; _______________________ SHORT Side Script StopPrice=Price;Price=Price-Bid;Share=10/Price;ROUTE=LIMIT;Price=Bid-.05;TIF=DAY+;SELL=Send; StopPrice=StopPrice;Price=StopPrice-Bid;Price=Price*2;Price=Bid-Price;Price=Round2; TriggerOrder=RT:STOP STOPTYPE:RANGE LowPrice:Price HighPrice:StopPrice ACT:BUY QTY:POS TIF:DAY+; -------------------------------------------------- ! Always test any scripts and hotkeys in DEMO account prior to using them in real account with real money. -
By lucian_dinu · Posted
The Think or Swim / TOS Script /Code bellow will display a label into the volume box, showing the value of Daily ATR versus current Day ATR and % of the Daily ATR achieved in the current session / Day. Pictures attached for reference. Bellow are two versions of the script 1. Label is GREY under 70% DATR , Turns Green over 70% of the DATR, tuns RED over 100% DATR 2. Label is GERY under 70% DATR , Turns Green over 70% of the DATR 1.st Version -------Label is GREY under 70% DATR , Turns Green over 70% of the DATR, tuns RED over 100% DATR # ---------------------------------------------------------- # DATR vs Today-ATR – volume-pane label # DATR = 14-day Wilders-smoothed TrueRange from DAILY bars # ATS = today’s intraday High – Low # ---------------------------------------------------------- declare on_volume; input dailyATRLength = 14; input averageType = AverageType.WILDERS; # ---------- Daily ATR (computed from daily bars) ---------- def dailyTR = TrueRange( high(period = AggregationPeriod.DAY), close(period = AggregationPeriod.DAY), low(period = AggregationPeriod.DAY) ); def dailyATR = MovingAverage(averageType, dailyTR, dailyATRLength); # ---------- Today’s session range ---------- def todayHi = high(period = AggregationPeriod.DAY); def todayLo = low(period = AggregationPeriod.DAY); def todayATR = todayHi - todayLo; # ---------- Percentage ---------- def pct = if dailyATR != 0 then Round((todayATR / dailyATR) * 100, 1) else 0; # ---------- Label ---------- AddLabel( yes, "DATR " + Round(dailyATR, 2) + " vs ATR " + Round(todayATR, 2) + " (" + pct + "%)", if pct >= 100 then Color.GREEN else if pct >= 70 then Color.YELLOW else Color.GRAY ); 2.nd Version ------- Label is GERY under 70% DATR , Turns Green over 70% of the DATR # ---------------------------------------------------------- # DATR vs Today-ATR – volume-pane label # DATR = 14-day Wilders-smoothed TrueRange from DAILY bars # ATS = today’s intraday High – Low # ---------------------------------------------------------- declare on_volume; input dailyATRLength = 14; input averageType = AverageType.WILDERS; # ---------- Daily ATR (computed from daily bars) ---------- def dailyTR = TrueRange( high(period = AggregationPeriod.DAY), close(period = AggregationPeriod.DAY), low(period = AggregationPeriod.DAY) ); def dailyATR = MovingAverage(averageType, dailyTR, dailyATRLength); # ---------- Today’s session range ---------- def todayHi = high(period = AggregationPeriod.DAY); def todayLo = low(period = AggregationPeriod.DAY); def todayATR = todayHi - todayLo; # ---------- Percentage ---------- def pct = if dailyATR != 0 then Round((todayATR / dailyATR) * 100, 1) else 0; # ---------- Label ---------- AddLabel( yes, "DATR " + Round(dailyATR, 2) + " vs ATR " + Round(todayATR, 2) + " (" + pct + "%)", if pct >= 70 then Color.GREEN else Color.GRAY ); -
Hello everyone. I really need help understanding how some of the script function really work, because it seems that every time i click the hotkey, the same exact script does different things. In particular I'm having troubles understanding why Round2 seems to not work the way it should. I have this simple script, which adds 50 shares to an already existing position and moves the stop loss to the new average price. I would like to round the stop loss price to avoid setting the stop loss to something like 206.36344534... dollars. However it seems that Round2 does not round the price to the two decimals, but in reality adds to it. It is weird but i can't explain it. the script is this one: if(pos >0){ CXL ALLSYMB; ROUTE=LIMIT; Price=Ask+0.05; Share=50; TIF=DAY+; BUY=Send; $mystop = avgcost; $mystopround = $mystop; $mystopround = Round2; TriggerOrder=RT:STOP STOPTYPE:MARKET PX:$mystop ACT:SELL STOPPRICE:$mystop QTY:Pos TIF:DAY+; } When executed, the variables mystop and mystopround have completely different values. Mystop has the correct value but it has way more decimal places than needed, while mystopround is 30 cents above mystop. I do not execute other scripts, so these variables get set by this script only. I've read the documentation and I can't find what i'm doing wrong. Thank you
-
https://traderpeter.substack.com/p/das-trader-pro-advanced-hotkeys-part-88c
-