#### bunti_k23

##### Well-Known Member
So after a long time, i have decided to go with this trading system and want to automate this on MT4 platform as amibroker does not connect with forex brokers mostly. Below is the code of trading system attached which i want to convert it to MT4. I have found 1 excell money management sheet which is specifically for binary options, i am not a coding literate person so i am unable to understand the calculations behind it. so i am attaching the code of system with backtested data manually on historical charts of nifty. kindly take a look and if interested convert code to MT4, also i want to integrate this masaniello calculation into MT4 code of trading system.

Each trading session consist of 100 trades in which wins and losses are shown in the image 1,2 and 3.
it is mentioned as

Events Won
Lost Events

in configure masaniello we are taking initial capital as \$100 and we are going to take 100 trades(Total events). we know our trading systems winning percentage as 50% (50 trades will be won in 100 trades). Quota is the profit factor given by iqoptions it is changing as per market like 86% 90% 92% or 94% max i saw. that means when traded for 1\$ we will win \$ 0.96 and lose complete \$1.

#### Attachments

• 319.2 KB Views: 5
• 319.3 KB Views: 5
• 318.2 KB Views: 3
• 12.2 KB Views: 7
• 12.3 KB Views: 7
• 12.4 KB Views: 5

#### bunti_k23

##### Well-Known Member
Code:
``````_SECTION_BEGIN("SMART TRADE ZONES");
x=BarIndex();
rightStrength=Param("Fractal Pivot Right side Strength",3,0,50,1);
leftStrength=Param("Fractal Pivot Left side Strength",4,0,50,1);
pk=H>Ref(HHV(H,leftStrength),-1) AND Ref(HHV(H,rightStrength),-rightStrength)<=H;
tr=L<Ref(LLV(L,leftStrength),-1) AND Ref(LLV(L,rightStrength),-rightStrength)>=L;
PHigh = PK;
PHighPrice0 = ValueWhen(PHigh,H);
PHighPrice1 = IIf(PHighPrice0 AND BarsSince(PHigh) > rightStrength,PHighPrice0,Null);
PHighPrice2 = IIf(PHighPrice0 AND BarsSince(PHigh) <= rightStrength,PHighPrice0,Null);
PLow = TR;
PLowPrice0 = ValueWhen(PLow,L);
PLowPrice1 = IIf(PLowPrice0 AND BarsSince(Plow) > rightStrength,PLowPrice0,Null);
PLowPrice2 = IIf(PLowPrice0 AND BarsSince(Plow) <= rightStrength,PLowPrice0,Null);

//pk=ExRem(pk,tr);
//tr=ExRem(tr,pk);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

ll=tr AND tl1<tl2;
hl=tr AND tl1>tl2;
hh=pk AND ph1>ph2;
lh=pk AND ph1<ph2;
dt=pk AND ph1==ph2;
db=tr AND tl1==tl2;

ll_h=IIf(ll,1,0);
hl_h=IIf(hl,2,0);
hh_h=IIf(hh,3,0);
lh_h=IIf(lh,4,0);
dt_h=IIf(dt,5,0);
db_h=IIf(db,6,0);
combi=ll_h+hl_h+lh_h+hh_h;

t0=ValueWhen(combi,combi,0);
t1=ValueWhen(combi,combi,1);
t2=ValueWhen(combi,combi,2);
t3=ValueWhen(combi,combi,3);
t4=ValueWhen(combi,combi,4);

GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(C,"\nLast",colorWhite,64);

Plot(PHighPrice1,"\nPHighPrice",colorOrange,styleLine);
Plot(PHighPrice2,"",colorOrange,styleDots | styleNoLine);
Plot(PLowPrice1,"\nPLowPrice",colorBrightGreen,styleLine);
Plot(PLowPrice2,"",colorBrightGreen,styleDots | styleNoLine);

PH =Phigh- Ref(Phigh,-1) != 0;
PHprice = ValueWhen(PH, H,1);
Pvalid = C > ValueWhen(PH, PHighPrice2,1 ) ;
Pvalid = ExRem(Pvalid, PH);
Sell = Pvalid ;

PL= Plow - Ref(Plow,-1) != 0;
PLPrice = ValueWhen(PL,L,1);
TValid = C < ValueWhen(PL, PLowPrice2,1) ;
TValid = ExRem(TValid, PL);

Short    =    Sell;

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorWhite, colorWhite ),0, IIf( Buy, Low, High ) );``````

#### bunti_k23

##### Well-Known Member
Code:
``````_SECTION_BEGIN("SMART TRADE ZONES");
x=BarIndex();
rightStrength=Param("Fractal Pivot Right side Strength",3,0,50,1);
leftStrength=Param("Fractal Pivot Left side Strength",4,0,50,1);
pk=H>Ref(HHV(H,leftStrength),-1) AND Ref(HHV(H,rightStrength),-rightStrength)<=H;
tr=L<Ref(LLV(L,leftStrength),-1) AND Ref(LLV(L,rightStrength),-rightStrength)>=L;
PHigh = PK;
PHighPrice0 = ValueWhen(PHigh,H);
PHighPrice1 = IIf(PHighPrice0 AND BarsSince(PHigh) > rightStrength,PHighPrice0,Null);
PHighPrice2 = IIf(PHighPrice0 AND BarsSince(PHigh) <= rightStrength,PHighPrice0,Null);
PLow = TR;
PLowPrice0 = ValueWhen(PLow,L);
PLowPrice1 = IIf(PLowPrice0 AND BarsSince(Plow) > rightStrength,PLowPrice0,Null);
PLowPrice2 = IIf(PLowPrice0 AND BarsSince(Plow) <= rightStrength,PLowPrice0,Null);

//pk=ExRem(pk,tr);
//tr=ExRem(tr,pk);

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

ll=tr AND tl1<tl2;
hl=tr AND tl1>tl2;
hh=pk AND ph1>ph2;
lh=pk AND ph1<ph2;
dt=pk AND ph1==ph2;
db=tr AND tl1==tl2;

ll_h=IIf(ll,1,0);
hl_h=IIf(hl,2,0);
hh_h=IIf(hh,3,0);
lh_h=IIf(lh,4,0);
dt_h=IIf(dt,5,0);
db_h=IIf(db,6,0);
combi=ll_h+hl_h+lh_h+hh_h;

t0=ValueWhen(combi,combi,0);
t1=ValueWhen(combi,combi,1);
t2=ValueWhen(combi,combi,2);
t3=ValueWhen(combi,combi,3);
t4=ValueWhen(combi,combi,4);

GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(C,"\nLast",colorWhite,64);

Plot(PHighPrice1,"\nPHighPrice",colorOrange,styleLine);
Plot(PHighPrice2,"",colorOrange,styleDots | styleNoLine);
Plot(PLowPrice1,"\nPLowPrice",colorBrightGreen,styleLine);
Plot(PLowPrice2,"",colorBrightGreen,styleDots | styleNoLine);

PH =Phigh- Ref(Phigh,-1) != 0;
PHprice = ValueWhen(PH, H,1);
Pvalid = C > ValueWhen(PH, PHighPrice2,1 ) ;
Pvalid = ExRem(Pvalid, PH);
Sell = Pvalid ;

PL= Plow - Ref(Plow,-1) != 0;
PLPrice = ValueWhen(PL,L,1);
TValid = C < ValueWhen(PL, PLowPrice2,1) ;
TValid = ExRem(TValid, PL);