• LIMITED TIME ONLY: Take $40 off VIP with code: BTD40.

Unrequited Conversion Requests To ThinkOrSwim

XeoNoX

Well-known member
VIP
gotcha, in the future i would like to convert this volatility based envelopes study, figured would try and keep it relevant. I was so happy for a split second thinking it was the code to the volatility based envelopes then i realized it wasn't. 😭 Its going to take some digging to get the formula, hopefully someone would be kind enough to at least post the formula for the volatility based envelopes.
 

dharmesh

New member
PLEASE HELP TO CONVERT THESE MT4 SCRIPT IN TO TOS(THINK AND SWIM PLEASE)

Code:
// + ----------------------------------------------- ------------------- +
// | SPECIFIC PARAMETERS
// + ----------------------------------------------- ------------------- +
#property copyright ""; //Authorship
#property link ""; // Link to the developer's site
#property version ""; // Indicator version
#property description ""; // Indicator description
#property strict // Strict compilation mode
#property indicator_chart_window // Display the indicator in the chart window
#property indicator_buffers 5 // Number of buffers for indicator calculations
// + ----------------------------------------------- ------------------- +
// | SPECIFIC PARAMETERS
// + ----------------------------------------------- ------------------- +
// + ----------------------------------------------- ------------------- +
// | CUSTOM TRANSFERS
// + ----------------------------------------------- ------------------- +
// Enumeration of constants for the price type
enum PriceTypeInt
  {
   PRICE_CLOSE_1 = 0, // Closing price
   PRICE_OPEN_1 = 1, // Opening price
   PRICE_HIGH_1 = 2, // Maximum price for the period
   PRICE_LOW_1 = 3, // Lowest price for the period
   PRICE_MEDIAN_1 = 4, // Median price, (high + low) / 2
   PRICE_TYPICAL_1 = 5, // Typical price, (high + low + close) / 3
   PRICE_WEIGHTED_1 = 6 // Weighted closing price, (high + low + close + close) / 4
  };
/// Enumeration of constants instead of true / false
enum BoolInt
  {
   Yes = 0, // Yes
   No = 1 // No
  };
// Enumeration of line style constants
enum StyleLineInt
  {
   STYLE_SOLID_1 = 0, // Solid line
   STYLE_DASH_1 = 1, // Dashed line
   STYLE_DOT_1 = 2, // Dotted line
   STYLE_DASHDOT_1 = 3, // Dash-dotted line
   STYLE_DASHDOTDOT_1 = 4 // Dash-dotted line with double dots
  };
// Enumeration of constants for symbols
enum StyleArrowInt
  {
   STYLE_ARROW_1 = 217, // Symbol - upward fractal arrow
   STYLE_ARROW_2 = 218, // Symbol - downward fractal arrow
   STYLE_ARROW_3 = 221, // Symbol - an upward arrow in a circle
   STYLE_ARROW_4 = 222, // Symbol - an arrow in a circle down
   STYLE_ARROW_5 = 221, // Symbol - thin up arrow
   STYLE_ARROW_6 = 222, // Symbol - thin arrow down
   STYLE_ARROW_7 = 233, // Symbol - thick up arrow
   STYLE_ARROW_8 = 234, // Symbol - thick down arrow
   STYLE_ARROW_9 = 83, // Symbol is a drop
   STYLE_ARROW_10 = 84, // Symbol - snowflake
   STYLE_ARROW_11 = 251, // Symbol - cross
   STYLE_ARROW_12 = 252, // Symbol - check mark
   STYLE_ARROW_13 = 89, // Symbol - pintogram
   STYLE_ARROW_14 = 91, // Symbol - yyang
   STYLE_ARROW_15 = 161, // Symbol - circle
   STYLE_ARROW_16 = 164, // Symbol - a circle with a dot
   STYLE_ARROW_17 = 108, // Symbol is a big dot
   STYLE_ARROW_18 = 159, // Symbol - small dot
   STYLE_ARROW_19 = 110, // Symbol is a big square
   STYLE_ARROW_20 = 167, // Symbol is a small square
   STYLE_ARROW_21 = 117, // Symbol - big diamond
   STYLE_ARROW_22 = 119, // Symbol is a small diamond
   STYLE_ARROW_23 = 171, // Symbol is a star
   STYLE_ARROW_24 = 181 // Symbol - a star in a circle
  };
