/*[[ Name := New_ASCTrend3 Author := C0Rpus - big thanks CHANGE2002, STEPAN and SERSH Notes := ASCTrend2 3.0 Open Source Separate Window := No First Color := LightGreen First Draw Type := Symbol First Symbol := 119 Use Second Data := Yes Second Color := LightCoral Second Draw Type := Symbol Second Symbol := 119 ]]*/ Inputs: RISK(3),MONYRISK(1.5),AllBars(500); Variables: value1(1),value2(18),value3(9),value4(0),value5(0),value7(0),value8(0),value9(0),value10(10); Variables: value11(0),value12(0),value13(0),value14(0),value15(0),value16(0),value17(0),value18(0),value19(0); Variables: value4_1(0),value5_1(0),value5_2(0),value9_1(0),value10_1(0),value11_1(0),value12_1(0); Variables: value17_1(0),value17_2(0); Variables: value20(70),value21(30); Variables: TrueCount(0),Counter(0),Range(0),AvgRange(0),AvgRange_1(0),AvgRange_2(0); Variables: MRO(0),MRO1(0),MRO2(0),ASCVTV2(0); Variables: val1(0),val2(0),val5(0),val6(0),val7(0),val10(0),val20(0),shift(0),NumBars(0); Variables: LC(0),HC(0),k(0),Length(0),Const(0),TR(0),SW(0); Variables: condition1(False),condition2(False); Variables: Pass8(0); // 576 SetLoopCount(0); If Bars= Average(Range,10)*2.0,9,1)>-1 // then value4 = 3 // else value4 = value3; Counter=shift; TrueCount=0; While Counter= Range*2.0 Then TrueCount++;//TrueCount=TrueCount+1; Counter++;//Counter=Counter+1; }; if TrueCount >= 1 then MRO = Counter else MRO = -1; If MRO > -1 Then value4=3 Else value4=value3; // ----- // if MRO( AbsValue(C[3]-C)>= Average(Range,10)*4.6,6,1)>-1 then value4 = 4 else value4 = value3; Counter=shift; TrueCount=0; While Counter= Range*4.6 Then TrueCount++;//TrueCount=TrueCount+1; Counter++;//Counter=Counter+1; }; if TrueCount >= 1 then MRO = Counter else MRO = -1; If MRO > -1 Then value4=4 Else value4=value3; // ----- // End of // if MRO( AbsValue(O-C[1])>= Average(Range,10)*2.0,9,1)>-1 then value4 = 3 else value4 = value3; // if MRO( AbsValue(C[3]-C)>= Average(Range,10)*4.6,9,1)>-1 then value4 = 4 else value4 = value3; // ----------------------------------- value17=Abs(iWPR(value4,shift)); // PercentR(value4,shift) if value17 > 70 then { condition1 = True; condition2 = False; }; if value17 < 30 then { condition1 = False; condition2 = True; }; // ------------------------------------------------ // value5 = JESSD(High,Low,H[value1],L[value1],C[value1]); /* AvgRange=(High[shift]+Low[shift])/2.0; If Close[shift+value1]value5[1] And value5[1]-1 and L[1]>value5[1] // then value7 = value5[1]+value18*0.8; // if MRO( value5value5[2],2,1)>-1 and H[1]value5_1 And value5_1=1 Then MRO1=Counter-shift-1 Else MRO1=-1; // ----- Counter=shift; TrueCount=0; While Countervalue5_2) Then TrueCount++;//TrueCount+=1;TrueCount=TrueCount+1; Counter++;//Counter+=1; Counter=Counter+1; }; If TrueCount>=1 Then MRO2=Counter-shift-1 Else MRO2=-1; // ----- //value4_1=UserFunction("JESSD",High[shift+1],Low[shift+1],High[shift+1+value2],Low[shift+1+value2],Close[shift+1+value2]); AvgRange_1=(High[shift+1]+Low[shift+1])/2.0; If Close[shift+1+value1]-1 And Low[shift+1] >value5_1) Then value7 = value5_1 - value18*(0.382 + 0.1*RISK); If (MRO2>-1 And High[shift+1]value5[1] And value5[1]-1 and LC[1]>value5[1] then value7 = value5[1]+value18*0.8; // if MRO( value5value5[2],2,1)>-1 and HC[1]=70 then value13 = Min(Close[shift+1],Low[shift]) - value18*0.1*RISK; if value17_1>30 and value17<=30 then value14 = Max(Close[shift+1],High[shift])+ value18*0.1*RISK; if Abs(Open[shift]-Close[shift+1])>= Range*1.618 then { if value17_1<70 and value17>=70 then value13 = Low[shift] -value18*0.1*RISK; if value17_1>30 and value17<=30 then value14 = High[shift]+value18*0.1*RISK; }; //value9=UserFunction("BS105",Low[shift],1.618,value18,value11); If ( (Low[shift]-1.618*value18) < value11 ) Then { value9=value11; } Else { value9=Low[shift]-1.618*value18; }; //value10=UserFunction("SS105",High[shift],1.618,value18,value12); If ( (High[shift]+1.618*value18) > value10 ) Then { value10=value12; } Else { value10=High[shift]+1.618*value18; }; // -------------------------------------- // value11=UserFunction("BS0",Low[shift],70,value9,RISK,value19); value11=value9; // value12=UserFunction("SS0",High[shift],70,value10,RISK,value19); value12=value10; // --------------------------------------- if Low[shift] - value11 > value19/Point then value11 = Low[shift] - (1 + 0.1*RISK)*value18; if value12 - High[shift]> value19/Point then value12 = High[shift] + (1 + 0.1*RISK)*value18; // --------------------------------------- if value15 >= value16 and value7 >= value11 then value11 = value7; if value15 <= value16 and value8 <= value12 then value12 = value8; if value15 <= value16 and value7 <= value11 then value11 = value7; if value15 >= value16 and value8 >= value12 then value12 = value8; if value13 > value11 then value11 = value13; if value14 < value12 then value12 = value14; // -------------------------------------- // if (MRO(value17>70,2,2)>-1 and value11<=value11[1] then value11=value11[1]; // if (MRO(value17<30,2,2)>-1 and value12>=value12[1] then value12=value12[1]; TrueCount=0; If value17_2>70 Then TrueCount++;//TrueCount=TrueCount+1; If value17_1>70 Then TrueCount++;//TrueCount=TrueCount+1; If value17 >70 Then TrueCount++;//TrueCount=TrueCount+1; If TrueCount>=2 Then MRO1=1 Else MRO1=-1; TrueCount=0; If value17_2<30 Then TrueCount++;//TrueCount=TrueCount+1; If value17_1<30 Then TrueCount++;//TrueCount=TrueCount+1; If value17 <30 Then TrueCount++;//TrueCount=TrueCount+1; If TrueCount>=2 Then MRO2=1 Else MRO2=-1; if MRO1>-1 and value11<=value11_1 then value11 = value11_1; if MRO2>-1 and value12<=value12_1 then value12 = value12_1; // --------------------------------------- // if value11>0 and condition1 and C>ASCVT2(14,3,100188) and value11<=HC then Plot1(value11,"BuyStop3"); // if value12>0 and condition2 and C=LC then Plot2(value12,"SellStop3"); Length = 14; Const = 3; val1 = 0; Pass8 = 100188; if Pass8 = 100188 then { for k=1 to Length-1 { val1 += Max(Close[k+1],High[k]) - Min(Close[k+1],Low[k]) ; // TrueRange[k] = TrueHigh[k] - TrueLow[k] }; TR = Max(Close[shift+1],High[shift])-Min(Close[shift+1],Low[shift]) ; val5 = val1/(Length-1); val6 = ( val5*(Length-1)+ TR )/Length; val7 = (13*val6 + TR)/14; LC = Close[shift]; HC = Close[shift]; for k=1 to Length { if LC > Close[shift+k] then LC = Close[shift+k]; if HC < Close[shift+k] then HC = Close[shift+k]; }; val10 = LC + val6*Const; //short Stop val20 = HC - val6*Const; //long Stop if Close[shift]>=val10 then SW = 1; // Long position if Close[shift]<=val20 then SW = 0; // Short position if SW = 1 then ASCVTV2 = value20; if SW = 0 then ASCVTV2 = value10; } else ASCVTV2 = Close[shift]; if value11>0 and condition1 and Close[shift]>ASCVTV2 and value11<=High[shift] then SetIndexValue(shift,value11); if value12>0 and condition2 and Close[shift]=Low[shift] then SetIndexValue2(shift,value12); /* // BOBuy if value17>value20 and Close[shift+1]value12 then SetIndexValue(shift,value12); // BOSell if value17value11_1 and Close[shift]