//@version=2
study(title="SuperTrend Oscillator Binary Options",shorttitle="STO_BO",overlay=false)
//Inputs
spt_ures=false//spt_ures=input(false,title="Use Cutsom Resolution?")
spt_res="M"//spt_res=input(type=resolution,defval="M")
spt_lenw=200//spt_lenw=input(200,title="Length Of Warning Range")
spt_len=input(14,title="SuperTrend Length")
spt_mult=input(1,title="SuperTrend Multiple")
spt_ubc=input(false,title="Use Barcolors?")
colup=green
coldn=red
//SuperTrend
spt_atr=atr(spt_len)
spt_nsb=hl2+spt_atr*spt_mult
spt_nlb=hl2-spt_atr*spt_mult
spt_lb=close[1]>spt_lb[1]?max(spt_nlb,spt_lb[1]):spt_nlb
spt_sb=close[1]<spt_sb[1]?min(spt_nsb,spt_sb[1]):spt_nsb
spt_tdur=close>spt_sb[1]?1:close<spt_lb[1]?-1:nz(spt_tdur[1],1)
spt_td=spt_ures?(security(tickerid,spt_res,spt_tdur)):spt_tdur
spt_lvlur=(close-(spt_td==1?spt_lb:spt_sb))
spt_lvl=spt_ures?(security(tickerid,spt_res,spt_lvlur)):spt_lvlur
//Components
spt_lvlup=spt_td==1?spt_lvl:na
spt_lvldn=spt_td==-1?spt_lvl:na
spt_tdup=(spt_td==1)and(spt_td[1]==-1)
spt_tddn=(spt_td==-1)and(spt_td[1]==1)
spt_tr=spt_ures?(security(tickerid,spt_res,tr)):tr
spt_matr=sma(abs(spt_lvl),200)
spt_cls=spt_ures?(security(tickerid,spt_res,close)):close
spt_lvlwup=(spt_lvlup<spt_matr)and(spt_cls<spt_cls[1])
spt_lvlwdn=(spt_lvldn>-spt_matr)and(spt_cls>spt_cls[1])
//Color
spt_col=spt_td==1?colup:coldn
spt_colbar=(spt_td==1)and(spt_lvlwup)?#A7D1AA:(spt_td==-1)and(spt_lvlwdn)?#D1A7AE:spt_td==1?colup:coldn
spt_colhst=spt_tdup?colup:spt_tddn?coldn:spt_lvlwdn?colup:spt_lvlwup?coldn:na
//Plot
p0=plot(0,color=spt_col,style=line,linewidth=1,transp=0,title="Midline")
p1=plot(spt_lvlup,color=colup,style=linebr,linewidth=1,transp=0,title="Uptrend Line")
p2=plot(spt_lvldn,color=coldn,style=linebr,linewidth=1,transp=0,title="Downtrend Line")
plot(spt_lvl,color=spt_colhst,style=histogram,linewidth=3,transp=0,title="Trend Change")
plot(spt_lvl,color=spt_colhst,style=circles,linewidth=2,transp=0,title="Trend Change")
fill(p0,p1,color=colup,transp=90)
fill(p0,p2,color=red,transp=90)
barcolor(spt_ubc?spt_colbar:na)

E = input(1, title="Buy/sell period")
show = input(true, title="Show win/lose")
show_1 = input(true, title="Show usl 1")

usl_down_1 = spt_tdup
usl_up_1 = spt_tddn

plotshape(show_1 and usl_down_1, style = shape.arrowdown, title="Up Entry Arrow", color=red, size = size.small, transp=30, location = location.bottom)
plotshape(show_1 and usl_up_1, style = shape.arrowup, title="Down Entry Arrow", color=green, size = size.small, transp=30, location = location.bottom)
WIN_1 = (usl_up_1[E] and open[E-1] < close) or (usl_down_1[E] and open[E-1] > close)
LOSE_1 = (usl_up_1[E] and open[E-1] >= close) or (usl_down_1[E] and open[E-1] <= close)
//plotchar(show_1 and (usl_up_1 or usl_down_1), location = location.top, char='1', color = black, size = size.tiny)
plotshape(show and show_1 and WIN_1, location = location.top, style = shape.flag, color = #006400, size = size.small)
plotshape(show and show_1 and LOSE_1, location = location.top, style = shape.circle, color = red, size = size.small)

 

C++ Online Compiler

Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++ and start coding!

Read inputs from stdin

OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.

#include <iostream>
#include <string>
using namespace std;

int main() 
{
    string name;
    cout << "Enter name:";
    getline (cin, name);
    cout << "Hello " << name;
    return 0;
}

About C++

C++ is a widely used middle-level programming language.

  • Supports different platforms like Windows, various Linux flavours, MacOS etc
  • C++ supports OOPS concepts like Inheritance, Polymorphism, Encapsulation and Abstraction.
  • Case-sensitive
  • C++ is a compiler based language
  • C++ supports structured programming language
  • C++ provides alot of inbuilt functions and also supports dynamic memory allocation.
  • Like C, C++ also allows you to play with memory using Pointers.

Syntax help

Loops

1. If-Else:

When ever you want to perform a set of operations based on a condition If-Else is used.

if(conditional-expression) {
   //code
}
else {
   //code
}

You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.

2. Switch:

Switch is an alternative to If-Else-If ladder.

switch(conditional-expression){    
case value1:    
 // code    
 break;  // optional  
case value2:    
 // code    
 break;  // optional  
......    
    
default:     
 code to be executed when all the above cases are not matched;    
} 

3. For:

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
  //code  
} 

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
// code 
}  

5. Do-While:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
 // code 
} while (condition); 

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.

How to declare a Function:

return_type function_name(parameters);

How to call a Function:

function_name (parameters)

How to define a Function:

return_type function_name(parameters) {  
 // code
}