[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Coding for QQE expert



PureBytes Links

Trading Reference Links

I found following code for QQE on net for vttrader.I need MS code

Barnum:= BarCount();
Err:= (tp1=0) or (tp2=0) or (rsitpr=0) or (Sh=0) or (Lg=0) or (K=0) 
or (D=0) or (stochsl=0);

{Moving Averages}

ShortMA:= mov(pr1,tp1,mTp1);
LongMA:= mov(pr2,tp2,mTp2);

{Relative Strength Index}

rsi_r:= (rsipr - ref(rsipr,-1));
rsi_rs:= Wilders(if(rsi_r>0,rsi_r,0),rsitpr) / Wilders(if(rsi_r<0,Abs
(rsi_r),0),rsitpr);
RSIndex:= 100-(100/(1+rsi_rs));
RSIML:= 50;

{MACD}

FL:= Mov(spr,Sh,smat) - Mov(lpr,Lg,lmat);
SL:= Mov(FL,sig,sigmat);
OsMA:= FL-SL;

{Slow Stochastic Oscillator}

StK:= ((C-LLV(L,K))/(HHV(H,K)-LLV(L,K)))*100;
StDK:= Mov(StK,stochSl,MtK);
StDD:= Mov(StDK,D,DMt);
StochUp:= 80;
StochDown:= 20;

{Do NOT change the NAMES of the Variables below.
If you Changed The NAMES of Indicator1 or Indicator2,
you will have to change them below.}

{Define Final Trade Entry/Exit Criteria}

LongEntryCond1:= ShortMA>LongMA;
LongEntryCond2:= FL>SL;
LongEntryCond3:= RSIndex>RSIML;
LongEntryCond4:= StDK>StDD;

ShortEntryCond1:= ShortMA<LongMA;
ShortEntryCond2:= FL<SL;
ShortEntryCond3:= RSIndex<RSIML;
ShortEntryCond4:= StDK<StDD;

LongEntrySetup:= Cross
((LongEntryCond1+LongEntryCond2+LongEntryCond3+LongEntryCond4),3.5);
LongExitSetup:= Cross
((ShortEntryCond1+ShortEntryCond2+ShortEntryCond3+ShortEntryCond4),3.
5);

ShortEntrySetup:= Cross
((ShortEntryCond1+ShortEntryCond2+ShortEntryCond3+ShortEntryCond4),3.
5);
ShortExitSetup:= Cross
((LongEntryCond1+LongEntryCond2+LongEntryCond3+LongEntryCond4),3.5);

{***********************************************}

{That's it! You're done! There is no need to
edit below this point.}

{***********************************************}

{Determine the Pip Value for the currency chart being used}

_SymbolPoint:= SymbolPoint();

_InitialStoploss:= InitialStoploss * _SymbolPoint;
_BEP:= BEP * _SymbolPoint;
_TrailingStoploss:= TrailingStoploss * _SymbolPoint;
_ProfitTarget:= ProfitTarget * _SymbolPoint;
_Spread:= Spread * _SymbolPoint;

{Define Active Market Hours for Taking Trade Entries}
{For Example: StartHour=2 and StartMinute=0 will allow trade entries 
beginning at 2:00 AM EST}
{For Example: EndHour=14 and EndMinute=30 will allow trade entries 
until 2:30 PM EST}

_hour:= hour();
_minute:= minute();

TradingSessionOnStart:= _hour=StartHour and _minute>=StartMinute;
TradingSessionOnEnd:= _hour=EndHour and _minute>=EndMinute;
TradingSessionOn:= SignalFlag
(TradingSessionOnStart,TradingSessionOnEnd);
TradingSessionOff:= 1;
TradeEntryTimeFilter:= if(TradeEntryTimeFilterMode=0, 
TradingSessionOn, TradingSessionOff);

TradeEntryTimeFilterNotEnabled:= TradeEntryTimeFilter=0;
TradeEntryTimeFilterEnabled:= TradeEntryTimeFilter=1;

{***********************************************}

LongEntrySignal:= (NOT Err AND LongTradeAlert=0 AND 
ShortTradeAlert=0 AND TradeEntryTimeFilter=1 AND LongEntrySetup) OR
                  (NOT Err AND LongTradeAlert=0 AND Cross
(0.5,ShortTradeAlert) AND TradeEntryTimeFilter=1 AND LongEntrySetup) 
OR
                  (NOT Err AND LongTradeAlert=0 AND 
TradeEntryTimeFilter=1 AND ShortExitSetup);

LongEntryPrice:= valuewhen(1,LongEntrySignal,C) + _Spread;
BarsSinceLongEntry:= BarsSince(LongEntrySignal);

LongEntryInitialStop:= if(LongTradeAlert=1 OR LongEntrySignal OR 
LongExitSignal, LongEntryPrice - _InitialStoploss, null);
DisplayLongEntryInitialStop:= if(InitialStoplossMode=0, 
LongEntryInitialStop, null);

LongEntryBEStoplossFlag:= SignalFlag(LongTradeAlert=1 AND C >= 
(LongEntryPrice + _BEP), LongExitSignal);
LongEntryBEStoploss:= if(LongEntryBEStoplossFlag=1 OR 
LongEntrySignal OR LongExitSignal, LongEntryPrice, null);
DisplayLongEntryBEStoploss:= if(BEStoplossMode=0, 
LongEntryBEStoploss, null);

LongEntryPipTrailingStop:= if(LongTradeAlert=1 OR LongEntrySignal OR 
LongExitSignal, max((C - _TrailingStoploss), PREV(LongEntryPrice - 
_TrailingStoploss)), null);
LongEntryATRTrailingStop:= if(LongTradeAlert=1 OR LongEntrySignal OR 
LongExitSignal, max(HHV(H,BarsSinceLongEntry) - (ATR(ATRper) * 
atrmultiplier), PREV(valuewhen(1,LongEntrySignal,H) - (ATR(ATRper) * 
atrmultiplier))), null);
DisplayLongEntryTrailingStop:= if(TrailingStoplossMode=0 AND 
TrailingStoplossType=1, LongEntryPipTrailingStop,
                               if(TrailingStoplossMode=0 AND 
TrailingStoplossType=0, LongEntryATRTrailingStop,
                               null));

LongEntryProfitTarget:= if(LongTradeAlert=1 OR LongEntrySignal OR 
LongExitSignal, LongEntryPrice + _ProfitTarget, null);
DisplayLongEntryProfitTarget:= if(ProfitTargetMode=0, 
LongEntryProfitTarget, null);

LongExitSignal:= (LongTradeAlert=1 AND InitialStoplossMode=0 AND 
Cross(LongEntryInitialStop,C))
              OR (LongTradeAlert=1 AND BEStoplossMode=0 AND Cross
(LongEntryBEStoploss,C))
              OR (LongTradeAlert=1 AND TrailingStoplossMode=0 AND 
TrailingStoplossType=1 AND Cross(LongEntryPipTrailingStop,C))
              OR (LongTradeAlert=1 AND TrailingStoplossMode=0 AND 
TrailingStoplossType=0 AND Cross(LongEntryATRTrailingStop,C))
              OR (LongTradeAlert=1 AND ProfitTargetMode=0 AND Cross
(C,LongEntryProfitTarget))
              OR (LongTradeAlert=1 AND LongExitSetup);

LongExitPrice:= valuewhen(1,LongExitSignal,C);

ShortEntrySignal:= (NOT Err AND ShortTradeAlert=0 AND 
LongTradeAlert=0 AND TradeEntryTimeFilter=1 AND ShortEntrySetup) OR
                   (NOT Err AND ShortTradeAlert=0 AND Cross
(0.5,LongTradeAlert) AND TradeEntryTimeFilter=1 AND ShortEntrySetup) 
OR
                   (NOT Err AND ShortTradeAlert=0 AND 
TradeEntryTimeFilter=1 AND LongExitSetup);

ShortEntryPrice:= valuewhen(1,ShortEntrySignal,C);
BarsSinceShortEntry:= BarsSince(ShortEntrySignal);

ShortEntryInitialStop:= if(ShortTradeAlert=1 OR ShortEntrySignal OR 
ShortExitSignal, ShortEntryPrice + _InitialStoploss - _Spread, null);
DisplayShortEntryInitialStop:= if(InitialStoplossMode=0, 
ShortEntryInitialStop, null);

ShortEntryBEStoplossFlag:= SignalFlag(ShortTradeAlert=1 AND C <= 
(ShortEntryPrice - _BEP), ShortExitSignal);
ShortEntryBEStoploss:= if(ShortEntryBEStoplossFlag=1 OR 
ShortEntrySignal OR ShortExitSignal, ShortEntryPrice - _Spread, 
null);
DisplayShortEntryBEStoploss:= if(BEStoplossMode=0, 
ShortEntryBEStoploss, null);

ShortEntryPipTrailingStop:= if(ShortTradeAlert=1 OR ShortEntrySignal 
OR ShortExitSignal, min((C + _TrailingStoploss - _Spread), PREV
(ShortEntryPrice + _TrailingStoploss - _Spread)), null);
ShortEntryATRTrailingStop:= if(ShortTradeAlert=1 OR ShortEntrySignal 
OR ShortExitSignal, min(LLV(L,BarsSinceShortEntry) + (ATR(ATRper) * 
atrmultiplier), PREV(valuewhen(1,ShortEntrySignal,L) + (ATR(ATRper) 
* atrmultiplier))), null);
DisplayShortEntryTrailingStop:= if(TrailingStoplossMode=0 AND 
TrailingStoplossType=1, ShortEntryPipTrailingStop,
                                if(TrailingStoplossMode=0 AND 
TrailingStoplossType=0, ShortEntryATRTrailingStop,
                                null));

ShortEntryProfitTarget:= if(ShortTradeAlert=1 OR ShortEntrySignal OR 
ShortExitSignal, ShortEntryPrice - _ProfitTarget - _Spread, null);
DisplayShortEntryProfitTarget:= if(ProfitTargetMode=0, 
ShortEntryProfitTarget, null);

ShortExitSignal:= (ShortTradeAlert=1 AND InitialStoplossMode=0 AND 
Cross(C,ShortEntryInitialStop))
               OR (ShortTradeAlert=1 AND BEStoplossMode=0 AND Cross
(C,ShortEntryBEStoploss))
               OR (ShortTradeAlert=1 AND TrailingStoplossMode=0 AND 
TrailingStoplossType=1 AND Cross(C,ShortEntryPipTrailingStop))
               OR (ShortTradeAlert=1 AND TrailingStoplossMode=0 AND 
TrailingStoplossType=0 AND Cross(C,ShortEntryATRTrailingStop))
               OR (ShortTradeAlert=1 AND ProfitTargetMode=0 AND Cross
(ShortEntryProfitTarget,C))
               OR (ShortTradeAlert=1 AND ShortExitSetup);

ShortExitPrice:= valuewhen(1,ShortExitSignal,C) + _Spread;

{Simulated Open Trade Determination and Trade Direction}

LongTradeAlert:= SignalFlag(LongEntrySignal,LongExitSignal);
ShortTradeAlert:= SignalFlag(ShortEntrySignal,ShortExitSignal);

{Create Auto-Trading Functionality}

OpenBuy:= LongEntrySignal and (eventCount('OpenBuy')=eventCount
('CloseBuy'));
CloseBuy:= LongExitSignal and (eventCount('OpenBuy')>eventCount
('CloseBuy'));

OpenSell:= ShortEntrySignal and (eventCount('OpenSell')=eventCount
('CloseSell'));
CloseSell:= ShortExitSignal and (eventCount('OpenSell')>eventCount
('CloseSell'));

{***********************************************}

{Calculate Simulated Individual Trade Profit In Pips}

_TradeProfitInPips:= If(LongExitSignal=1,LongExitPrice - 
LongEntryPrice,
                     If(ShortExitSignal=1,ShortEntryPrice - 
ShortExitPrice,
                     0));

TradeProfitInPips:= if(SymbolDigits()=4, _TradeProfitInPips * 10000, 
_TradeProfitInPips * 100);

{Calculate Simulated Total Profit In Pips}

TotalProfitInPips:= cum(TradeProfitInPips);

{Calculate Number of Trades}

LongTrades:= cum(LongExitSignal);
ShortTrades:= cum(ShortExitSignal);

LosingTrades:= cum(If(TradeProfitInPips < 0,1,0));
WinningTrades:= cum(If(TradeProfitInPips > 0,1,0));
BreakEvenTrades:= if((LongExitSignal=1 or ShortExitSignal=1) and 
TradeProfitInPips=0, PREV+1, PREV);
TotalTrades:= cum(LongExitSignal) + cum(ShortExitSignal);

{Calculate Additional Stats}

WinningTradesPips:= if(TradeProfitInPips > 0,TradeProfitInPips + 
PREV, PREV);
LosingTradesPips:= if(TradeProfitInPips < 0,TradeProfitInPips + 
PREV, PREV);

LargestWinningTradeInPips:= max(TradeProfitInPips,PREV);
LargestLosingTradeInPips:= min(TradeProfitInPips,PREV);

AverageWinningTradeInPips:= WinningTradesPips / WinningTrades;
AverageLosingTradeInPips:= LosingTradesPips / LosingTrades;

PercentProfitable:= (WinningTrades/TotalTrades) * 100;
AverageWinLossRatio:= AverageWinningTradeInPips / 
AverageLosingTradeInPips;

{***********************************************}



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/