增加交易策略、交易指标、量化库代码等文件夹

This commit is contained in:
Win_home
2025-04-27 15:54:09 +08:00
parent ca3b209096
commit f57150dae8
589 changed files with 854346 additions and 1757 deletions

View File

@@ -0,0 +1,273 @@
//------------------------------------------------------------------------
// <20><><EFBFBD><EFBFBD>: VIP17_duo
// <20><><EFBFBD><EFBFBD>: VIP17_duo
// <20><><EFBFBD><EFBFBD>: <20><>ʽӦ<CABD><D3A6>
// <20><><EFBFBD><EFBFBD>: <20>û<EFBFBD>Ӧ<EFBFBD><D3A6>
// <20><><EFBFBD><EFBFBD>: Void
//------------------------------------------------------------------------
Params
Numeric Fund(20000); // Ͷ<>뱣֤<EBB1A3><D6A4>
Vars
Numeric Lots(0); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Numeric totalScore(5); // <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ŀǰ<C4BF><C7B0><EFBFBD>ǵ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>ܹ<EFBFBD>6<EFBFBD><36>ָ<EFBFBD>꼰6<EABCB0>֡<EFBFBD>
Numeric rpmPeriod(14); // RPM Period
Numeric bboPeriod(16); // BBO Period
Numeric macdFastPeriod(12); // MACD Fast Period
Numeric macdSlowPeriod(24); // MACD Slow Period
Numeric macdSignalPeriod(9); // MACD Signal Period
Numeric rsiPeriod(14); // RSI Period
Numeric cciPeriod(14); // CCI Period
Numeric stochasticKLength(14); // Stochastic %K Length
Numeric stochasticKSmoothing(1); // Stochastic %K Smoothing
Numeric stochasticDSmoothing(3); // Stochastic %D Smoothing
Numeric supertrendPeriod(10); // SUPERTREND Period
Numeric supertrendFactor(2); // SUPERTREND Factor
Series<Numeric> rpmValue; // RPM Value
Series<Numeric> bboValue; // BBO Value
Series<Numeric> macdValue; // MACD Value
Series<Numeric> macdSignal; // MACD Signal Line
Series<Numeric> macdHist; // MACD Histogram
Series<Numeric> rsiValue; // RSI Value
Series<Numeric> stochasticValue; // Stochastic Value
Series<Numeric> cciValue; // CCI Value
Series<Numeric> supertrendValue; // SUPERTREND Value
Series<Numeric> netChgAvg ;
Series<Numeric> totChgAvg ;
Series<Numeric> score;
Numeric EntryStrength(90); // <20><><EFBFBD><EFBFBD>ǿ<EFBFBD>ȵĽ<C8B5><C4BD><EFBFBD>ֵ
Numeric Length(5); // ǿ<><C7BF>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
Series<Numeric> CloseChange; // <20><><EFBFBD>̼۱䶯ֵ
Numeric i; // ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
Numeric UpCloses; // <20><><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>ֵ
Numeric DnCloses; // <20><><EFBFBD>̼<EFBFBD><CCBC>µ<EFBFBD><C2B5>ۼ<EFBFBD>ֵ
Numeric SumChange; // <20><><EFBFBD>̼۱<DBB1>ۼ<EFBFBD>ֵ
Series<Numeric> MarketStrength; // <20>г<EFBFBD>ǿ<EFBFBD><C7BF>ָ<EFBFBD><D6B8>
Plot plt1; // <20><><EFBFBD>ڻ<EFBFBD>ͼ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
Events
OnInit()
{
Range[0:DataCount-1]
{
//=========<3D><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>==============
AddDataFlag(Enum_Data_RolloverBackWard()); //<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>Ȩ
AddDataFlag(Enum_Data_RolloverRealPrice()); //<2F><><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD>ʵ<EFBFBD>۸<EFBFBD>
AddDataFlag(Enum_Data_AutoSwapPosition()); //<2F><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
//AddDataFlag(Enum_Data_IgnoreSwapSignalCalc()); //<2F><><EFBFBD>ú<EFBFBD><C3BA>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD>źż<C5BA><C5BC><EFBFBD>
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ͼ
plt1.figure(0); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
plt1.setOption("Score", "width", Enum_7Pix); // <20><>ָ<EFBFBD>ꡰMA1<41><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD>Ϊ3<CEAA><33><EFBFBD><EFBFBD>
plt1.setOption("Score","color",Blue);
}
OnBar(ArrayRef<Integer> indexs)
{
// <20><><EFBFBD><EFBFBD><E3BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Lots = Max(1, Round(Fund/(O*ContractUnit*BigPointValue* MarginRatio/rollover), 0));
// <20><><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD>ǿ<EFBFBD><C7BF>ָ<EFBFBD><D6B8>
CloseChange = Close - Close[1];
UpCloses = 0;
DnCloses = 0;
For i = 0 To Length-1
{
// <20><><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ۼ<EFBFBD>
If(CloseChange[i] > 0)
UpCloses = UpCloses + CloseChange[i];
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>
Else
DnCloses = DnCloses + CloseChange[i];
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>
SumChange = Summation(CloseChange, Length);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ȣ<EFBFBD>0-100֮<30><D6AE>
If(SumChange >= 0)
{
MarketStrength = SumChange / UpCloses * 100;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ǿ<EFBFBD>ȣ<EFBFBD>0-100֮<30><D6AE>
Else
{
MarketStrength = SumChange / Abs(DnCloses) * 100;
}
// <20><><EFBFBD><EFBFBD> MACD ֵ
Numeric emaFast = XAverage(Close, macdFastPeriod);
Numeric emaSlow = XAverage(Close, macdSlowPeriod);
macdValue = emaFast - emaSlow;
macdSignal = XAverage(macdValue, macdSignalPeriod);
macdHist = macdValue - macdSignal;
// <20><><EFBFBD><EFBFBD> RSI ֵ
Numeric SF = 1 / rsiPeriod;
Numeric change = Close - Close[1];
If(CurrentBar <= rsiPeriod - 1)
{
netChgAvg = (Close - Close[rsiPeriod]) / rsiPeriod;
totChgAvg = Average(Abs(Close - Close[1]), rsiPeriod);
}
Else
{
netChgAvg = netChgAvg[1] + SF * (change - netChgAvg[1]);
totChgAvg = totChgAvg[1] + SF * (Abs(change) - totChgAvg[1]);
}
If(totChgAvg <> 0)
{
rsiValue = 50 * (netChgAvg / totChgAvg + 1);
}
Else
{
rsiValue = 50;
}
// <20><><EFBFBD><EFBFBD> Stochastic ֵ
Numeric highestHigh = Highest(High, stochasticKLength);
Numeric lowestLow = Lowest(Low, stochasticKLength);
Numeric stochasticRaw = (Close - lowestLow) / (highestHigh - lowestLow) * 100;
stochasticValue = Average(stochasticRaw, stochasticKSmoothing);
// <20><><EFBFBD><EFBFBD> CCI ֵ
Numeric typicalPrice = (High + Low + Close) / 3;
Numeric smaTypicalPrice = Average(typicalPrice, cciPeriod);
Numeric meanDeviation = Summation(Abs(typicalPrice - smaTypicalPrice), cciPeriod) / cciPeriod;
If(meanDeviation <> 0)
{
cciValue = (typicalPrice - smaTypicalPrice) / (0.015 * meanDeviation);
}
Else
{
cciValue = 0;
}
// <20><><EFBFBD><EFBFBD> SUPERTREND ֵ
Numeric atr = AvgTrueRange(supertrendPeriod);
Numeric basicUpperBand = (High + Low) / 2 + supertrendFactor * atr;
Numeric basicLowerBand = (High + Low) / 2 - supertrendFactor * atr;
Numeric finalUpperBand = IIF(basicUpperBand < supertrendValue[1] || Close[1] > supertrendValue[1], basicUpperBand, supertrendValue[1]);
Numeric finalLowerBand = IIF(basicLowerBand > supertrendValue[1] || Close[1] < supertrendValue[1], basicLowerBand, supertrendValue[1]);
supertrendValue = IIF(Close > supertrendValue[1], finalLowerBand, finalUpperBand);
// <20><><EFBFBD>ö<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>
Bool macdCondition = macdValue > macdSignal;
Bool rsiCondition = rsiValue >50;
Bool stochasticCondition = stochasticValue > 50;
Bool cciCondition = cciValue >0;
Bool supertrendCondition = Close > supertrendValue;
Bool Marketbool = MarketStrength >= EntryStrength;
// <20><><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD>
score = 0;
If(macdCondition)
{
score = score + 1;
}
If(rsiCondition)
{
score = score + 1;
}
If(stochasticCondition)
{
score = score + 1;
}
If(cciCondition)
{
score = score + 1;
}
If(supertrendCondition)
{
score = score + 1;
}
if(Marketbool)
{
score = score + 1;
}
// <20>ڸ<EFBFBD>ͼ<EFBFBD><CDBC>ʾ<EFBFBD>÷<EFBFBD>
Commentary("Score: " + Text(score));
plt1.barv("Score",score);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
If(score == totalScore)
{
Commentary("All conditions met!");
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
If(score[1] >= totalScore And MarketPosition == 0 ) //
{
Buy(Lots, Open);
}
// ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
If(score[1] == 0 And MarketPosition == 1)
{
Sell(0, Open);
}
// <20>ڸ<EFBFBD>ͼ<EFBFBD><CDBC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD>
If(macdCondition)
{
PlotAuto("MACD_Condition",1,1,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("MACD_Condition",1,1,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(rsiCondition)
{
PlotAuto("RSI_Condition",2,2,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("RSI_Condition",2,2,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(stochasticCondition)
{
PlotAuto("Stochastic_Condition", 3,3,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("Stochastic_Condition", 3,3,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(cciCondition)
{
PlotAuto("CCI_Condition", 4,4,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("CCI_Condition", 4,4,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(supertrendCondition)
{
PlotAuto("Supertrend_Condition", 5,5,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("Supertrend_Condition", 5,5,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(Marketbool)
{
PlotAuto("Marketbool", 6,6,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("Marketbool", 6,6,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
}
//------------------------------------------------------------------------
// <20><><EFBFBD><EFBFBD><EFBFBD>汾 2024/11/27 145803
// <20><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD> songshu123
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TradeBlazer Software<72><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TradeBlazerƽ̨
// ÿһ<C3BF><EFBFBD><E6B1BE>TradeBlazer<65><72>ʽ<EFBFBD>޸ĺ<DEB8><C4BA><EFBFBD>д<EFBFBD><D0B4>Ȩ<EFBFBD><C8A8>
//------------------------------------------------------------------------

View File

@@ -0,0 +1,274 @@
//------------------------------------------------------------------------
// <20><><EFBFBD><EFBFBD>: vip17_kong
// <20><><EFBFBD><EFBFBD>: vip17_kong
// <20><><EFBFBD><EFBFBD>: <20><>ʽӦ<CABD><D3A6>
// <20><><EFBFBD><EFBFBD>: <20>û<EFBFBD>Ӧ<EFBFBD><D3A6>
// <20><><EFBFBD><EFBFBD>: Void
//------------------------------------------------------------------------
Params
Numeric Fund(20000); // Ͷ<>뱣֤<EBB1A3><D6A4>
Vars
Numeric Lots(0); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Numeric totalScore(5); // <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ŀǰ<C4BF><C7B0><EFBFBD>ǵ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>ܹ<EFBFBD>6<EFBFBD><36>ָ<EFBFBD>꼰6<EABCB0>֡<EFBFBD>
Numeric rpmPeriod(14); // RPM Period
Numeric bboPeriod(16); // BBO Period
Numeric macdFastPeriod(12); // MACD Fast Period
Numeric macdSlowPeriod(24); // MACD Slow Period
Numeric macdSignalPeriod(9); // MACD Signal Period
Numeric rsiPeriod(14); // RSI Period
Numeric cciPeriod(14); // CCI Period
Numeric stochasticKLength(14); // Stochastic %K Length
Numeric stochasticKSmoothing(1); // Stochastic %K Smoothing
Numeric stochasticDSmoothing(3); // Stochastic %D Smoothing
Numeric supertrendPeriod(10); // SUPERTREND Period
Numeric supertrendFactor(2); // SUPERTREND Factor
Series<Numeric> rpmValue; // RPM Value
Series<Numeric> bboValue; // BBO Value
Series<Numeric> macdValue; // MACD Value
Series<Numeric> macdSignal; // MACD Signal Line
Series<Numeric> macdHist; // MACD Histogram
Series<Numeric> rsiValue; // RSI Value
Series<Numeric> stochasticValue; // Stochastic Value
Series<Numeric> cciValue; // CCI Value
Series<Numeric> supertrendValue; // SUPERTREND Value
Series<Numeric> netChgAvg ;
Series<Numeric> totChgAvg ;
Series<Numeric> score;
Numeric EntryStrength(90); // <20><><EFBFBD><EFBFBD>ǿ<EFBFBD>ȵĽ<C8B5><C4BD><EFBFBD>ֵ
Numeric Length(5); // ǿ<><C7BF>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
Series<Numeric> CloseChange; // <20><><EFBFBD>̼۱䶯ֵ
Numeric i; // ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
Numeric UpCloses; // <20><><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>ֵ
Numeric DnCloses; // <20><><EFBFBD>̼<EFBFBD><CCBC>µ<EFBFBD><C2B5>ۼ<EFBFBD>ֵ
Numeric SumChange; // <20><><EFBFBD>̼۱<DBB1>ۼ<EFBFBD>ֵ
Series<Numeric> MarketStrength; // <20>г<EFBFBD>ǿ<EFBFBD><C7BF>ָ<EFBFBD><D6B8>
Plot plt1; // <20><><EFBFBD>ڻ<EFBFBD>ͼ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
Events
OnInit()
{
Range[0:DataCount-1]
{
//=========<3D><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>==============
AddDataFlag(Enum_Data_RolloverBackWard()); //<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>Ȩ
AddDataFlag(Enum_Data_RolloverRealPrice()); //<2F><><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD>ʵ<EFBFBD>۸<EFBFBD>
AddDataFlag(Enum_Data_AutoSwapPosition()); //<2F><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
//AddDataFlag(Enum_Data_IgnoreSwapSignalCalc()); //<2F><><EFBFBD>ú<EFBFBD><C3BA>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD>źż<C5BA><C5BC><EFBFBD>
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ͼ
plt1.figure(0); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
plt1.setOption("Score", "width", Enum_7Pix); // <20><>ָ<EFBFBD>ꡰMA1<41><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD>Ϊ3<CEAA><33><EFBFBD><EFBFBD>
plt1.setOption("Score","color",Blue);
}
OnBar(ArrayRef<Integer> indexs)
{
// <20><><EFBFBD><EFBFBD><E3BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Lots = Max(1, Round(Fund/(O*ContractUnit*BigPointValue* MarginRatio/rollover), 0));
// <20><><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD>ǿ<EFBFBD><C7BF>ָ<EFBFBD><D6B8>
CloseChange = Close - Close[1];
UpCloses = 0;
DnCloses = 0;
For i = 0 To Length-1
{
// <20><><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ۼ<EFBFBD>
If(CloseChange[i] > 0)
UpCloses = UpCloses + CloseChange[i];
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>
Else
DnCloses = DnCloses + CloseChange[i];
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>
SumChange = Summation(CloseChange, Length);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ȣ<EFBFBD>0-100֮<30><D6AE>
If(SumChange >= 0)
{
MarketStrength = SumChange / UpCloses * 100;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ǿ<EFBFBD>ȣ<EFBFBD>0-100֮<30><D6AE>
Else
{
MarketStrength = SumChange / Abs(DnCloses) * 100;
}
// <20><><EFBFBD><EFBFBD> MACD ֵ
Numeric emaFast = XAverage(Close, macdFastPeriod);
Numeric emaSlow = XAverage(Close, macdSlowPeriod);
macdValue = emaFast - emaSlow;
macdSignal = XAverage(macdValue, macdSignalPeriod);
macdHist = macdValue - macdSignal;
// <20><><EFBFBD><EFBFBD> RSI ֵ
Numeric SF = 1 / rsiPeriod;
Numeric change = Close - Close[1];
If(CurrentBar <= rsiPeriod - 1)
{
netChgAvg = (Close - Close[rsiPeriod]) / rsiPeriod;
totChgAvg = Average(Abs(Close - Close[1]), rsiPeriod);
}
Else
{
netChgAvg = netChgAvg[1] + SF * (change - netChgAvg[1]);
totChgAvg = totChgAvg[1] + SF * (Abs(change) - totChgAvg[1]);
}
If(totChgAvg <> 0)
{
rsiValue = 50 * (netChgAvg / totChgAvg + 1);
}
Else
{
rsiValue = 50;
}
// <20><><EFBFBD><EFBFBD> Stochastic ֵ
Numeric highestHigh = Highest(High, stochasticKLength);
Numeric lowestLow = Lowest(Low, stochasticKLength);
Numeric stochasticRaw = (Close - lowestLow) / (highestHigh - lowestLow) * 100;
stochasticValue = Average(stochasticRaw, stochasticKSmoothing);
// <20><><EFBFBD><EFBFBD> CCI ֵ
Numeric typicalPrice = (High + Low + Close) / 3;
Numeric smaTypicalPrice = Average(typicalPrice, cciPeriod);
Numeric meanDeviation = Summation(Abs(typicalPrice - smaTypicalPrice), cciPeriod) / cciPeriod;
If(meanDeviation <> 0)
{
cciValue = (typicalPrice - smaTypicalPrice) / (0.015 * meanDeviation);
}
Else
{
cciValue = 0;
}
// <20><><EFBFBD><EFBFBD> SUPERTREND ֵ
Numeric atr = AvgTrueRange(supertrendPeriod);
Numeric basicUpperBand = (High + Low) / 2 + supertrendFactor * atr;
Numeric basicLowerBand = (High + Low) / 2 - supertrendFactor * atr;
Numeric finalUpperBand = IIF(basicUpperBand < supertrendValue[1] || Close[1] > supertrendValue[1], basicUpperBand, supertrendValue[1]);
Numeric finalLowerBand = IIF(basicLowerBand > supertrendValue[1] || Close[1] < supertrendValue[1], basicLowerBand, supertrendValue[1]);
supertrendValue = IIF(Close > supertrendValue[1], finalLowerBand, finalUpperBand);
// <20><><EFBFBD>ÿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>
Bool macdCondition = macdValue < macdSignal;
Bool rsiCondition = rsiValue <50;
Bool stochasticCondition = stochasticValue < 50;
Bool cciCondition = cciValue <0;
Bool supertrendCondition = Close < supertrendValue;
Bool Marketbool = MarketStrength >= EntryStrength;
// <20><><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD>
score = 0;
If(macdCondition)
{
score = score + 1;
}
If(rsiCondition)
{
score = score + 1;
}
If(stochasticCondition)
{
score = score + 1;
}
If(cciCondition)
{
score = score + 1;
}
If(supertrendCondition)
{
score = score + 1;
}
if(Marketbool)
{
score = score + 1;
}
// <20>ڸ<EFBFBD>ͼ<EFBFBD><CDBC>ʾ<EFBFBD>÷<EFBFBD>
Commentary("Score: " + Text(score));
plt1.barv("Score",score);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
If(score == totalScore)
{
Commentary("All conditions met!");
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
If(score[1] >= totalScore And MarketPosition == 0 ) //
{
SellShort(Lots, Open);
}
// ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
If(score[1] == 0 And MarketPosition == -1)
{
BuyToCover(0, Open);
}
// <20>ڸ<EFBFBD>ͼ<EFBFBD><CDBC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD>
If(macdCondition)
{
PlotAuto("MACD_Condition",1,1,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("MACD_Condition",1,1,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(rsiCondition)
{
PlotAuto("RSI_Condition",2,2,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("RSI_Condition",2,2,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(stochasticCondition)
{
PlotAuto("Stochastic_Condition", 3,3,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("Stochastic_Condition", 3,3,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(cciCondition)
{
PlotAuto("CCI_Condition", 4,4,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("CCI_Condition", 4,4,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(supertrendCondition)
{
PlotAuto("Supertrend_Condition", 5,5,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("Supertrend_Condition", 5,5,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
If(Marketbool)
{
PlotAuto("Marketbool", 6,6,Green,Enum_Line,Enum_Solid,Enum_7Pix);
}
Else
{
PlotAuto("Marketbool", 6,6,Red,Enum_Line,Enum_Solid,Enum_7Pix);
}
}
//------------------------------------------------------------------------
// <20><><EFBFBD><EFBFBD><EFBFBD>汾 2024/11/27 150615
// <20><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD> songshu123
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TradeBlazer Software<72><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TradeBlazerƽ̨
// ÿһ<C3BF><EFBFBD><E6B1BE>TradeBlazer<65><72>ʽ<EFBFBD>޸ĺ<DEB8><C4BA><EFBFBD>д<EFBFBD><D0B4>Ȩ<EFBFBD><C8A8>
//------------------------------------------------------------------------