Set chart as 1 min candle stick
Logic starts when market is in sell mode
Analyse market to sell mode by EMA 20 - 50 down
for the same example chart.jpg is enclosed for the reference with the variables marked on it
-Logic starts only when market hit bottom of the day
- record the highest price above EMA20-EMA50 - store it in variable - r1 (7984)
- price comes down record lowest price store it in variable - r2 (7975)
if r2 >= EMA 20 & EMA 50 then - EMA20 IS 7974.18 EMA50 7973.48
continue
else
exit from the logic
- program exit mode - if price goes below r2 exit from logic
- continue
- price goes above r1 record highest price in variable - r3 (8003.43)
- price comes down record the lowest price - r4 (7985.35)
if r4 < r2 then
exit from the logic
else
- continue
- after this 1st white candle comes record highest point - r5 (7988.7)
- buy above r5 trigger price (r5+0.5) trade price (r5+0.5+1)
- set stop loss as r4
- set exit price as (r5+0.5+1+12)
Logic starts when market is in sell mode
Analyse market to sell mode by EMA 20 - 50 down
for the same example chart.jpg is enclosed for the reference with the variables marked on it
-Logic starts only when market hit bottom of the day
- record the highest price above EMA20-EMA50 - store it in variable - r1 (7984)
- price comes down record lowest price store it in variable - r2 (7975)
if r2 >= EMA 20 & EMA 50 then - EMA20 IS 7974.18 EMA50 7973.48
continue
else
exit from the logic
- program exit mode - if price goes below r2 exit from logic
- continue
- price goes above r1 record highest price in variable - r3 (8003.43)
- price comes down record the lowest price - r4 (7985.35)
if r4 < r2 then
exit from the logic
else
- continue
- after this 1st white candle comes record highest point - r5 (7988.7)
- buy above r5 trigger price (r5+0.5) trade price (r5+0.5+1)
- set stop loss as r4
- set exit price as (r5+0.5+1+12)
Code:
GraphXSpace =15;
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetPositionSize(1,4);
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
/////////////////
tf = Param( "TF", 1, 1, 1000, 1 );
TimeFrameSet(in1Minute*tf );
SetBarsRequired(sbrAll,sbrAll);
xx=BarIndex();x=xx;Lx=LastValue(x);
rightStrength=Optimize("R_S",Param("R_S",3,1,50,1) ,1,50,1);
leftStrength=Optimize("L_S",Param("L_S",3,1,50,1), 1,50,1);
function pkID(rightStrength,leftStrength)
{
pk=H>Ref(HHV(H,leftStrength),-1) AND H>=Ref(HHV(H,rightStrength),rightStrength);
return pk;
}
function trID(rightStrength,leftStrength)
{
tr=L<Ref(LLV(L,leftStrength),-1) AND L<=Ref(LLV(L,rightStrength),rightStrength);
return tr;
}
pk=pkID(rightStrength,leftStrength);
tr=trID(rightStrength,leftStrength);
SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0 ,chartShowDates);
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
pkHigh1=Ref(ValueWhen(pk,H,1),-(rightStrength+1));
trLow1=Ref(ValueWhen(Tr,L,1),-(rightStrength+1));
pkHigh0=ValueWhen(pk,H,0);
trLow0=ValueWhen(Tr,L,0);
Plot(pkHigh1,"",colorBlue,24,Null,Null,0,2,1);
Plot(trLow1,"",colorRed,24,Null,Null,0,2,1);
TimeFrameRestore();
////////////////////////