// + ----------------------------------------------- ------------------- +
// | CUSTOM TRANSFERS
// + ----------------------------------------------- ------------------- +
// + ----------------------------------------------- ------------------- +
// | INPUT SETTINGS
// + ----------------------------------------------- ------------------- +
extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; // Timeframe for building the channel
extern int HalfLength = 55; //Period
extern PriceTypeInt Price = PRICE_WEIGHTED_1; // Price type
extern double BandsDeviations = 1.618; // Expand the channel
extern BoolInt Interpolate = No; // Smooth the channel
extern int History = 750; // Limit history in bars
extern BoolInt alertsOn = No; // Allow alerts
extern BoolInt alertsOnCurrent = No; // Notifications "Yes" - on the current bar "No" - on the previous
extern BoolInt alertsOnHighLow = No; // Notifications of channel breakout "Yes" - High / Low "No" - Close
extern BoolInt alertsMessage = No; // Alert in the terminal
extern BoolInt alertsPush = No; // Push notification
extern BoolInt alertsEmail = No; // Email alert
extern string ChannelSetting = "Channel autobuilding settings"; // Autobuild channel settings
extern BoolInt UseAutoChannel = No; // Use automatic channel settings
extern ENUM_TIMEFRAMES TimeM1 = PERIOD_M5; //
//+------------------------------------------------------------------+ //| SPETSIFICHESKIYe PARAMETRY //+------------------------------------------------------------------+ #property copyright ""; //Avtorstvo #property link ""; //Sylka na sayt razrabotchika #property version ""; //Versiya indikatora #property description ""; //Opisaniye indikatora #property strict //Strogiy rezhim kompilyatsii #property indicator_chart_window //Vyvod indikatora v okne grafika #property indicator_buffers 5 //Kolichestvo buferov dlya raschetov indikatora //+------------------------------------------------------------------+ //| SPETSIFICHESKIYe PARAMETRY //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| KASTOMNYYe PERECHISLENIYA //+------------------------------------------------------------------+ //Perchisleniye konstant dlya tipa tsen enum PriceTypeInt { PRICE_CLOSE_1 = 0, //Tsena zakrytiya PRICE_OPEN_1 = 1, //Tsena otkrytiya PRICE_HIGH_1 = 2, //Maksimal'naya za period tsena PRICE_LOW_1 = 3, //Minimal'naya za period tsena PRICE_MEDIAN_1 = 4, //Mediannaya tsena, (high+low)/2 PRICE_TYPICAL_1 = 5, //Tipichnaya tsena, (high+low+close)/3 PRICE_WEIGHTED_1 = 6 //Vzveshennaya tsena zakrytiya, (high+low+close+close)/4 }; ///Perechisleniye konstant vmesto true/false enum BoolInt { Yes = 0, //Da No = 1 //Net }; //Perechisleniye konstant dlya stilya liniy enum StyleLineInt { STYLE_SOLID_1 = 0, //Sploshnaya liniya STYLE_DASH_1 = 1, //Shtrikhovaya liniya STYLE_DOT_1 = 2, //Punktirnaya liniya STYLE_DASHDOT_1 = 3, //Shtrikh-punktirnaya liniya STYLE_DASHDOTDOT_1 = 4 //Shtrikh-punktirnaya liniya s dvoynymi tochkami }; //Perechisleniya konstant dlya simvolov enum StyleArrowInt { STYLE_ARROW_1 = 217, //Simvol - strelka fraktala vverkh STYLE_ARROW_2 = 218, //Simvol - strelka fraktala vniz STYLE_ARROW_3 = 221, //Simvol - strelka v kruge vverkh STYLE_ARROW_4 = 222, //Simvol - strelka v kruge vniz STYLE_ARROW_5 = 221, //Simvol - tonkaya strelka vverkh STYLE_ARROW_6 = 222, //Simvol - tonkaya strelka vniz STYLE_ARROW_7 = 233, //Simvol - tolstaya strelka vverkh STYLE_ARROW_8 = 234, //Simvol - tolstaya strelka vniz STYLE_ARROW_9 = 83, //Simvol - kaplya STYLE_ARROW_10 = 84, //Simvol - snezhinka STYLE_ARROW_11 = 251, //Simvol - krestik STYLE_ARROW_12 = 252, //Simvol - galochka STYLE_ARROW_13 = 89, //Simvol - pintogramma STYLE_ARROW_14 = 91, //Simvol - in'yan' STYLE_ARROW_15 = 161, //Simvol - krug STYLE_ARROW_16 = 164, //Simvol - krug s tochkoy STYLE_ARROW_17 = 108, //Simvol - bol'shaya tochka STYLE_ARROW_18 = 159, //Simvol - malen'kaya tochka STYLE_ARROW_19 = 110, //Simvol - bol'shoy kvadrat STYLE_ARROW_20 = 167, //Simvol - malen'kiy kvadrat STYLE_ARROW_21 = 117, //Simvol - bol'shoy romb STYLE_ARROW_22 = 119, //Simvol - malen'kiy romb STYLE_ARROW_23 = 171, //Simvol - zvezda STYLE_ARROW_24 = 181 //Simvol - zvezda v kruge }; //+------------------------------------------------------------------+ //| KASTOMNYYe PERECHISLENIYA //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| VKHODNYYe NASTROYKI //+------------------------------------------------------------------+ extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; //Taymfreym dlya postroyeniya kanala extern int HalfLength = 55; //Period extern PriceTypeInt Price = PRICE_WEIGHTED_1; //Tip tseny extern double BandsDeviations = 1.618; //Rasshireniye kanala extern BoolInt Interpolate = No; //Sglazhivaniye kanala extern int History = 750; //Ogranicheniye istorii v barakh extern BoolInt alertsOn = No; //Razreshit' opoveshcheniya extern BoolInt alertsOnCurrent = No; //Opoveshcheniya "Da" - na tekushchem bare "Net" - na predydushchem extern BoolInt alertsOnHighLow = No; //Opoveshcheniya probitiya kanala "Da" - High/Low "Net" - Close extern BoolInt alertsMessage = No; //Opoveshcheniye v terminale extern BoolInt alertsPush = No; //Opoveshcheniye Push extern BoolInt alertsEmail = No; //Opoveshcheniye na elektronnuyu pochtu extern string ChannelSetting = "Nastroyki avtopostroyeniya kanala"; //Nastroyki avtopostroyeniya kanala extern BoolInt UseAutoChannel = No; //Ispol'zovaniye avtomaticheskikh nastroyek kanala extern ENUM_TIMEFRAMES TimeM1 = PERIOD_M5; //
 

