Convert SilverTrend to thinkscript

tradebyday

Active member
Posting here for FX lovers or simply the curious.. Going to be transferring this to TOS and then seeing if it repaints based on its function

Code:
//+------------------------------------------------------------------+
//|                                                 SilverTrend .mq4 |
//|                             SilverTrend  rewritten by CrazyChart |
//|                                                 http://viac.ru/  |
//|                  modified by Kalenzo [email protected] |
//+------------------------------------------------------------------+
#property copyright "SilverTrend  rewritten by CrazyChart"
#property link      "http://viac.ru/ "

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue  //Red  //Aqua
#property indicator_color2 Red

extern int       SSP=7;
extern double    Kmax=50.6; //24 21.6 21.6
extern int       CountBars=300;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtHBuffer1[];
double ExtHBuffer2[];




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_HISTOGRAM,0,2);  //Red
   SetIndexBuffer(0,ExtHBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,2);  //Aqua
   SetIndexBuffer(1,ExtHBuffer2);
 
   SetIndexBuffer(2,ExtMapBuffer1);
   SetIndexBuffer(3,ExtMapBuffer2);

   IndicatorShortName("FxTrend v2("+SSP+")");
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

  if (CountBars>=Bars) CountBars=Bars;

   SetIndexDrawBegin(0,Bars-CountBars+SSP);
   SetIndexDrawBegin(1,Bars-CountBars+SSP);
 
  int i, counted_bars=IndicatorCounted();
  double SsMax, SsMin, smin, smax;

  if(Bars<=SSP+1) return(0);

if(counted_bars<SSP+1)
   {
      for(i=1;i<=SSP;i++) ExtMapBuffer1[CountBars-i]=0.0;
      for(i=1;i<=SSP;i++) ExtMapBuffer2[CountBars-i]=0.0;
   }

for(i=CountBars-SSP;i>=0;i--) {


  SsMax = High[Highest(NULL,0,MODE_HIGH,SSP,i-SSP+1)];
  SsMin = Low[Lowest(NULL,0,MODE_LOW,SSP,i-SSP+1)];

   smax = SsMax-(SsMax-SsMin)*Kmax/100;
     
   ExtMapBuffer1[i-SSP+6]=smax;
   ExtMapBuffer2[i-SSP-1]=smax;

}
   for(int b=CountBars-SSP;b>=0;b--)
   {
      if(ExtMapBuffer1[b]>ExtMapBuffer2[b])
      {
         ExtHBuffer1[b]=1;
         ExtHBuffer2[b]=0;
      }
      else
      {
         ExtHBuffer1[b]=0;
         ExtHBuffer2[b]=1;
      }
     
   }

return(0);
}
 
Last edited by a moderator:

Billions

Active member
2019 Donor
VIP
@tradebyday Can you post the code when you transfer also I found this one but cant get the code any help would be grateful: Target Bands Metatrader 4 Forex Signals Indicator
 
Last edited by a moderator:

tradebyday

Active member
@tradebyday Can you post the code when you transfer also I found this one but cant get the code any help would be grateful: Target Bands Metatrader 4 Forex Signals Indicator
Ya the transfer will take me a bit as i am not proficient in the different coding languages, but will post when finished. If it has a mq4 file I may be able to transfer that one, but if its ex4 I will not be able to do it
 

tradebyday

Active member
I am interested to know how this one compares to other candle trend painting studies like Supertrend for example.

https://www.mt5traders.com/silver-trend-metatrader-4-forex-indicator/
So I don't know who changed the title, because the indicator I am transferring is a mod of silvertrend called "FxTrend v2" (found farther down the code), which is a lower indicator, not an on chart indicator, which has some extra functions involved that adds to it calculations
 

tradebyday

Active member
Sorry to disappoint guys but this project here has ended. Massive repainter, and definitely not worth using in any live trading. For an alternative here is a Heiken ashi based lower indicator to be played with that think someone else in here had made at one point
Code:
declare lower;

#Heikin-Ashi
def hc = (open + high + low + close ) / 4;
def ho = CompoundValue( 1, ( ho[1] + hc[1] ) / 2, hc );
def hh = Max(Max(high , ho), hc);
def hl = Min(Min(low , ho), hc);
def hh1r = if ho == hc then 0 else if ho < hc then 1 else -1;

plot Value = 1;

Value.AssignValueColor ( if hh1r == 1 then COLOR.GREEN else COLOR.RED );
Value.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
 

HighBredCloud

Well-known member
VIP
Sorry to disappoint guys but this project here has ended. Massive repainter, and definitely not worth using in any live trading. For an alternative here is a Heiken ashi based lower indicator to be played with that think someone else in here had made at one point
Code:
declare lower;

#Heikin-Ashi
def hc = (open + high + low + close ) / 4;
def ho = CompoundValue( 1, ( ho[1] + hc[1] ) / 2, hc );
def hh = Max(Max(high , ho), hc);
def hl = Min(Min(low , ho), hc);
def hh1r = if ho == hc then 0 else if ho < hc then 1 else -1;

plot Value = 1;

Value.AssignValueColor ( if hh1r == 1 then COLOR.GREEN else COLOR.RED );
Value.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Do a quick addition of MTF and this can be very useful especially for trading on lower timeframes in order to avoid whipsaw...
 

Similar threads

Top