_SECTION_BEGIN("PRICE"); //////************** By Easyalgo.in *************////// ////// +91-8448735946, Support@easyalgo.in /////////// //***************************************************// SetChartOptions(0,chartShowArrows|chartShowDates); SetBarFillColor(IIf(C>O,ParamColor("Candle Up Color", colorLime),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey))); Plot(C,"Price",IIf(C>O,ParamColor("Shadow Up Color", colorGreen),IIf(C<=O,ParamColor("Shadow Color", colorBrown),colorLightGrey)),64,0,0,0,1); ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// paraIntraENTRYTime = ParamTime("Last trade Time", "15:04:00"); // IntraENTRYCond = TimeNum() <= paraIntraENTRYTime ; trcl=ParamTime("Trade Closing time","15:14:00"); IntraExitCond = TimeNum() >= trcl; Exittimecondition = IntraExitCond; _SECTION_END(); LastBar = Day() != Ref(Day(),2); NewDay = (Day()!= Ref(Day(), -1)) OR BarIndex() == 0; CandleDay = Day(); CandleDay1 = Ref(CandleDay, -1); FIRSTCandle = CandleDay != CandleDay1; KAM = NewDay AND FIRSTCandle ; ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// _SECTION_BEGIN("Trading controls"); barfr=Param("Candle From",3,1,100,1); barto=Param("Candle To",3,1,100,1); //buff=Optimize("Entry Buffer",0.00,0.00,100,0.05); nutr=Param("Number of Trades",1,1,50,1); //risk=Optimize("Risk Amount",100,10,10000,10); //tar=Param("Target Ratio",2.90,0.1,10,0.1); // 2.9 tar=Param("Target Ratio",80,0.1,500,0.1); // 2.9 tarmul = Param("Target Multiplier",1.5,0.1,100,0.5); ADD=Param("Buffer",50,0.0,100,0.5); ADDSL=Param("Stoploss",200,1,500,1); _SECTION_END(); _SECTION_BEGIN(" Line Calculations"); count = BarsSince(Day() != Ref(Day(),-1))+1; moh1= ValueWhen(count==barto,Max(C, O)+ADD,1); mol1= ValueWhen(count==barto,Min(O, C)-ADD,1); inday=ValueWhen(moh1 OR mol1,Day()); CL15 =ValueWhen(count==barto,C,1); _SECTION_END(); _SECTION_BEGIN(" Trade Calculations"); buy1=(H>=moh1); short1=(mol1>=L); mobarday=ValueWhen((moh1 OR mol1),Day(),1); sigday=ValueWhen((buy1 OR short1),Day(),1); sada=IIf(mobarday==sigday,1,0); diff=moh1-mol1; _SECTION_END(); RequestTimedRefresh( 1 ); _SECTION_BEGIN(" Trade Setup"); Buy5 = count>barto AND buy1 AND sada AND TimeNum()barto AND short1 AND sada AND TimeNum()trcl); Short5=ExRem(Short5,Buy5 OR TimeNum()>trcl); buysum=Sum(buy5,BarsSince(count==1)); shsum=Sum(short5,BarsSince(count==1)); tosum=buysum + shsum ; _Buy=buy5 ; _Short=short5 ; plotshapes(_Buy*shapeStar,colorGreen,0,L-1); plotshapes(_short*shapeStar,colorRed,0,H+1); _BuyPrice1=ValueWhen(_Buy,moh1); _ShortPrice1=ValueWhen(_Short,mol1); buta=_BuyPrice1+tar; // +diff //Buytarget shta=_ShortPrice1-tar; // diff //shorttarget BSL = _BuyPrice1-ADDSL ; //buy stoploss SSL = _ShortPrice1+ADDSL ; // short stoploss BSL2A = HHV(H,_Buy) ; //Buy trailing High SSL2A = LLV(L,_Short) ; // Short trailing Low BSL2 = BSL+(BSL2A-_BuyPrice1) ; //Buy trailing SL SSL2 = SSL-(_ShortPrice1-SSL2A) ; // Short trailing SL dn = Day(); newday = dn != Ref( dn, -1 ); bar=BarsSince(newday); _SECTION_END(); //Plot(BSL2,"BSL2A",colorYellow); lasttarget =0; targetflag=Tf=targetflag1=0; tradecount = 0; tc=0; check =0; l1 = Ref(L,-1); h1 = Ref(H,-1); notp = ParamToggle("Trade Entry after First Target","No_Entry|Entry",1); revtar = ParamToggle("Reverse Target or Normal Target","Reverse|Normal",0); //////************** By Easyalgo.in *************////// ////// +91-8448735946, Support@easyalgo.in /////////// //***************************************************// Buy = Sell = Short = Cover = Null; LongFlag = ShortFlag = Target = _BuyPrice = ShortTarget = 0; //Simple flags _shortprice = buytarget=shorttarget=t=st=bsl1=ssl1=bp=sp=0; buysl = shortsl=0; Starget= sstoploss = 0; LF=SF=0; //Using Loop to generate signals for( i = 0; i < BarCount; i++ ) { /////////////////////////////////////////Long Positions if(newday[i]) { targetflag=0; tradecount=0; targetflag1= 0; lasttarget=0; } //if(tradecount [i]==0 if( _Buy[ i ] AND LongFlag == 0 AND ShortFlag==0 AND targetflag==0 AND tradecount[i] <=nutr[i]) { Buy[ i ] = 1; BuyPrice[i]=_BuyPrice1[i]; _BuyPrice = _BuyPrice1[i]; LongFlag = 1; if(tradecount==1) { lasttarget = (tar[i]*tarmul[i]); } else if(tradecount==2) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]); } else if(tradecount==3) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]*tarmul[i]); } else if(tradecount==4) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]*tarmul[i]*tarmul[i]); } else if(tradecount==5) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]*tarmul[i]*tarmul[i]*tarmul[i]); } else { lasttarget = tar[i]; } buytarget = _BuyPrice[i]+(lasttarget[i]); buysl = BSL[i]; tradecount += 1 ; } if( LongFlag==1 AND High[i]>buytarget[i] ) { if(revtar[i]==1) { Sell[ i ] = 1; SellPrice[i] = Target[i]; LongFlag = 0; targetflag1 =1; } targetflag =1; if(notp[i]==0 AND revtar[i]==1) { targetflag1 =1; }else{targetflag1 =0;} } if( LongFlag==1 AND targetflag[i]==1 AND L1[i] > buytarget[i] AND L[i] < buytarget[i]) { Sell[ i ] = 1; SellPrice[i] = buysl[i]; LongFlag = 0; if(notp[i]==0) { targetflag1 =1; }else { targetflag1 =0; } targetflag =0; } if( LongFlag==1 AND L[i] < buysl[i]) { Sell[ i ] = 1; SellPrice[i] = buysl[i]; LongFlag = 0; targetflag =0; } if(LongFlag==1 AND Exittimecondition[i]) { Sell[ i ] = 1; SellPrice[i] = Open[i]; LongFlag = 0; } if( LongFlag==1 AND L[i] < BSL2[i]) { Sell[ i ] = 1; SellPrice[i] = BSL2[i]; LongFlag = 0; if( BSL2[i]> buytarget[i] AND notp[i]==0) { targetflag =0; targetflag1 =1; } else { targetflag1 =0; } } //////************** By Easyalgo.in *************////// ////// +91-8448735946, Support@easyalgo.in /////////// //***************************************************// /////////////////////////////////////////////////Short Positions if( _Short[ i ] AND LongFlag == 0 AND ShortFlag==0 AND targetflag==0 AND tradecount[i] <=nutr[i]) { Short[ i ] = 1; ShortPrice[i]=_ShortPrice1[i]; _ShortPrice = _ShortPrice1[i]; ShortFlag = 1; if(tradecount==1) { lasttarget = (tar[i]*tarmul[i]); } else if(tradecount==2) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]); } else if(tradecount==3) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]*tarmul[i]); } else if(tradecount==4) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]*tarmul[i]*tarmul[i]); } else if(tradecount==5) { lasttarget = (tar[i]*tarmul[i]*tarmul[i]*tarmul[i]*tarmul[i]*tarmul[i]); } else { lasttarget = tar[i]; } shorttarget = _ShortPrice[i]-(lasttarget[i]) ; Shortsl = SSL[i]; tradecount += 1 ; } if( ShortFlag==1 AND High[i]>Shortsl[i] ) { Cover[ i ] = 1; CoverPrice[i] = Shortsl[i]; ShortFlag = 0; targetflag =0; } if( ShortFlag==1 AND L[i] < shorttarget[i] ) { if(revtar[i]==1 ) { Cover[ i ] = 1; coverPrice[i] = shorttarget[i]; ShortFlag = 0; //targetflag1 =1; } if(notp[i]==0 AND revtar[i]==1) { targetflag1 =1; }else{targetflag1 =0;} targetflag =1; } if( ShortFlag==1 AND targetflag[i]==1 AND h1[i] < shorttarget[i] AND H[i] > shorttarget[i] AND revtar[i]==1) { Cover[ i ] = 1; CoverPrice[i] = shorttarget[i]; ShortFlag = 0; if(notp[i]==0 ) { targetflag1 =1; }else{targetflag1 =0;} targetflag=0; } if(ShortFlag==1 AND Exittimecondition[i]) { Cover[ i ] = 1; COverPrice[i] = Open[i]; ShortFlag = 0; targetflag=0; } //////************** By Easyalgo.in *************////// ////// +91-8448735946, Support@easyalgo.in /////////// //***************************************************// if(ShortFlag==1 AND h[i]>SSL2[i]) { Cover[ i ] = 1; COverPrice[i] = SSL2[i]; ShortFlag = 0; if( SSL2[i]< shorttarget[i] AND notp[i]==0) { targetflag =0; targetflag1 =1; } else { targetflag1 =0; } } //////////////// Reinitiate for reverse signal/////////////////////////// check[i] = lasttarget[i]; bt[i] = buyTarget[i]; St[i] = ShortTarget[i]; bsl1[i] = buysl[i]; ssl1[i]= shortsl[i]; bp[i] = _buyprice[i]; sp[i]= _shortprice[i]; LF[i] = longflag[i];; SF[i] =shortflag[i]; tc[i] = tradecount[i]; } "LF = "+lf; "bp = "+bp; "bt = "+bt; "bsl1 ="+bsl1; ""; "SF = "+Sf; "Sp = "+Sp; "St = "+St; "Ssl1 ="+Ssl1; ""; "TC = "+tc; ""; "check = "+check; //GfxTextOut("Check = "+check,30,80); ""; Buyflag = Flip(Buy,Sell); Shortflag11 = Flip(Short,cover); PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorGreen, 0, L, Offset = -40 ); PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorLime, 0, L, Offset = -50 ); PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, 0, L, Offset = -45 ); PlotShapes( IIf( Sell , shapeDownArrow, shapeNone ), colorRed, 0, H, Offset = -45 ); PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorRed, 0, H, Offset = 40 ); PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorOrange, 0, H, Offset = 50 ); PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorWhite, 0, H, Offset = -45 ); PlotShapes( IIf( Cover , shapeUpArrow, shapeNone ), colorBlue, 0, L, Offset = -45 ); //////************** By Easyalgo.in *************////// ////// +91-8448735946, Support@easyalgo.in /////////// //***************************************************// ///////////////////////////////////////////////////////////////////////////////////////// Filter= Buy OR Short ; SetSortColumns(- 2 ) ; AddColumn( IIf(Buy , 66,IIf (Short ,83,660000)),"B/S", formatChar ,colorBlue,colorWhite); AddColumn(Close,"Close",1.2); dist = 0.5*ATR(20); for( i = 0; i < BarCount; i++ ) { if( Buy [i] ) PlotText( "" + BuyPrice [ i ], i, L[ i ]-dist[i], colorCustom11); if( Short [i] ) PlotText( "" + ShortPrice [ i ], i, H[ i ]+dist[i], colorCustom12); } dist = 0.5*ATR(20); for( i = 0; i < BarCount; i++ ) { if( Cover [i] ) PlotText( "" + CoverPrice [ i ], i, L[ i ]-dist[i], colorCustom11); if( Sell [i] ) PlotText( "" + SellPrice [ i ], i, H[ i ]+dist[i], colorCustom12); } SetChartOptions(0,chartShowArrows|chartShowDates); Title =StrFormat("{{DATE}} Op %g, Hi %g, Lo %g, Cl %g (%.1f%%) ",O,H,L,C, SelectedValue( ROC(C,1))); ////////////////////////////////////////////////////////////////////////////////////////////////////////// Long=Flip(Buy,Ref(Sell,-10) OR IntraExitCond ); Shrt=Flip(Short ,Ref(Cover,-10)OR IntraExitCond ); Long5=Flip(Buy,Sell); Shrt5=Flip(Short,Cover); _SECTION_BEGIN("Dashboard"); showMsgBoard = ParamToggle("show MsgBoard ", "Hide|Show", 1); ShowEntryLine = ParamToggle("Show Entry Lines", "Hide|Show", 1); ShowTGTLine = ParamToggle("Show TGT Lines", "Hide|Show", 1); ShowSLLine = ParamToggle("Show SL Lines", "Hide|Show", 1); Plot(IIf(Buyflag AND ShowTGTLine,bt,Null),"",colorCustom12, 1|styleThick); Plot(IIf(Shortflag11 AND ShowTGTLine,st,Null),"",colorCustom11, 1|styleThick); Plot(IIf(Buyflag AND ShowSLLine,bsl,Null),"",colorred,styleDashed); Plot(IIf(Shortflag11 AND ShowSLLine,SSL,Null),"",colorred,styleDashed); Plot(IIf(Buyflag AND ShowEntryLine,BP,Null),"",colorWhite,styleDashed); Plot(IIf(Shortflag11 AND ShowEntryLine,SP,Null),"",colorWhite,styleDashed); Plot(IIf(Buyflag,BSL2,Null),"",colorAqua,44); Plot(IIf(Shortflag11,SSL2,Null),"",colorAqua,44); SetChartOptions(0, chartShowDates); Title = EncodeColor(colorCustom7)+" *** MAX 2 SYSTEM *** " +EncodeColor(colorCustom3) +" "+ Interval(2) + " - " + Date() + EncodeColor(ColorRGB( 10,100,250)) + " OPEN : " + O + EncodeColor(colorbrightGreen)+ " , HIGH : " + H + EncodeColor(colorCustom5)+ " , LOW : " + L + EncodeColor(colorCustom3)+ " , CLOSE : " + C ; ////////////////////////////////////////////////////////////////////////////////// _Section_Begin("Message Board"); Inlong = Flip(Buy, Sell AND LF==0); Inshort = Flip(Short,Cover AND SF==0); InlongExit = Flip(Sell AND LF==0, Buy) AND !Flip(Cover AND SF==0, Buy) ; InshortExit = Flip(Cover AND SF==0,Short) AND !Flip(Sell AND LF==0, Short); Yexitlong = InlongExit AND InshortExit==False; YexitShort = InSHORTExit AND InLONGExit==False; //////************** By Easyalgo.in *************////// ////// +91-8448735946, Support@easyalgo.in /////////// //***************************************************// Ybuyprice = ValueWhen(Buy,bp); Yshortprice = ValueWhen(short,sp); YCOVERPRICE = ValueWhen(Cover,CoverPrice); YSELLPRICE = ValueWhen(Sell, SellPrice); //YCoverprice = ValueWhen(Cross(Cover,Short),CoverPrice,1) ; //YSellprice =ValueWhen(Cross(Sell,Buy),SellPrice,1); Messageboard = Paramlist("Message Board", "Show|Hide", 0); DatetimBuy = "" + ValueWhen( Buy, Day(), 1 ) + "/" + ValueWhen( Buy, Month(), 1 ) + "/" + ValueWhen( Buy, Year(), 1 ) + " " + ValueWhen( Buy, Hour(), 1 ) + ":" +WriteIf(Minute() <10, "0", "") + ValueWhen( Buy, Minute(), 1 ); DatetimShort = "" + ValueWhen( Short, Day(), 1 ) + "/" + ValueWhen( Short, Month(), 1 ) + "/" + ValueWhen( Short, Year(), 1 ) + " " + ValueWhen( Short, Hour(), 1 ) + ":" +WriteIf(Minute() <10, "0", "") + ValueWhen( Short, Minute(), 1 ); //TM_QUANTITY = Param("Quantity", 1, 0, 300000, 10); //qty = IIf(btflag1 OR stflag1, round(TM_QUANTITY/2),TM_QUANTITY); //qty = valuewhen(Cover OR Sell ,qty); // Replace this variable for exit qty If(Messageboard=="Show") { Gfxselectfont( "Tahoma", 13, 100 ); Gfxsetbkmode( 1 ); Gfxsettextcolor( colorWhite); If (SelectedValue(Inlong)==1) { GfxSelectSolidBrush( colorCustom13 ); // This Is The Box Background Color } else If (SelectedValue(Inshort)==1) { GfxSelectSolidBrush( colorOrange ); // This Is The Box Background Color } else { GfxSelectSolidBrush( colorBlue ); } Ychartleft = Status("Pxchartleft") ; // Left Side Of Chart Ychartright = Status("Pxchartright"); // Right Side Of Chart Ycharttop = Status("Pxcharttop"); // Top Side Of Chart Ychartbottom = Status("Pxchartbottom"); // Bottom Side Ofthe Chart Ychartwidth = Status("Pxchartwidth"); Ychartheight= Status("Pxchartheight"); Fs = (Status("Pxchartwidth") + Status("Pxchartheight")); Gfxselectpen( Colorlightblue, 1); // Border Color Gfxroundrect( Ychartleft*0.5, Ychartbottom, Ychartright*0.27, Ychartbottom*0.80, Ychartwidth*0.005, Ychartwidth*0.005 ); Gfxsetbkmode(1); Gfxsettextalign(0|24); Gfxselectfont( "Tahoma",Fs*0.0060, 800 ); GfxSetTextColor( colorWhite ); If ( Selectedvalue(LF) == 1 ) Gfxtextout( "System is in Long Position", Ychartright*0.005,Ychartbottom*0.83); If ( Selectedvalue(SF) == 1 ) Gfxtextout( "System is in Short Position", Ychartright*0.005,Ychartbottom*0.83); If ( Selectedvalue(LF OR SF) == 1 ) Gfxtextout( "...............................................", Ychartright*0.005,Ychartbottom*0.85); If ( Selectedvalue(!SF And !LF) == 1 ) Gfxtextout( "Waiting For Next Singal", Ychartright*0.005,Ychartbottom*0.85); If ( Selectedvalue(!SF And !LF AND InlongExit) == 1 ) Gfxtextout( "Last Long Trade P/L = "+Prec((YSellPrice - YBuyprice ),2), Ychartright*0.005,Ychartbottom*0.94); If ( Selectedvalue(!Inshort And !Inlong AND InShortExit) == 1 ) Gfxtextout( "Last Short Trade P/L = "+Prec((YShortprice - YCoverprice),2), Ychartright*0.005,Ychartbottom*0.94); If ( Selectedvalue(Inlong) == 1 ) Gfxtextout( "Buy Signal : "+DatetimBuy, Ychartright*0.005,Ychartbottom*0.88); If ( Selectedvalue(Inshort) == 1 ) Gfxtextout( "Short Signal: "+Datetimshort, Ychartright*0.005,Ychartbottom*0.88); if ( SelectedValue(Inlong) == 1 ) GfxTextOut( "Buy Entry@ : "+Ybuyprice, Ychartright*0.005,Ychartbottom*0.915); if ( SelectedValue(Inshort) == 1 ) GfxTextOut( "Short Entry@ : "+Yshortprice, Ychartright*0.005,Ychartbottom*0.915); if ( SelectedValue(Inlong) == 1 ) GfxTextOut("Buy TP : "+BT + " TSL : "+BSL2, Ychartright*0.005,Ychartbottom*0.95); if ( SelectedValue(Inshort) == 1 ) GfxTextOut("Short TP : "+ST+ " TSL : "+SSL2, Ychartright*0.005,Ychartbottom*0.95); if ( SelectedValue(Inlong) == 1 ) GfxTextOut("Current P/L : "+Prec((Close - Ybuyprice),2), Ychartright*0.005,Ychartbottom*0.985); if ( SelectedValue(Inshort) == 1 ) GfxTextOut("Current P/L : "+Prec((Yshortprice- Close),2), Ychartright*0.005,Ychartbottom*0.985); } _Section_End(); //////************** By Easyalgo.in *************////// ////// +91-8448735946, Support@easyalgo.in /////////// //***************************************************// GfxSetBkMode(1); _SECTION_BEGIN("NMN Chart Stamp"); SetFormulaName("NMN Chart Stamp"); GfxFont = "Times New Roman"; GfxSetOverlayMode(0); GfxSelectFont(GfxFont, Status("pxheight")/25); GfxSetTextAlign(6); // center alignment GfxSetTextColor(ColorRGB(100,100,100)); GfxSetBkMode(0); // transparent GfxTextOut(Name(), Status("pxwidth")/2, Status("pxheight")/12); GfxSetTextColor(ColorRGB(200,200,200)); GfxTextOut("Easyalgo.in", Status("pxwidth")/1.15, Status("pxheight")/1.15); //GfxSelectFont(GfxFont, Status("pxheight")/28); //GfxSelectFont(GfxFont, Status("pxheight")/18); //GfxSelectFont("Tahoma", Status("pxheight")/18); _SECTION_END();