//@version=5 indicator("Structure mapping v2.0 - Truest SMC indicators series", "TradeEmpire", true, max_bars_back = 5000, max_labels_count = 500, max_lines_count = 500) //#region variable declaration var bool mnUp = na var bool mnDn = na float mnStrc = na var top = high var bot = low var puUp = high var puDn = low var L = low var H = high var idmB = low var idmS = high var lastH = high var lastL = low var lastHH = high var lastLL = low //bar indexes var int puUpbar = na var int puDnbar = na var int idmB_bar = na var int idmS_bar = na var int Hbar = bar_index var int Lbar = bar_index var int lastHbar = bar_index var int lastLbar = bar_index var int lastHHbar = bar_index var int lastLLbar = bar_index //structure confirmaions lastHL = math.max(Hbar, Lbar) var bool isBosUp = 0 var bool isBosDn = 0 var bool isCocUp = 1 var bool isCocDn = 1 //color color transp = color.new(color.white,100) //drawing options equalHL = input.bool(0,"Use equal H/L", "To calculate valid pullbacks and minor structure", group = "Calculation method") showHL = input.bool(1, "Mark H/L", group = "H/L marking options") HLcolor = input.color(color.white, "H/L color", group = "H/L marking options") showMn = input.bool(0, "Mark out internal structure", group = "Internal structue") puUpco = input.color(color.red , "High pivots", inline = "mnco", group = "Internal structue") puDnco = input.color(color.green, "Low pivots" , inline = "mnco", group = "Internal structue") showBC = input.bool(1, "Mark BoS/ChoCH", group = "BoS/Choch") bull = input.color(color.green, "Bull color", inline = "BSclor" ,group = "BoS/Choch") bear = input.color(color.red , "Bear color", inline = "BSclor" ,group = "BoS/Choch") showbarcolor = input.bool(0,"Bar color", group = "Bar color") showSCOB = input.bool(1, "Show SCOB pattern", group = "Bar color") scobUp = input.color(color.aqua , "Bullish SCOB", inline = "scob" , group = "Bar color") scobDn = input.color(color.fuchsia, "Bearish SCOB", inline = "scob" , group = "Bar color") showIDM = input.bool(1,"Mark previous IDM", group = "IDM") showliveIDM = input.bool(1,"Mark live IDM", group = "IDM") idmColor = input.color(color.white, "IDM color", group = "IDM") var label lv_lbl = na var line lv_line = na showSw = input.bool(1, "Show H/L sweeping lines", group = "H/L sweeps") markX = input.bool(1, 'Mark "X"', group = "H/L sweeps") swColor = input.color(color.white, "Sweeping line color", group = "H/L sweeps") //max line length maxlen = bar_index - 500 //#endregion //#region drawing functions mnMark(bool UD) => if showMn label.new( x = UD ? puUpbar : puDnbar, y = UD ? puUp : puDn, yloc = UD ? yloc.abovebar : yloc.belowbar, text = "", color = UD ? puUpco : puDnco, style = UD ? label.style_arrowdown : label.style_arrowup, size = size.tiny ) BoS_ChoCh(bool B_C, bool UpDn) => [HLbarid, BCprc, BCcolor, BCtxt, BCstyle] = switch B_C == 1 and UpDn == 1 => [lastHHbar, lastHH, bull, "BoS" , label.style_label_down] B_C == 0 and UpDn == 1 => [lastHbar , lastH , bull, "ChoCh", label.style_label_down] B_C == 0 and UpDn == 0 => [lastLbar , lastL , bear, "ChoCh", label.style_label_up ] B_C == 1 and UpDn == 0 => [lastLLbar, lastLL, bear, "BoS" , label.style_label_up ] HLbarid := HLbarid < maxlen ? maxlen : HLbarid if showBC line.new(HLbarid, BCprc, bar_index, BCprc, color = BCcolor, style = line.style_dashed) label.new( int( math.avg(bar_index,HLbarid) ), BCprc ,BCtxt ,color = transp ,style = BCstyle ,textcolor = BCcolor )cfHL(bool ifHL) => [ifHLbarid, HLprc] = switch ifHL => if high > H [bar_index, high] else [Hbar, H] => if low < L [bar_index, low] else [Lbar, L] ifHL_txt = if ifHL if H == lastHH "HH" else "LH" else if L == lastLL "LL" else "HL" cfHLStyle = ifHL ? label.style_label_down : label.style_label_up if showHL label.new(ifHLbarid,HLprc,ifHL_txt, color = transp, textcolor = HLcolor, style = cfHLStyle) sweep(bool swHL, bool swHrLr) => swStyle = swHL ? label.style_label_down : label.style_label_up [swHLbarid, swprc, swHL_txt] = switch swHL == 1 and swHrLr == 1 => [lastHHbar, lastHH, "HH"] swHL == 1 and swHrLr == 0 => [lastHbar , lastH , "LH"] swHL == 0 and swHrLr == 1 => [lastLbar , lastL , "HL"] swHL == 0 and swHrLr == 0 => [lastLLbar, lastLL, "LL"] swHLbarid := swHLbarid < maxlen ? maxlen : swHLbarid //draw sweeping line if showSw line.new(swHLbarid,swprc,bar_index,swprc,color = swColor,style = line.style_dotted) if markX label.new(int(math.avg(bar_index,swHLbarid)),swprc, "X", color = transp, textcolor = swColor, style = swStyle, size = size.small) IDM(bool BS) => IDMid = BS ? idmB_bar : idmS_bar idmprc = BS ? idmB : idmS idmStyle = BS ? label.style_label_up : label.style_label_down IDMid := IDMid < maxlen ? maxlen : IDMid //draw idm takeout line if showIDM line.new(IDMid,idmprc,bar_index,idmprc,color = idmColor,style = line.style_dotted) label.new(int(math.avg(bar_index,IDMid)),idmprc, "IDM", color = transp, textcolor = idmColor, style = idmStyle,size = size.small) //Bar color ba_color = if showSCOB if low[1] == puDn and low >= low[1] and close > high[1] and close[1] > low[2] scobUp else if high[1] == puUp and high <= high[1] and close < low[1] and close[1] < high[2] scobDn else if showbarcolor isCocUp?bull:bear else na barcolor(ba_color,-1) //#endregion //#region structure mapping //update IDM if (high > H or (high == H and equalHL)) and low > idmB if low <= puDn idmB := low idmB_bar := bar_index else idmB := puDn idmB_bar := puDnbar if (low < L or (low == L and equalHL)) and high < idmS if high >= puUp idmS := high idmS_bar := bar_index else idmS := puUp idmS_bar := puUpbar //Check for IDM and ChoCh if isCocUp and lastHL != Lbar if low < idmB if idmB != lastL IDM(1) isBosUp := 0 lastH := H lastHbar := Hbar lastHH := H lastHHbar := Hbar cfHL(1) L := low Lbar := bar_index else if lastH != lastHH and high > lastH cfHL(0) isCocDn := 0 isBosDn := 0 if close > lastH BoS_ChoCh(0,1) isCocUp := 1 else sweep(1,0) if isCocDn and lastHL != Hbar if high > idmS if idmS != lastH IDM(0) isBosDn := 0 lastL := L lastLbar := Lbar lastLL := L lastLLbar := Lbar cfHL(0) H := high Hbar := bar_index else if low < lastL and lastL != lastLL if close < lastL BoS_ChoCh(0,0) cfHL(1) isCocDn := 1 isCocUp := 0 isBosUp := 0 else sweep(0,1) //Check for BoS if isBosUp == 0 if high > lastHH if close > lastHH BoS_ChoCh(1,1) cfHL(0) lastL := L lastLbar := Lbar isCocUp := 1 isBosUp := 1 isCocDn := 0 isBosDn := 0 else sweep(1,1) if isBosDn == 0 if low < lastLL if close < lastLL BoS_ChoCh(1,0) cfHL(1) lastH := H lastHbar := Hbar isCocUp := 0 isBosUp := 0 isCocDn := 1 isBosDn := 1 else sweep(0,0) //#endregion //#region internal structure if equalHL if high >= top if low > bot mnDn :=0 mnUp := 1 if low <= bot if high < top mnUp := 0 mnDn := 1 if mnUp[1] and not mnUp mnMark(1) if mnDn[1] and not mnDn mnMark(0) else if high > top if low > bot mnDn :=0 mnUp := 1 if low < bot if high < top mnUp := 0 mnDn := 1 if mnUp[1] and not mnUp mnMark(1) if mnDn[1] and not mnDn mnMark(0) if equalHL if high >= top puUp := high puUpbar := bar_index if low <= bot puDn := low puDnbar := bar_index top := high bot := low if high >= top top := high bot := low else if high > top puUp := high puUpbar := bar_index if low < bot puDn := low puDnbar := bar_index top := high bot := low if high > top top := high bot := low //#endregion //#region auto update High and Low vars if high > H or (high == H and equalHL) H := high Hbar := bar_index if high > idmS idmS := high idmS_bar := bar_index if high > lastH or (high == lastH and equalHL) lastH := high lastHbar := bar_index if high > lastHH or (high == lastHH and equalHL) lastHH := high lastHHbar := bar_index if low < L or (low == L and equalHL) L := low Lbar := bar_index if low < idmB idmB := low idmB_bar := bar_index if low < lastL or (low == lastL and equalHL) lastL := low lastLbar := bar_index if low < lastLL or (low == lastLL and equalHL) lastLL := low lastLLbar := bar_index //#endregion //#region live IDM if showliveIDM and barstate.islast [liveIDM, liveIDMbar] = if isCocUp and lastHL == Hbar [idmB, idmB_bar] else if isCocDn and lastHL == Lbar [idmS, idmS_bar] lv_line := line.new(liveIDMbar, liveIDM, bar_index + 20, liveIDM, color = idmColor, style = line.style_dotted), lv_lbl := label.new(bar_index + 20, liveIDM, "IDM", color = transp, textcolor = idmColor, style = isCocUp ? label.style_label_down : label.style_label_up, size = size.small) else lv_line := na lv_lbl := na line.delete(lv_line[1]) label.delete(lv_lbl[1]) //#endregion //#region fixing bugs // plot(H,"H") // plot(lastH, "lastH") // plot(lastHH, "lastHH") // plot(idmS, "idmS") // plot(puUp, "puUp") // plot(L,"L") // plot(lastL, "lastL") // plot(lastLL, "lastLL") // plot(idmB, "idmB") // plot(puDn, "puDn") //#endregion
Write, Run & Share Java code online using OneCompiler's Java online compiler for free. It's one of the robust, feature-rich online compilers for Java language, running the Java LTS version 17. Getting started with the OneCompiler's Java editor is easy and fast. The editor shows sample boilerplate code when you choose language as Java and start coding.
OneCompiler's Java online editor supports stdin and users can give inputs to the programs using the STDIN textbox under the I/O tab. Using Scanner class in Java program, you can read the inputs. Following is a sample program that shows reading STDIN ( A string in this case ).
import java.util.Scanner;
class Input {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter your name: ");
String inp = input.next();
System.out.println("Hello, " + inp);
}
}
OneCompiler supports Gradle for dependency management. Users can add dependencies in the build.gradle
file and use them in their programs. When you add the dependencies for the first time, the first run might be a little slow as we download the dependencies, but the subsequent runs will be faster. Following sample Gradle configuration shows how to add dependencies
apply plugin:'application'
mainClassName = 'HelloWorld'
run { standardInput = System.in }
sourceSets { main { java { srcDir './' } } }
repositories {
jcenter()
}
dependencies {
// add dependencies here as below
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
}
Java is a very popular general-purpose programming language, it is class-based and object-oriented. Java was developed by James Gosling at Sun Microsystems ( later acquired by Oracle) the initial release of Java was in 1995. Java 17 is the latest long-term supported version (LTS). As of today, Java is the world's number one server programming language with a 12 million developer community, 5 million students studying worldwide and it's #1 choice for the cloud development.
short x = 999; // -32768 to 32767
int x = 99999; // -2147483648 to 2147483647
long x = 99999999999L; // -9223372036854775808 to 9223372036854775807
float x = 1.2;
double x = 99.99d;
byte x = 99; // -128 to 127
char x = 'A';
boolean x = true;
When ever you want to perform a set of operations based on a condition If-Else is used.
if(conditional-expression) {
// code
} else {
// code
}
Example:
int i = 10;
if(i % 2 == 0) {
System.out.println("i is even number");
} else {
System.out.println("i is odd number");
}
Switch is an alternative to If-Else-If ladder and to select one among many blocks of code.
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;
}
For loop is used to iterate a set of statements based on a condition. Usually for loop is preferred when number of iterations is known in advance.
for(Initialization; Condition; Increment/decrement){
//code
}
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
}
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>);
Class is the blueprint of an object, which is also referred as user-defined data type with variables and functions. Object is a basic unit in OOP, and is an instance of the class.
class
keyword is required to create a class.
class Mobile {
public: // access specifier which specifies that accessibility of class members
string name; // string variable (attribute)
int price; // int variable (attribute)
};
Mobile m1 = new Mobile();
public class Greeting {
static void hello() {
System.out.println("Hello.. Happy learning!");
}
public static void main(String[] args) {
hello();
}
}
Collection is a group of objects which can be represented as a single unit. Collections are introduced to bring a unified common interface to all the objects.
Collection Framework was introduced since JDK 1.2 which is used to represent and manage Collections and it contains:
This framework also defines map interfaces and several classes in addition to Collections.
Collection | Description |
---|---|
Set | Set is a collection of elements which can not contain duplicate values. Set is implemented in HashSets, LinkedHashSets, TreeSet etc |
List | List is a ordered collection of elements which can have duplicates. Lists are classified into ArrayList, LinkedList, Vectors |
Queue | FIFO approach, while instantiating Queue interface you can either choose LinkedList or PriorityQueue. |
Deque | Deque(Double Ended Queue) is used to add or remove elements from both the ends of the Queue(both head and tail) |
Map | Map contains key-values pairs which don't have any duplicates. Map is implemented in HashMap, TreeMap etc. |