PaPP v2: MA monotonic alignment filter (no mean reversion in trends)
This commit is contained in:
+18
-17
@@ -154,14 +154,24 @@ void OnTick()
|
|||||||
//--- Reset escursion flags quando price rientra nel cluster
|
//--- Reset escursion flags quando price rientra nel cluster
|
||||||
if(bid>=buyBand && bid<=sellBand) { buyFired=false; sellFired=false; }
|
if(bid>=buyBand && bid<=sellBand) { buyFired=false; sellFired=false; }
|
||||||
|
|
||||||
|
//--- MA alignment: se tutte monotone = trend, blocca mean reversion
|
||||||
|
bool trendUp=true, trendDown=true;
|
||||||
|
for(int m=0;m<7;m++)
|
||||||
|
if(mv[m] > mv[m+1]) trendUp=false;
|
||||||
|
else if(mv[m] < mv[m+1]) trendDown=false;
|
||||||
|
else { trendUp=false; trendDown=false; }
|
||||||
|
bool allowBuy = !buyFired && nBuy<MaxPosPerSide && !trendDown;
|
||||||
|
bool allowSell = !sellFired && nSell<MaxPosPerSide && !trendUp;
|
||||||
|
|
||||||
//--- LOG
|
//--- LOG
|
||||||
if(DebugPrint)
|
if(DebugPrint)
|
||||||
{
|
{
|
||||||
Print("");
|
Print("");
|
||||||
Print("=== BAR: ",TimeToString(curBar)," ===");
|
Print("=== BAR: ",TimeToString(curBar)," ===");
|
||||||
Print("Bid=",DoubleToString(bid,_Digits)," Median=",DoubleToString(median,_Digits));
|
Print("Bid=",DoubleToString(bid,_Digits)," Median=",DoubleToString(median,_Digits));
|
||||||
Print("Dist=",DoubleToString(distPct,3),"% DispMA=",DoubleToString(vol,4),"%");
|
Print("Dist=",DoubleToString(distPct,3),"% DispMA=",DoubleToString(vol,4),"%");
|
||||||
Print("Band: [",DoubleToString(buyBand,_Digits)," <- ",DoubleToString(sellBand,_Digits)," ] Pos: ",nBuy,"B ",nSell,"S");
|
Print("Trend: ",trendUp?"UP":trendDown?"DOWN":"MIX", " Allow: ",allowBuy?"B":"-",allowSell?"S":"-");
|
||||||
|
Print("Band: [",DoubleToString(buyBand,_Digits)," <- ",DoubleToString(sellBand,_Digits)," ] Pos: ",nBuy,"B ",nSell,"S");
|
||||||
for(int m=0;m<8;m++)
|
for(int m=0;m<8;m++)
|
||||||
if(mv[m]>0)
|
if(mv[m]>0)
|
||||||
Print(" MA",m,"=",DoubleToString(mv[m],_Digits),
|
Print(" MA",m,"=",DoubleToString(mv[m],_Digits),
|
||||||
@@ -170,7 +180,7 @@ void OnTick()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--- Entry: fuori dal cluster, TP=mediana, SL simmetrico
|
//--- Entry: fuori dal cluster, TP=mediana, SL simmetrico
|
||||||
if(bid < buyBand && !buyFired && nBuy < MaxPosPerSide)
|
if(bid < buyBand && allowBuy)
|
||||||
{
|
{
|
||||||
double entry = ask;
|
double entry = ask;
|
||||||
double tpDist = MathAbs(median-entry);
|
double tpDist = MathAbs(median-entry);
|
||||||
@@ -194,7 +204,7 @@ void OnTick()
|
|||||||
else if(DebugPrint) Print("BUY SKIP: tpDist too small (",DoubleToString(tpDist/point,0),"pts)");
|
else if(DebugPrint) Print("BUY SKIP: tpDist too small (",DoubleToString(tpDist/point,0),"pts)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bid > sellBand && !sellFired && nSell < MaxPosPerSide)
|
if(bid > sellBand && allowSell)
|
||||||
{
|
{
|
||||||
double entry = bid;
|
double entry = bid;
|
||||||
double tpDist = MathAbs(entry-median);
|
double tpDist = MathAbs(entry-median);
|
||||||
@@ -218,17 +228,8 @@ void OnTick()
|
|||||||
else if(DebugPrint) Print("SELL SKIP: tpDist too small (",DoubleToString(tpDist/point,0),"pts)");
|
else if(DebugPrint) Print("SELL SKIP: tpDist too small (",DoubleToString(tpDist/point,0),"pts)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DebugPrint)
|
if(DebugPrint && bid>=buyBand && bid<=sellBand)
|
||||||
{
|
Print("NO ENTRY: inside cluster [",DoubleToString(buyBand,_Digits),
|
||||||
if(bid>=buyBand && bid<=sellBand)
|
" - ",DoubleToString(sellBand,_Digits),"]");
|
||||||
Print("NO ENTRY: inside cluster [",DoubleToString(buyBand,_Digits),
|
|
||||||
" - ",DoubleToString(sellBand,_Digits),"]");
|
|
||||||
else if(bid<buyBand && nBuy>=MaxPosPerSide)
|
|
||||||
Print("BUY BLOCKED: max pos (",nBuy,"/",MaxPosPerSide,") bid=",DoubleToString(bid,_Digits),
|
|
||||||
" < buyBand=",DoubleToString(buyBand,_Digits));
|
|
||||||
else if(bid>sellBand && nSell>=MaxPosPerSide)
|
|
||||||
Print("SELL BLOCKED: max pos (",nSell,"/",MaxPosPerSide,") bid=",DoubleToString(bid,_Digits),
|
|
||||||
" > sellBand=",DoubleToString(sellBand,_Digits));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
|
|||||||
Reference in New Issue
Block a user