wyfc68

New member
I was wondering if someone can help me convert this code from FUTU Bull into Thinkscript. This is a bottom indicator that gives out buy and sell signal.

IBS.jpg


Code below:

Code:
VAR3:=(CLOSE-MA(CLOSE,6))/MA(CLOSE,6)*100;
VAR4:=(CLOSE-MA(CLOSE,24))/MA(CLOSE,24)*100;
VAR5:=(CLOSE-MA(CLOSE,32))/MA(CLOSE,32)*100;
VAR6:=(VAR3+VAR4+VAR5)/3;
VAR7:=EMA(VAR6,5);
指标: EMA(EMA(VAR3,5),5)*3, COLORSTICK;
VAR8:=IF(VAR6<=-20,10,0);
VAR9:=HHV(VAR8,10);
STICKLINE(VAR8=10,20,10,5,0),COLOR6666FF;
VARA:=IF(VAR9 AND CROSS(MA(CLOSE,3),MA(CLOSE,5)),20,0);
K:EMA(VAR7,5)*2,  COLORFF00FF;
D:EMA(K,5),  COLORWHITE;
J:K*3-D*2, COLORYELLOW;
VARB:=BETWEEN(CLOSE,MA(CLOSE,3),MA(CLOSE,5)) AND J>10;
换手: VOL/CAPITAL*100,COLORGREEN;
STICKLINE((VARA=20),0,10,5,0),COLORWHITE;
DRAWTEXT(VARA=20,15,'BOTTOM'),LINETHICK1,COLORWHITE;
VARC:=(ZIG(3,5)>REF(ZIG(3,5),1)) AND (REF(ZIG(3,5),1)<=REF(ZIG(3,5),2)) AND (REF(ZIG(3,5),2)<=REF(ZIG(3,5),3));
VARD:=(ZIG(3,5)<REF(ZIG(3,5),1)) AND (REF(ZIG(3,5),1)>=REF(ZIG(3,5),2)) AND (REF(ZIG(3,5),2)>=REF(ZIG(3,5),3));
STICKLINE((VARC=1),(-20),0,1,0),COLORGREEN;
DRAWTEXT((VARC=1),(-20),'BUY'),COLORWHITE;
STICKLINE((VARD=1),40,0,1,0),COLORRED;
DRAWTEXT((VARD=1),50,'SELL'),COLOR00FF00;
VARE:=MA(100*(CLOSE-LLV(CLOSE,34))/(HHV(HIGH,34)-LLV(LOW,34)),5)-20;
VARF:=100-3*SMA((CLOSE-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1)+2*SMA(SMA((CLOSE-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1),15,1);
VAR10:=100-3*SMA((OPEN-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1)+2*SMA(SMA((OPEN-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1),15,1);
VAR11:=VARF<REF(VAR10,1) AND VOL>REF(VOL,1) AND CLOSE>REF(CLOSE,1);
STICKLINE(VAR11 AND COUNT(VAR11,30)=1,1,10,5,0),COLORFF00FF;
DRAWTEXT(VAR11 AND COUNT(VAR11,30)=1,15,'HIGH VOL'),LINETHICK1,COLORFF00FF;
VAR12:=(HIGH+LOW+CLOSE)/3;
VAR13:=(VAR12-MA(VAR12,14))/(0.015*AVEDEV(VAR12,14));
VAR14:=(VAR12-MA(VAR12,70))/(0.015*AVEDEV(VAR12,70));
VAR15:=IF(VAR13>=150 AND VAR13<200 AND VAR14>=150 AND VAR14<200,10,0);
VAR16:=IF(VAR13<=-150 AND VAR13>-200 AND VAR14<=-150 AND VAR14>-200,-10,VAR15);
VAR17:=(CLOSE-MA(CLOSE,13))/MA(CLOSE,13)*100;
VAR18:=100-ABS(VAR17);
VAR19:=IF(VAR18<90,VAR18,100);
VAR1A:=IF(VARE>0,VARE,0);
VAR1B:=IF(VAR14>=200 AND VAR13>=150,15,IF(VAR14<=-200 AND VAR13<=-150,-15,VAR16))+60;
VAR1C:=VAR1A>48 AND VAR1B>60 AND VAR19<100;
STICKLINE(VAR1C AND COUNT(VAR1C,30)=1,0,100,1,0),COLORFFCC66;
DRAWTEXT(VAR1C AND COUNT(VAR1C,30)=1,110,'HIGH SELL VOL'),LINETHICK1,COLORFFCC66;
It looks like that the signal can change if the trend changes. How do you use this indicator? 怎么联系你?
 

XeoNoX

Well-known member
VIP
this is like asking someone to build a mansion with no blue prints or thorough explanation of how they want the mansion layout to be implemented, with no blueprint there is nothing to convert.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
SuperTrend Indicators [for the most part] are notoriously too complex for the TOS platform to scan or put in a watchlist. Many pivot points are real time so they constantly update (as in repaint) So would it be worth trying to convert this indicator that has two strikes against it? How would you want to use it?
@Kubera
 

Kubera

New member
SuperTrend Indicators [for the most part] are notoriously too complex for the TOS platform to scan or put in a watchlist. Many pivot points are real time so they constantly update (as in repaint) So would it be worth trying to convert this indicator that has two strikes against it? How would you want to use it?
@Kubera
Thanks for the reply. The study doesn't repaint as claimed by the author. I have tried on tradingview with reasonable results but for very short time. I'd like to have TOS version so I can backtest and use it with others for confluence. I tried to convert to thinkscript but am not good at it.
 

nowhmar

New member
found this mt5 script need help converting it.

Code:
int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   MqlRates _rates[]; int _ratesCopied=CopyRates(_Symbol,inpTimeFrame,1,inpAtrPeriod+1,_rates);
   if(_ratesCopied != inpAtrPeriod+1) return(prev_calculated);

   double _atr    = 0; for(int k=0;k lt inpAtrPeriod; k++) _atr += MathMax(_rates[k+1].high,_rates[k].close)-MathMin(_rates[k+1].low,_rates[k].close); _atr /= inpAtrPeriod;
   double _pclose = _rates[inpAtrPeriod].close;
   string _tf     = timeFrameToString(inpTimeFrame);
   datetime _time = time[rates_total-1]+PeriodSeconds(_Period)*inpLabelsShift;
   _createLine("res3",_pclose+_atr,_time,inpUp,inpUp,_tf+" probability band R3 ("+DoubleToString(_pclose+_atr,_Digits)+")");
   _createLine("res2",_pclose+_atr*0.75,_time,inpUp,inpUp,_tf+" probability band R2 ("+DoubleToString(_pclose+_atr*0.75,_Digits)+")");
   _createLine("res1",_pclose+_atr*0.50,_time,inpUp,inpUp,_tf+" probability band R1 ("+DoubleToString(_pclose+_atr*0.50,_Digits)+")");
   _createLine("sup1",_pclose-_atr*0.50,_time,inpDn,inpDn,_tf+" probability band S1 ("+DoubleToString(_pclose-_atr*0.50,_Digits)+")");
   _createLine("sup2",_pclose-_atr*0.75,_time,inpDn,inpDn,_tf+" probability band S2 ("+DoubleToString(_pclose-_atr*0.75,_Digits)+")");
   _createLine("sup3",_pclose-_atr,_time,inpDn,inpDn,_tf+" probability band S3 ("+DoubleToString(_pclose-_atr,_Digits)+")");
   ChartRedraw();
   return (rates_total);
  }
//+------------------------------------------------------------------+
//| Custom function(s)                                               |
//+------------------------------------------------------------------+
void _createLine(string _add,double _price,datetime _time,color _color,color _textColor,string _text,int _style=STYLE_DOT)
  {
   string _name=inpUniqueID+":"+_add;
   ObjectCreate(0,_name,OBJ_HLINE,0,0,0);
   ObjectSetInteger(0,_name,OBJPROP_COLOR,_color);
   ObjectSetInteger(0,_name,OBJPROP_STYLE,_style);
   ObjectSetDouble(0,_name,OBJPROP_PRICE,0,_price);
   _name=inpUniqueID+":label:"+_add;
   ObjectCreate(0,_name,OBJ_TEXT,0,0,0);
   ObjectSetInteger(0,_name,OBJPROP_COLOR,_textColor);
   ObjectSetInteger(0,_name,OBJPROP_TIME,0,_time);
   ObjectSetInteger(0,_name,OBJPROP_FONTSIZE,8);
   ObjectSetDouble(0,_name,OBJPROP_PRICE,0,_price);
   ObjectSetString(0,_name,OBJPROP_FONT,"Arial");
   ObjectSetString(0,_name,OBJPROP_TEXT,_text);
  }
//------------------ 
int    _tfsPer[]={PERIOD_M1,PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,PERIOD_M30,PERIOD_H1,PERIOD_H2,PERIOD_H3,PERIOD_H4,PERIOD_H6,PERIOD_H8,PERIOD_H12,PERIOD_D1,PERIOD_W1,PERIOD_MN1};
string _tfsStr[]={"1 minute","2 minutes","3 minutes","4 minutes","5 minutes","6 minutes","10 minutes","12 minutes","15 minutes","20 minutes","30 minutes","1 hour","2 hours","3 hours","4 hours","6 hours","8 hours","12 hours","daily","weekly","monthly"};
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string timeFrameToString(int period)
  {
   if(period==PERIOD_CURRENT)
      period=_Period;
   int i; for(i=0;i lt ArraySize(_tfsPer);i++) if(period==_tfsPer[i]) break;
   return(_tfsStr[i]);
  }
//+------------------------------------------------------------------+
 

nowhmar

New member
@nowhmar You neglected to post a link to the original script and didn't post an image of the resulting chart... We don't generally just convert code for a single request but if you're willing to learn Thinkscript we're more than willing to help you along... Expecting others to do all of your coding for you should be considered poor forum etiquette... These forums are meant for learning... If you've spent any amount of time in these forums you should realize that a lot more requests get posted than get converted... There's good reason for that...
so sorry, didn't realize it was poor etiquette. I am new to this forum. this is the mt5 chart by the way.
cb-1__9.png
 

Christopher84

Well-known member
VIP
The bands look just like STARC bands which are essentially Keltner channels with different settings. STARC bands are a fantastic tool for trading. They are calculated using ATR instead of standard deviation (Bollinger Bands). STARC bands come standard on the TOS platform. However, after playing around with this for a few minutes, I believe you will achieve very similar results with a Keltner channel. It just needs a some changes to the settings. (See image below) I realize its not a perfect match, but its darn close for 15 minutes of tinkering. I fail to see how this would offer any advantage over Keltner channels or STARC.

rqyCokS.png


gqsYUfY.png
 
Last edited:

halcyonguy

Well-known member
VIP
Lifetime
hi tjira. have you searched for murrey on this site? there are 10+ posts, maybe one of the links has something close.

i haven't heard of this before, but it looks interesting. i searched and found these links, which will help others understand the theory behind it.
murrey math lines, theory
https://pipbear.com/indicator/murra...tps://tradingstrategyguides.com/murrey-lines/

http://wintrend.com/MurreyMath.aspx

https://blog.roboforex.com/blog/2020/08/14/murrey-math-lines-how-to-set-and-trade-them/[/url
 
Top