There is some alteration logic am trying to include in the code, but couldn't succeed. can any help me with my requirement.
Re-entry of order after the system exited a trade. For example, when short is initiated at 8000 and a maximum stop loss of 50 points hits at 8050, the system exits the trade. after a while if markets goes down below the entry point then short order should be initiated again.
can the above requirement be coded?
Re-entry of order after the system exited a trade. For example, when short is initiated at 8000 and a maximum stop loss of 50 points hits at 8050, the system exits the trade. after a while if markets goes down below the entry point then short order should be initiated again.
can the above requirement be coded?
Code:
//SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorGold)+ "Jackpot system" + EncodeColor(colorRose)+" (" + Name() + ") " + EncodeColor(colorGold)+ Interval(2) +
" " + Date() +" " +" • Open "+WriteVal(O,1.2)+" • "+"Hi "+WriteVal(H,1.2)+" • "+"Lo "+WriteVal(L,1.2)+" • "+
"Close "+WriteVal(C,1.2)+" ("+WriteVal(C-Ref(C,-1),1,0)+" "+WriteVal((C-Ref(C,-1))*100/Ref(C,-1),1.1)+ "%) • Vol= "+ WriteVal(V,1.0)
);
SetPositionSize(1,spsShares);
_SECTION_BEGIN("System");
e= EMA(C,49);
//Conditions for Buying
Cond1 = ValueWhen(C,O<C);
Cond5 = e > Ref(e,-1);
//Conditions for Selling
Cond10 = e < Ref(e,-1);
e[BarCount-1]=Null;
e[BarCount-1]=Null;
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
Buy = Cond5 ;
Sell = cond10 ;
Buy[BarCount-1]=Null;
Sell[BarCount-1]=Null;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell ;
Cover=Buy ;
BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);
StopLevel = 10;
ApplyStop( stopTypeLoss, stopModePoint, stoplevel, 1 );
Equity( 1, 0 ); // evaluate stops, all quotes
SetOption("EveryBarNullCheck", True );
Buystop = IIf( Buy, BuyPrice-Stoplevel , Null );
Shortstop = IIf( Short, ShortPrice+Stoplevel , Null );
Plot( Buystop, "Buystop", colorRed );
Plot( Shortstop, "Shortstop", colorGreen );
PlotShapes(IIf(Sell==2, shapeHollowCircle, shapeNone), colorYellow, 0,High, Offset=30);
PlotShapes(IIf(Cover==2, shapeHollowCircle, shapeNone), colorYellow, 0,Low, Offset=-30);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-30);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy);
BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
Edc=(
WriteIf (Buy AND Ref(shrt,-1), " BUY@ "+C+" ","")+
WriteIf (Sell AND Ref(Long,-1), " SEll@ "+C+" ","")+
WriteIf(Sell , "Last Trade Profit Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Last trade Profit Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade: Long Profit: "+WriteVal((C-BuyPrice))+"","")+
WriteIf(shrt AND NOT Sell, "Trade: Short Profit: "+WriteVal((SellPrice-C))+"",""));
dist = 3*ATR(10);
dist1 = 3*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] )
{
PlotText( "\nBuy@:" + C[ i ], i, C[ i ]-dist[i], colorGreen, colorDarkOliveGreen );
}
if( Sell[i] )
{
PlotText( "Sell@:" + C[ i ], i, C[ i ]+dist1[i], colorRed, colorDarkOliveGreen );
}
}