├── README.md ├── 腾讯QQ.lnk ├── .gitattributes ├── Strategy_Renko_Para_Break.txt ├── Multicharts Print Renko Trade.txt ├── Multicharts Print WeChart Notify Code.txt ├── 伦敦金-沪金套利换算.txt ├── Multihcarts Print QualitySeries Code.txt ├── Multichats-DranBackRenko.txt ├── Multicharts-Print-SymbolInfos.txt ├── HANYU-Trend-New.txt ├── HANYU-Trend-Data2.txt ├── Multicharts 网格交易模板.txt ├── Multicharts HegeAlalsy MaginCal.txt ├── HANYU-Hedge.txt ├── HANYU-Hedge-New.txt ├── HANYU-Trend.txt ├── MACD-Hedge (2).txt ├── Multicharts-Trend-New2.txt └── Multicharts Tl_New Demo.txt /README.md: -------------------------------------------------------------------------------- 1 | # MC-Fundament-Code 2 | -------------------------------------------------------------------------------- /腾讯QQ.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/handayu/MC-Fundament-Code/HEAD/腾讯QQ.lnk -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Strategy_Renko_Para_Break.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/handayu/MC-Fundament-Code/HEAD/Strategy_Renko_Para_Break.txt -------------------------------------------------------------------------------- /Multicharts Print Renko Trade.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/handayu/MC-Fundament-Code/HEAD/Multicharts Print Renko Trade.txt -------------------------------------------------------------------------------- /Multicharts Print WeChart Notify Code.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/handayu/MC-Fundament-Code/HEAD/Multicharts Print WeChart Notify Code.txt -------------------------------------------------------------------------------- /伦敦金-沪金套利换算.txt: -------------------------------------------------------------------------------- 1 | [IntrabarOrderGeneration = true] 2 | 3 | inputs: 4 | BuySell(1), 5 | EntryPriceIn(0); 6 | 7 | var: 8 | 9 | intrabarpersist TrandferClose(0), 10 | intrabarpersist profit(0); 11 | 12 | if BuySell = 1 then profit = (Close - EntryPriceIn)*33*(Close of data2); 13 | if BuySell = -1 then profit = (EntryPriceIn - Close)*33*(Close of data2); 14 | 15 | TrandferClose = (Close of data1) * (Close of data2)/31.1035; 16 | 17 | if LastBarOnChart then begin 18 | 19 | if Text_Exist(Value60) then text_delete(Value60); 20 | 21 | Value60 = Text_New(Date,Time,High, numtostr(TrandferClose,5) + "Y/g" + "\n"+ 22 | "1 Shares SHFE-Au is 1000g" + "\n"+ 23 | "= 1000/31.1035 = 32.150 Shares oz.av in MC"+"\n" 24 | +" = 0.32150 Shares in MT4" + "\n"+ 25 | "Profit: " + NumToStr(profit,2) + " 33Oz need 5&Commison"); 26 | 27 | 28 | text_setcolor(Value60,Red); 29 | 30 | text_setsize(Value60,16); 31 | Text_SetAttribute(Value60,1,True); 32 | Text_SetFontName(Value60,"Verdana"); 33 | 34 | 35 | 36 | 37 | end; 38 | -------------------------------------------------------------------------------- /Multihcarts Print QualitySeries Code.txt: -------------------------------------------------------------------------------- 1 | input: 2 | 3 | InitStart(0); 4 | 5 | var: 6 | MP(0), 7 | LastTradeProfitPoint(0), 8 | TradeNum(0), 9 | EntryDateInit(0), 10 | EntryTimeInit(0), 11 | EntryPricInit(0); 12 | 13 | MP = marketposition; 14 | 15 | 16 | if ((MP[1] <> 0 ) and MP = 0) OR (MP[1] =1 and MP = -1) OR (MP[1] =-1 and MP = 1) then begin 17 | 18 | TradeNum = TradeNum + 1; 19 | 20 | if(TradeNum >= 3) then begin 21 | 22 | if(MP[1] = 1) then LastTradeProfitPoint =exitprice(1) - entryprice(1); 23 | if(MP[1] = -1) then LastTradeProfitPoint =entryprice(1) - exitprice(1); 24 | 25 | if(EntryDateInit = 0 and EntryTimeInit = 0 and EntryPricInit = 0) then begin 26 | Value21 = tl_new(entryDate(1) ,entryTime(1) ,InitStart,exitDate(1),exitTime(1),InitStart + LastTradeProfitPoint); 27 | EntryDateInit = exitDate(1); 28 | EntryTimeInit= exitTime(1); 29 | EntryPricInit= InitStart+ LastTradeProfitPoint; 30 | end; 31 | if(EntryDateInit <> 0 and EntryTimeInit <> 0 and EntryPricInit <> 0) then begin 32 | Value22 = tl_new(EntryDateInit,EntryTimeInit,EntryPricInit,exitDate(1),exitTime(1),EntryPricInit + LastTradeProfitPoint); 33 | EntryDateInit = exitDate(1); 34 | EntryTimeInit= exitTime(1); 35 | EntryPricInit= EntryPricInit + LastTradeProfitPoint; 36 | end; 37 | end; 38 | end; 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Multichats-DranBackRenko.txt: -------------------------------------------------------------------------------- 1 | Inputs: 2 | MaxProfitRenko(3), 3 | DrawBackRenko(1); 4 | 5 | 6 | 7 | var: 8 | intrabarpersist WinMax(0), 9 | intrabarpersist MaxProfit(0), 10 | intrabarpersist WinNow(0); 11 | 12 | var: 13 | 14 | varRenko(0); 15 | 16 | varRenko = AbsValue(Open[1] - Close[1]); 17 | 18 | if marketposition<>0 then begin 19 | if marketposition = 1 then begin 20 | WinMax=( close- entryprice(0) )/ varRenko ; 21 | if(WinMax>MaxProfit) then MaxProfit=WinMax; 22 | if(MaxProfit<>0) then WinNow= MaxProfit - WinMax; 23 | end; 24 | 25 | if ( Marketposition = 1 and MaxProfit >= MaxProfitRenko and WinNow >= DrawBackRenko and openpositionprofit > 0 ) then begin 26 | Sell ("SDrawDown_Out") this bar at Close; 27 | WinMax = 0; 28 | MaxProfit = 0; 29 | WinNow = 0; 30 | end; 31 | end; 32 | 33 | if marketposition<>0 then begin 34 | if marketposition = -1 then begin 35 | WinMax=( EntryPrice(0) - Close )/ varRenko ; 36 | if(WinMax > MaxProfit) then MaxProfit = WinMax; 37 | if(MaxProfit<> 0) then WinNow = MaxProfit-WinMax; 38 | end; 39 | 40 | if ( Marketposition = -1 and MaxProfit >= MaxProfitRenko and WinNow >= DrawBackRenko and openpositionprofit > 0 ) then begin 41 | BuytoCover ("BDrawDown_Out")this bar at Close; 42 | WinMax = 0; 43 | MaxProfit = 0; 44 | WinNow = 0; 45 | end; 46 | end; 47 | 48 | -------------------------------------------------------------------------------- /Multicharts-Print-SymbolInfos.txt: -------------------------------------------------------------------------------- 1 | [IntrabarOrderGeneration = false] 2 | inputs: AfStep( 0.02 ), AfLimit( 0.2 ) ; 3 | variables: var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ) ; 4 | 5 | Value1 = ParabolicSAR( AfStep, AfLimit, var0, var1, var2, var3 ) ; 6 | 7 | if var2 = 1 then 8 | Buy ( "ParSE" ) next bar market ; 9 | 10 | if var2 = -1 then 11 | Sell Short ( "ParLE" ) next bar at market ; 12 | 13 | ///////////////////////////////////////////////////////////////////////////////////////////////// 14 | //////////////////////////////////////////////////////////////////////////////////////////////// 15 | inputs: 16 | AccountName("8070-882702"), 17 | Commmison(1), 18 | Slipise(5); 19 | 20 | var: 21 | MP(0), 22 | TradeNum(0); 23 | 24 | MP = marketposition; 25 | 26 | if ((MP[1] <> 0 ) and MP = 0) OR (MP[1] =1 and MP = -1) OR (MP[1] =-1 and MP = 1) then begin 27 | TradeNum = TradeNum + 1; 28 | end; 29 | 30 | 31 | 32 | var: 33 | NoCommisonSlipiseAccountSeries(0), 34 | HasCommisonSlipiseAccountSeries(0); 35 | 36 | if ((MP[1] <> 0 ) and MP = 0) OR (MP[1] =1 and MP = -1) OR (MP[1] =-1 and MP = 1) then begin 37 | 38 | NoCommisonSlipiseAccountSeries = NoCommisonSlipiseAccountSeries+ positionprofit(1); 39 | 40 | HasCommisonSlipiseAccountSeries = HasCommisonSlipiseAccountSeries + positionprofit(1) - (Commmison * MinMove*(1/PriceScale) + Slipise * MinMove*(1/PriceScale))*bigpointvalue; 41 | 42 | value1 = text_new_bn(Barnumber,high,Symbol + newline + 43 | "LastProfit: " + Numtostr(positionprofit(1) ,2) + newline + 44 | "TradeNum: " + Numtostr(TradeNum ,0) + NewLine + 45 | "NoComSlipeProfit: " + Numtostr(NoCommisonSlipiseAccountSeries ,2) + NewLine + 46 | "HasComSlipeProfit: " + Numtostr(HasCommisonSlipiseAccountSeries ,2) + NewLine + 47 | "AllIn-OutComsinAndSlipe(Comison+slipe): " + Numtostr(Commmison+Slipise ,2) + NewLine + 48 | "EntryAndExit-Comsion: " + Numtostr(Commmison,2) + NewLine + 49 | "EntryAndExit-Slipese: " + Numtostr(Slipise ,2) + " EntrySlipe: " + Numtostr(Slipise/2 ,2) + " ExitSlipe: " + Numtostr(Slipise/2 ,2) + NewLine + 50 | "BigPointValue: " + Numtostr(BigpointValue ,2) + " MinMove:" + NumToStr(MinMove*(1/PriceScale),2) + " MinMove-Value(MinM*BigValue): " + NumToStr(MinMove*(1/PriceScale)*bigpointvalue,2) + NewLine + 51 | "--" + "Remove-Money(EntryAndExit-Comsion+EntryAndExit-Slipese**BigPointValue): " + Numtostr((Commmison * MinMove*(1/PriceScale) + Slipise * MinMove*(1/PriceScale))*bigpointvalue ,2) +NewLine + NewLine + 52 | "ChartEntryPrice: " + NumToStr(OpenEntryPrice,2) + NewLine + 53 | "RealAccountEntryPrice: " + NumToStr(GetPositionAveragePrice(Symbol,AccountName),2) + NewLine); 54 | 55 | text_setcolor(value1,White); 56 | text_setsize(value1,8); 57 | text_setfontname(value1,"Verdana"); 58 | end; 59 | 60 | 61 | -------------------------------------------------------------------------------- /HANYU-Trend-New.txt: -------------------------------------------------------------------------------- 1 | [IntrabarOrderGeneration = false] 2 | 3 | inputs: 4 | OpenShares(1), 5 | AccountName("1999_2-0009904"), 6 | Commmison(1), 7 | Slipise(2); 8 | 9 | variables: 10 | 11 | AfStep( 0.02 ), 12 | 13 | AfLimit( 0.2 ) ; 14 | 15 | variables: 16 | 17 | var0( 0 ), 18 | 19 | var1( 0 ), 20 | 21 | var2( 0 ), 22 | 23 | var3( 0 ) ; 24 | 25 | 26 | 27 | Value1 = ParabolicSAR( AfStep, AfLimit, var0, var1, var2, var3 ) ; 28 | 29 | if close cross above var1 then begin 30 | Buy ( "ParB" ) OpenShares shares this bar at Close; 31 | end; 32 | 33 | if close cross under var1 then begin 34 | Sell Short ( "ParS" ) OpenShares shares this bar at Close; 35 | end; 36 | 37 | 38 | 39 | var: 40 | MP(0), 41 | TradeNum(0), 42 | NoCommisonSlipiseAccountSeries(0), 43 | HasCommisonSlipiseAccountSeries(0); 44 | 45 | 46 | MP = marketposition; 47 | 48 | if ((MP[1] <> 0 ) and MP = 0) OR (MP[1] =1 and MP = -1) OR (MP[1] =-1 and MP = 1) then begin 49 | NoCommisonSlipiseAccountSeries = NoCommisonSlipiseAccountSeries+ positionprofit(1); 50 | HasCommisonSlipiseAccountSeries = HasCommisonSlipiseAccountSeries + positionprofit(1) - (Commmison * MinMove*(1/PriceScale) + Slipise * MinMove*(1/PriceScale))*bigpointvalue; 51 | TradeNum = TradeNum + 1; 52 | //print(Date," ",Time," ",symbolname,"_",NoCommisonSlipiseAccountSeries ,"_",HasCommisonSlipiseAccountSeries ,"_", MinMove*(1/PriceScale)," ",bigpointvalue," ",TradeNum); 53 | end; 54 | 55 | var: 56 | 57 | RealOpenPrice(0); 58 | 59 | if LastBarOnChart then begin 60 | 61 | if Text_Exist(Value60) then text_delete(Value60); 62 | 63 | RealOpenPrice = GetPositionAveragePrice(Symbol,AccountName); 64 | 65 | Value60 = Text_New(0, 0, 0,Symbol + newline + "NoCommisionSliplise: " + Numtostr(NoCommisonSlipiseAccountSeries,2) + newline + 66 | "HasCommisonSlipiseAccountSeries: " + Numtostr(HasCommisonSlipiseAccountSeries ,2) + newline + "TradeNum: " + NumToStr(TradeNum ,2) + newline + "TicChengben(Include In-Out): " 67 | + NumToStr(Commmison+Slipise,1) + "Tick =" + NumToStr((Commmison+Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newline + "--Commision: " + NumToStr(Commmison,1) + "Tick =" + NumToStr((Commmison)* MinMove*(1/PriceScale)*bigpointvalue,2) + 68 | NewLine + "--Slipise: " + NumToStr(Slipise,1) + "Tick =" + NumToStr((Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newLine+ "Now-Silipse: " + NumToStr(absvalue(Close - Close[1])/MinMove*(1/PriceScale)*bigpointvalue,2) + " RealNowOpen-Silpse: " + 69 | NumToStr(absvalue(RealOpenPrice - EntryPrice(0))/MinMove*(1/PriceScale)*bigpointvalue,2) 70 | + newline + "ChartNowOpenPrice: " + NumToStr(EntryPrice(0),2) + newline + "RealAccountOpenPrice: " + NumToStr(RealOpenPrice,2)); 71 | 72 | Text_Float(Value60, 5, 75); 73 | text_setcolor(Value60,Red); 74 | text_setsize(Value60,8); 75 | Text_SetAttribute(Value60,1,True); 76 | Text_SetFontName(Value60,"Verdana"); 77 | 78 | end; 79 | 80 | -------------------------------------------------------------------------------- /HANYU-Trend-Data2.txt: -------------------------------------------------------------------------------- 1 | [IntrabarOrderGeneration = false] 2 | 3 | inputs: 4 | 5 | Commmison(1), 6 | Slipise(5); 7 | 8 | variables: 9 | 10 | AfStep( 0.02 ), 11 | 12 | AfLimit( 0.2 ) ; 13 | 14 | variables: 15 | 16 | var0( 0 ), 17 | 18 | var1( 0 ), 19 | 20 | var2( 0 ), 21 | 22 | var3( 0 ) , 23 | 24 | Quality(0), 25 | 26 | varValur(0,data2), 27 | 28 | NoCommisonSlipiseAccountSeries(0), 29 | HasCommisonSlipiseAccountSeries(0), 30 | 31 | PointSeries(0); 32 | 33 | 34 | varValur = ParabolicSAR( AfStep, AfLimit, var0, var1, var2, var3 ) of data2; 35 | 36 | if ( close of data2 )cross above var1 then begin 37 | Buy ( "B" ) this bar at Close; 38 | // 39 | text_new_bn(Barnumber,high,Numtostr(Close,2)); 40 | end; 41 | 42 | if ( close of data2 ) cross under var1 then begin 43 | Sell Short ( "S" ) this bar at Close; 44 | text_new_bn(Barnumber,high,Numtostr(Close,2)); 45 | end; 46 | 47 | var: 48 | MP(0), 49 | TradeNum(0); 50 | 51 | MP = marketposition; 52 | 53 | if ((MP[1] <> 0 ) and MP = 0) OR (MP[1] =1 and MP = -1) OR (MP[1] =-1 and MP = 1) then begin 54 | NoCommisonSlipiseAccountSeries = NoCommisonSlipiseAccountSeries+ positionprofit(1); 55 | HasCommisonSlipiseAccountSeries = HasCommisonSlipiseAccountSeries + positionprofit(1) - (Commmison * MinMove*(1/PriceScale) + Slipise * MinMove*(1/PriceScale))*bigpointvalue; 56 | TradeNum = TradeNum + 1; 57 | //print(Date," ",Time," ",symbolname,"_",NoCommisonSlipiseAccountSeries ,"_",HasCommisonSlipiseAccountSeries ,"_", MinMove*(1/PriceScale)," ",bigpointvalue," ",TradeNum); 58 | end; 59 | 60 | var: 61 | 62 | RealOpenPrice(0); 63 | 64 | if LastBarOnChart then begin 65 | 66 | if Text_Exist(Value60) then text_delete(Value60); 67 | 68 | RealOpenPrice = GetPositionAveragePrice(Symbol,"1999_2-0009904"); 69 | 70 | Value60 = Text_New(0, 0, 0,Symbol + newline + "NoCommisionSliplise: " + Numtostr(NoCommisonSlipiseAccountSeries,2) + newline + 71 | "HasCommisonSlipiseAccountSeries: " + Numtostr(HasCommisonSlipiseAccountSeries ,2) + newline + "TradeNum: " + NumToStr(TradeNum ,2) + newline + "TicChengben(Include In-Out): " 72 | + NumToStr(Commmison+Slipise,1) + "Tick =" + NumToStr((Commmison+Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newline + "--Commision: " + NumToStr(Commmison,1) + "Tick =" + NumToStr((Commmison)* MinMove*(1/PriceScale)*bigpointvalue,2) + 73 | NewLine + "--Slipise: " + NumToStr(Slipise,1) + "Tick =" + NumToStr((Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newLine+ "Now-Silipse: " + NumToStr(absvalue(Close - Close[1])/MinMove*(1/PriceScale)*bigpointvalue,2) + " RealNowOpen-Silpse: " + 74 | NumToStr(absvalue(RealOpenPrice - EntryPrice(0))/MinMove*(1/PriceScale)*bigpointvalue,2) 75 | + newline + "ChartNowOpenPrice: " + NumToStr(EntryPrice(0),2) + newline + "RealAccountOpenPrice: " + NumToStr(RealOpenPrice,2)); 76 | 77 | Text_Float(Value60, 5, 75); 78 | text_setcolor(Value60,Red); 79 | text_setsize(Value60,8); 80 | Text_SetAttribute(Value60,1,True); 81 | Text_SetFontName(Value60,"Verdana"); 82 | 83 | end; 84 | 85 | 86 | -------------------------------------------------------------------------------- /Multicharts 网格交易模板.txt: -------------------------------------------------------------------------------- 1 | input:N1(1000),N2(200),N3(20); 2 | var:ma1(0),bd(0),bdma(0),up1(0),up2(0),up3(0),up4(0),dw1(0),dw2(0),dw3(0),dw4(0); 3 | var:dk0(0),dk1(0),dk2(0),dk3(0),kk0(0),kk1(0),kk2(0),kk3(0); 4 | 5 | ma1=Average(close,n1); 6 | 7 | bd=High-Low; 8 | bdma=Average(bd,n2); 9 | 10 | up1=ma1+N3*bdma/4; 11 | up2=ma1+N3*bdma/2; 12 | up3=ma1+N3*bdma*3/4; 13 | up4=ma1+N3*bdma; 14 | 15 | dw1=ma1-N3*bdma/4; 16 | dw2=ma1-N3*bdma/2; 17 | dw3=ma1-N3*bdma*3/4; 18 | dw4=ma1-N3*bdma; 19 | 20 | Plot9( ma1 ) ; 21 | 22 | Plot1( up1) ; 23 | Plot2( up2) ; 24 | Plot3( up3) ; 25 | Plot4( up4) ; 26 | Plot5( dw1) ; 27 | Plot6( dw2) ; 28 | Plot7( dw3) ; 29 | Plot8( dw4) ; 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | //////////////////////////////////// 39 | 40 | 41 | input: 42 | 43 | N1(1000), 44 | 45 | N2(200), 46 | 47 | N3(20); 48 | 49 | var: 50 | 51 | ma1(0), 52 | 53 | bd(0), 54 | 55 | bdma(0), 56 | 57 | up1(0), 58 | 59 | up2(0), 60 | 61 | up3(0), 62 | 63 | up4(0), 64 | 65 | dw1(0), 66 | 67 | dw2(0), 68 | 69 | dw3(0), 70 | 71 | dw4(0); 72 | 73 | 74 | ma1=Average(close,n1); 75 | 76 | bd=High-Low; 77 | bdma=Average(bd,n2); 78 | 79 | up1=ma1+N3*bdma/4; 80 | up2=ma1+N3*bdma/2; 81 | up3=ma1+N3*bdma*3/4; 82 | up4=ma1+N3*bdma; 83 | 84 | dw1=ma1-N3*bdma/4; 85 | dw2=ma1-N3*bdma/2; 86 | dw3=ma1-N3*bdma*3/4; 87 | dw4=ma1-N3*bdma; 88 | 89 | var: 90 | 91 | Intrabarpersist Int CurrStatus (0); 92 | 93 | CurrStatus = Marketposition*CurrentShares; 94 | 95 | ///=======================Up-Sell==------------------// 96 | if Close Cross Above ma1 then begin 97 | buy("ma1B") 1 shares next bar at market; 98 | end; 99 | 100 | if CurrStatus = 1 then begin 101 | SellShort("up1S") 1 shares next bar at up1 limit; 102 | end; 103 | 104 | if CurrStatus = -1 then begin 105 | SellShort("up2S") 2 shares next bar at up2 limit; 106 | end; 107 | 108 | if CurrStatus = -3 then begin 109 | BuytoCover("up2SP") From Entry("up2S") 2 shares next bar at up1 limit; 110 | end; 111 | 112 | if CurrStatus = -3 then begin 113 | SellShort("up3S") 4 shares next bar at up3 limit; 114 | end; 115 | 116 | if CurrStatus = -7 then begin 117 | BuytoCover("up3SP") From Entry("up3S") 4 shares next bar at up2 limit; 118 | end; 119 | 120 | if Close Cross Above Up4 and Marketposition < 0 then begin 121 | BuytoCover("CAll") all Shares next bar at market; 122 | end; 123 | 124 | //if marketposition = 1 and Close Cross Under dw1 then begin 125 | // sell all shares next bar at market; 126 | //end; 127 | ///======================DW_Buy----------------------// 128 | if Close Cross Under ma1 then begin 129 | SellShort("ma1S") 1 shares next bar at market; 130 | end; 131 | 132 | if CurrStatus = -1 then begin 133 | Buy("dw1B") 1 shares next bar at dw1 limit; 134 | end; 135 | 136 | if CurrStatus = 1 then begin 137 | Buy("dw2B") 2 shares next bar at dw2 limit; 138 | end; 139 | 140 | if CurrStatus = 3 then begin 141 | Sell("dw2SP") From Entry("dw2B") 2 shares next bar at dw1 limit; 142 | end; 143 | 144 | if CurrStatus = 3 then begin 145 | Buy("dw3B") 4 shares next bar at dw3 limit; 146 | end; 147 | 148 | if CurrStatus = 7 then begin 149 | Sell("dw3SP") From Entry("dw3B") 4 shares next bar at dw2 limit; 150 | end; 151 | 152 | if Close Cross Under dw4 and Marketposition > 0 then begin 153 | Sell("CAllS") all Shares next bar at market; 154 | end; 155 | 156 | //if marketposition = 1 and Close Cross Under dw1 then begin 157 | // sell all shares next bar at market; 158 | //end; -------------------------------------------------------------------------------- /Multicharts HegeAlalsy MaginCal.txt: -------------------------------------------------------------------------------- 1 | Inputs: 2 | 3 | OpenMainshares(1); 4 | 5 | var: 6 | ATRLength( 14 ); 7 | 8 | variables: 9 | VolatityPointEveryDay1( 0 ), 10 | VolatityPointEveryDay2( 0 ), 11 | VolatityPointEveryDay3( 0 ), 12 | VolatityPointEveryDay4( 0 ), 13 | VolatityPointEveryDay5( 0 ), 14 | VolatityPointEveryDay6( 0 ), 15 | 16 | MainProductOpenShresLossProfitEveryDay(0), 17 | 18 | Data2Shares(0), 19 | Data3Shares(0), 20 | Data4Shares(0), 21 | Data5Shares(0), 22 | Data6Shares(0); 23 | 24 | VolatityPointEveryDay1= AvgTrueRange( ATRLength ) of data1; 25 | VolatityPointEveryDay2= AvgTrueRange( ATRLength ) of data2; 26 | VolatityPointEveryDay3= AvgTrueRange( ATRLength ) of data3; 27 | VolatityPointEveryDay4= AvgTrueRange( ATRLength ) of data4; 28 | VolatityPointEveryDay5= AvgTrueRange( ATRLength ) of data5; 29 | VolatityPointEveryDay6= AvgTrueRange( ATRLength ) of data6; 30 | 31 | MainProductOpenShresLossProfitEveryDay= VolatityPointEveryDay1*Bigpointvalue*OpenMainshares; 32 | 33 | Data2Shares= MainProductOpenShresLossProfitEveryDay/((bigpointvalue of data2) * VolatityPointEveryDay2); 34 | Data3Shares= MainProductOpenShresLossProfitEveryDay/((bigpointvalue of data3) * VolatityPointEveryDay3); 35 | Data4Shares= MainProductOpenShresLossProfitEveryDay/((bigpointvalue of data4) * VolatityPointEveryDay4); 36 | Data5Shares= MainProductOpenShresLossProfitEveryDay/((bigpointvalue of data5) * VolatityPointEveryDay5); 37 | Data6Shares= MainProductOpenShresLossProfitEveryDay/((bigpointvalue of data6) * VolatityPointEveryDay6); 38 | 39 | var: 40 | stringTips(""), 41 | // 42 | // 43 | string1(""), 44 | string2(""), 45 | string3(""), 46 | string4(""), 47 | string5(""), 48 | string6(""), 49 | // 50 | // 51 | stringAllMagin(""); 52 | 53 | 54 | var: 55 | 56 | magin1(0), 57 | magin2(0), 58 | magin3(0), 59 | magin4(0), 60 | magin5(0), 61 | magin6(0); 62 | 63 | magin1 = OpenMainshares* (bigpointvalue of data1)* (Close of data1)*0.1; 64 | magin2= Data2Shares* (bigpointvalue of data2)* (Close of data2)*0.1; 65 | magin3= Data3Shares* (bigpointvalue of data3)* (Close of data3)*0.1; 66 | magin4= Data4Shares* (bigpointvalue of data4)* (Close of data4)*0.1; 67 | magin5= Data5Shares* (bigpointvalue of data5)* (Close of data5)*0.1; 68 | magin6= Data6Shares* (bigpointvalue of data6)* (Close of data6)*0.1; 69 | 70 | stringTips = "One Mini PortFoilo Products Matching Concept,Defult 10% Magin"; 71 | 72 | string1 = symbol + " :" + numtostr(OpenMainshares,2) + " Magin Need: " + NumToStr(magin1 ,2); 73 | string2 = symbol of data2 + " :" + numtostr(Data2Shares,2)+ " Magin Need: " + NumToStr(magin2 ,2); 74 | string3 = symbol of data3 + " :" + numtostr(Data3Shares,2)+ " Magin Need: " + NumToStr(magin3 ,2); 75 | string4 = symbol of data4 + " :" + numtostr(Data4Shares,2)+ " Magin Need: " + NumToStr(magin4 ,2); 76 | string5= symbol of data5 + " :" + numtostr(Data5Shares,2)+ " Magin Need: " + NumToStr(magin5 ,2); 77 | string6= symbol of data6 + " :" + numtostr(Data6Shares,2)+ " Magin Need: " + NumToStr(magin6 ,2); 78 | 79 | stringAllMagin = "All One Min-Folio Magin Need: " + NumToStr(magin1 + magin2 + magin3 + magin4 + magin5 + magin6,2); 80 | 81 | 82 | if LastBarOnChart then begin 83 | 84 | if Text_Exist(Value60) then text_delete(Value60); 85 | Value60 = Text_New(0, 0, 0, stringTips +"\n" + "\n" +string1 +"\n" + string2 +"\n"+string3+"\n"+string4+"\n"+string5+"\n"+string6 + "\n" + "\n" +stringAllMagin ); 86 | 87 | Text_Float(Value60, 5, 75); 88 | text_setcolor(Value60,Red); 89 | text_setsize(Value60,16); 90 | Text_SetAttribute(Value60,1,True); 91 | Text_SetFontName(Value60,"Verdana"); 92 | end; 93 | 94 | //int(niShared," ",VolatityPointEveryDay2," ",MainProductOpenShresLossProfitEveryDay," ",bigpointvalue of data2," ",VolatityPointEveryDay3); 95 | -------------------------------------------------------------------------------- /HANYU-Hedge.txt: -------------------------------------------------------------------------------- 1 | variables: 2 | 3 | Length( 14 ), 4 | 5 | OverBought( 80 ) , 6 | 7 | OverSold( 20 ) ; 8 | 9 | 10 | variables: 11 | 12 | var0( 0 ), 13 | 14 | var1( 0 ), 15 | 16 | var2( 0 ), 17 | 18 | var3( 0 ) ; 19 | 20 | 21 | var: 22 | CrossAlert(0); 23 | 24 | variables: 25 | 26 | Double AfStep( 0.02 ), 27 | 28 | Double AfLimit( 0.2 ) ; 29 | 30 | variables: 31 | 32 | var10( 0 ), 33 | 34 | var11( 0 ), 35 | 36 | var12( 0 ), 37 | 38 | var13( 0 ) ; 39 | 40 | /////////==================================================/////////////// 41 | variables: 42 | 43 | Int SeriesLossRecord(0), 44 | Double OpenBPrice(0), 45 | Double OpenSPrice(0), 46 | Double LastProfit(0); 47 | 48 | var: 49 | MP(0), 50 | LastTradeProfitPoint(0), 51 | Quality(0), 52 | TradeCount(0); 53 | 54 | MP = marketposition; 55 | 56 | Value2 = ParabolicSAR( AfStep, AfLimit, var10, var11, var12, var13 ) ; 57 | 58 | if close Cross Above var11 then begin 59 | OpenBPrice= Close; 60 | LastProfit = OpenSPrice - OpenBPrice; 61 | if LastProfit < 0 then begin 62 | SeriesLossRecord = SeriesLossRecord + 1; 63 | Value1 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 64 | text_setsize(Value1,20); 65 | text_setcolor(Value1,Red); 66 | end 67 | else begin 68 | SeriesLossRecord = 0; 69 | Value2 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 70 | text_setsize(Value2,20); 71 | text_setcolor(Value2,Red); 72 | end; 73 | end; 74 | 75 | if close Cross Under var11 then begin 76 | OpenSPrice= Close; 77 | LastProfit = OpenSPrice- OpenBPrice; 78 | if LastProfit < 0 then begin 79 | SeriesLossRecord = SeriesLossRecord + 1; 80 | Value3 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 81 | text_setsize(Value3,20); 82 | text_setcolor(Value3,Red); 83 | end 84 | else begin 85 | SeriesLossRecord = 0; 86 | Value4 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 87 | text_setsize(Value4,20); 88 | text_setcolor(Value4,Red); 89 | end; 90 | end; 91 | 92 | 93 | //Value5 = text_new(date,time,(high+low)/2,numtostr(SeriesLossRecord,0)); 94 | 95 | Value88= Stochastic( H, L, C, Length, 3, 3, 1, var0, var1, var2, var3 ) ; 96 | 97 | var: 98 | 99 | Sys(0); 100 | 101 | if SeriesLossRecord >= 1 then begin 102 | 103 | Sys = 1; 104 | 105 | end; 106 | 107 | if SeriesLossRecord = 0 then begin 108 | 109 | Sys = 0; 110 | 111 | if MarketPosition = -1 and CurrentBar > 2 and var2 crosses Above var3 then begin 112 | buytocover ( "S-Over" ) this bar at Close ; 113 | Sys = 0; 114 | end; 115 | 116 | if MarketPosition = 1 and CurrentBar > 2 and var2 crosses Under var3 then begin 117 | Sell ( "B-Over" ) this bar at Close ; 118 | Sys = 0; 119 | end; 120 | 121 | end; 122 | 123 | if Sys = 1 then begin 124 | 125 | condition1 = MarketPosition = 0 and CurrentBar > 2 and var2 crosses under var3 and var2 > 70 And var11 <= OpenBPrice; 126 | condition10 = MarketPosition = 0 and ExitName(1) = "PB" and var2 > 70 and barssinceexit(1) <=5 ; 127 | condition2 = MarketPosition = -1 and CurrentBar > 2 and var2 crosses Above var3 ; 128 | condition22 = MarketPosition = -1 and var2 = 100 ; 129 | 130 | if condition1 Or Condition10 then begin 131 | SellShort ( "S" ) this bar at Close ; 132 | end; 133 | 134 | if condition2 Or Condition22 then begin 135 | buytocover ( "PS" ) this bar at Close; 136 | //Sys = 0; 137 | end; 138 | 139 | condition11 = MarketPosition = 0 and CurrentBar > 2 and var2 crosses above var3 and var2 < 30 And var11 >= OpenSPrice; 140 | condition21 = MarketPosition = 0 and ExitName(1) = "PS" and var2 < 30 and barssinceexit(1) <=3 ; 141 | condition32 = MarketPosition = 1 and var2 = 0 ; 142 | 143 | condition12 = MarketPosition = 1 and CurrentBar > 2 and var2 cross under var3; 144 | 145 | if condition11 Or Condition21 then begin 146 | Buy ( "B" ) this bar at Close ; 147 | end; 148 | 149 | if condition12 Or condition32 then begin 150 | sell ( "PB" ) this bar at Close ; 151 | //Sys = 0; 152 | end; 153 | 154 | end; 155 | 156 | //print("date:",date," ","time:",time," ","SeriesLossRecord :",SeriesLossRecord ," Sys : ",Sys ); 157 | 158 | -------------------------------------------------------------------------------- /HANYU-Hedge-New.txt: -------------------------------------------------------------------------------- 1 | variables: 2 | 3 | Length( 14 ), 4 | 5 | OverBought( 80 ) , 6 | 7 | OverSold( 20 ) ; 8 | 9 | 10 | variables: 11 | 12 | var0( 0 ), 13 | 14 | var1( 0 ), 15 | 16 | var2( 0 ), 17 | 18 | var3( 0 ) ; 19 | 20 | 21 | var: 22 | CrossAlert(0); 23 | 24 | variables: 25 | 26 | Double AfStep( 0.02 ), 27 | 28 | Double AfLimit( 0.2 ) ; 29 | 30 | variables: 31 | 32 | var10( 0 ), 33 | 34 | var11( 0 ), 35 | 36 | var12( 0 ), 37 | 38 | var13( 0 ) ; 39 | 40 | /////////==================================================/////////////// 41 | variables: 42 | 43 | Int SeriesLossRecord(0), 44 | Double OpenBPrice(0), 45 | Double OpenSPrice(0), 46 | Double LastProfit(0); 47 | 48 | var: 49 | MP(0), 50 | LastTradeProfitPoint(0), 51 | Quality(0), 52 | TradeCount(0); 53 | 54 | MP = marketposition; 55 | 56 | Value2 = ParabolicSAR( AfStep, AfLimit, var10, var11, var12, var13 ) ; 57 | 58 | if close Cross Above var11 then begin 59 | OpenBPrice= Close; 60 | LastProfit = OpenSPrice - OpenBPrice; 61 | if LastProfit < 0 then begin 62 | SeriesLossRecord = SeriesLossRecord + 1; 63 | Value1 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 64 | text_setsize(Value1,20); 65 | text_setcolor(Value1,Red); 66 | end 67 | else begin 68 | SeriesLossRecord = 0; 69 | Value2 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 70 | text_setsize(Value2,20); 71 | text_setcolor(Value2,Red); 72 | end; 73 | end; 74 | 75 | if close Cross Under var11 then begin 76 | OpenSPrice= Close; 77 | LastProfit = OpenSPrice- OpenBPrice; 78 | if LastProfit < 0 then begin 79 | SeriesLossRecord = SeriesLossRecord + 1; 80 | Value3 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 81 | text_setsize(Value3,20); 82 | text_setcolor(Value3,Red); 83 | end 84 | else begin 85 | SeriesLossRecord = 0; 86 | Value4 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 87 | text_setsize(Value4,20); 88 | text_setcolor(Value4,Red); 89 | end; 90 | end; 91 | 92 | 93 | //Value5 = text_new(date,time,(high+low)/2,numtostr(SeriesLossRecord,0)); 94 | 95 | Value88= Stochastic( H, L, C, Length, 3, 3, 1, var0, var1, var2, var3 ) ; 96 | 97 | var: 98 | 99 | Sys(0); 100 | 101 | if SeriesLossRecord >= 1 then begin 102 | 103 | Sys = 1; 104 | 105 | end; 106 | 107 | if SeriesLossRecord = 0 then begin 108 | 109 | Sys = 0; 110 | 111 | if MarketPosition = -1 and CurrentBar > 2 and var2 crosses Above var3 then begin 112 | buytocover ( "S-Over" ) this bar at Close ; 113 | Sys = 0; 114 | end; 115 | 116 | if MarketPosition = 1 and CurrentBar > 2 and var2 crosses Under var3 then begin 117 | Sell ( "B-Over" ) this bar at Close ; 118 | Sys = 0; 119 | end; 120 | 121 | end; 122 | 123 | if Sys = 1 then begin 124 | 125 | condition1 = MarketPosition = 0 and CurrentBar > 2 and var2 crosses under var3 and var2 > 70 And var11 <= OpenBPrice; 126 | condition10 = MarketPosition = 0 and ExitName(1) = "PB" and var2 > 70 and barssinceexit(1) <=5 ; 127 | condition2 = MarketPosition = -1 and CurrentBar > 2 and var2 crosses Above var3 ; 128 | condition22 = MarketPosition = -1 and var2 = 100 ; 129 | 130 | if condition1 Or Condition10 then begin 131 | SellShort ( "S" ) this bar at Close ; 132 | end; 133 | 134 | if condition2 Or Condition22 then begin 135 | buytocover ( "PS" ) this bar at Close; 136 | //Sys = 0; 137 | end; 138 | 139 | condition11 = MarketPosition = 0 and CurrentBar > 2 and var2 crosses above var3 and var2 < 30 And var11 >= OpenSPrice; 140 | condition21 = MarketPosition = 0 and ExitName(1) = "PS" and var2 < 30 and barssinceexit(1) <=3 ; 141 | condition32 = MarketPosition = 1 and var2 = 0 ; 142 | 143 | condition12 = MarketPosition = 1 and CurrentBar > 2 and var2 cross under var3; 144 | 145 | if condition11 Or Condition21 then begin 146 | Buy ( "B" ) this bar at Close ; 147 | end; 148 | 149 | if condition12 Or condition32 then begin 150 | sell ( "PB" ) this bar at Close ; 151 | //Sys = 0; 152 | end; 153 | 154 | end; 155 | 156 | 157 | inputs: 158 | 159 | AccountName("1999_2-0009904"), 160 | Commmison(1), 161 | Slipise(5); 162 | 163 | var: 164 | TradeNum(0), 165 | NoCommisonSlipiseAccountSeries(0), 166 | HasCommisonSlipiseAccountSeries(0); 167 | 168 | MP = marketposition; 169 | 170 | if ((MP[1] <> 0 ) and MP = 0) OR (MP[1] =1 and MP = -1) OR (MP[1] =-1 and MP = 1) then begin 171 | NoCommisonSlipiseAccountSeries = NoCommisonSlipiseAccountSeries+ positionprofit(1); 172 | HasCommisonSlipiseAccountSeries = HasCommisonSlipiseAccountSeries + positionprofit(1) - (Commmison * MinMove*(1/PriceScale) + Slipise * MinMove*(1/PriceScale))*bigpointvalue; 173 | TradeNum = TradeNum + 1; 174 | //print(Date," ",Time," ",symbolname,"_",NoCommisonSlipiseAccountSeries ,"_",HasCommisonSlipiseAccountSeries ,"_", MinMove*(1/PriceScale)," ",bigpointvalue," ",TradeNum); 175 | end; 176 | 177 | var: 178 | 179 | RealOpenPrice(0); 180 | 181 | if LastBarOnChart then begin 182 | 183 | if Text_Exist(Value60) then text_delete(Value60); 184 | 185 | RealOpenPrice = GetPositionAveragePrice(Symbol,AccountName); 186 | 187 | Value60 = Text_New(0, 0, 0,Symbol + newline + "NoCommisionSliplise: " + Numtostr(NoCommisonSlipiseAccountSeries,2) + newline + 188 | "HasCommisonSlipiseAccountSeries: " + Numtostr(HasCommisonSlipiseAccountSeries ,2) + newline + "TradeNum: " + NumToStr(TradeNum ,2) + newline + "TicChengben(Include In-Out): " 189 | + NumToStr(Commmison+Slipise,1) + "Tick =" + NumToStr((Commmison+Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newline + "--Commision: " + NumToStr(Commmison,1) + "Tick =" + NumToStr((Commmison)* MinMove*(1/PriceScale)*bigpointvalue,2) + 190 | NewLine + "--Slipise: " + NumToStr(Slipise,1) + "Tick =" + NumToStr((Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newLine+ "Now-Silipse: " + NumToStr(absvalue(Close - Close[1])/MinMove*(1/PriceScale)*bigpointvalue,2) + " RealNowOpen-Silpse: " + 191 | NumToStr(absvalue(RealOpenPrice - EntryPrice(0))/MinMove*(1/PriceScale)*bigpointvalue,2) 192 | + newline + "ChartNowOpenPrice: " + NumToStr(EntryPrice(0),2) + newline + "RealAccountOpenPrice: " + NumToStr(RealOpenPrice,2)); 193 | 194 | Text_Float(Value60, 5, 75); 195 | text_setcolor(Value60,Red); 196 | text_setsize(Value60,8); 197 | Text_SetAttribute(Value60,1,True); 198 | Text_SetFontName(Value60,"Verdana"); 199 | 200 | end; 201 | 202 | -------------------------------------------------------------------------------- /HANYU-Trend.txt: -------------------------------------------------------------------------------- 1 | [IntrabarOrderGeneration = false] 2 | 3 | inputs: 4 | OpenShares(1), 5 | SymbolColor(0); 6 | 7 | // variables: 8 | 9 | // bool IsParSystem_Switch(true), 10 | 11 | // HighLimitPrice(0), 12 | 13 | // LowLimitPrice(0); 14 | 15 | 16 | variables: 17 | 18 | AfStep( 0.02 ), 19 | 20 | AfLimit( 0.2 ) ; 21 | 22 | variables: 23 | 24 | var0( 0 ), 25 | 26 | var1( 0 ), 27 | 28 | var2( 0 ), 29 | 30 | var3( 0 ) ; 31 | 32 | //////////////////======Recode-And Destroy The Series Loss Construct And then Go-on=========/////////////// 33 | 34 | variables: 35 | 36 | Int SeriesLossRecord(0), 37 | Double OpenBPrice(0), 38 | Double OpenSPrice(0), 39 | Double LastProfit(0); 40 | 41 | if TradeCount >= 1 then begin 42 | 43 | if close Cross Above var1 then begin 44 | OpenBPrice= Close; 45 | LastProfit = OpenSPrice - OpenBPrice; 46 | if LastProfit < 0 then begin 47 | SeriesLossRecord = SeriesLossRecord + 1; 48 | end 49 | else begin 50 | SeriesLossRecord = 0; 51 | end; 52 | end; 53 | 54 | if close Cross Under var1 then begin 55 | OpenSPrice= Close; 56 | LastProfit = OpenSPrice- OpenBPrice; 57 | if LastProfit < 0 then begin 58 | SeriesLossRecord = SeriesLossRecord + 1; 59 | end 60 | else begin 61 | SeriesLossRecord = 0; 62 | end; 63 | end; 64 | end; 65 | 66 | 67 | 68 | //print("date:",date," ","time:",time," ","SeriesLossRecord :",SeriesLossRecord ); 69 | 70 | // variables: 71 | 72 | // String DEBUGSTR("DEBUG"), 73 | 74 | // Int DEBUGINTPTR(0); 75 | 76 | //////////////////////////////=====================================/////////////////////////////////////// 77 | //if IsParSystem_Switch = true then begin 78 | 79 | Value1 = ParabolicSAR( AfStep, AfLimit, var0, var1, var2, var3 ) ; 80 | 81 | if close cross above var1 then begin 82 | Buy ( "ParB" ) OpenShares shares this bar at Close; 83 | end; 84 | 85 | if close cross under var1 then begin 86 | Sell Short ( "ParS" ) OpenShares shares this bar at Close; 87 | end; 88 | 89 | // //if Entry-Par.in And next it goes other direction,out the open High-Low system; 90 | // if (entryname(0) = "ParB" Or entryname(0) = "ProfitCoverS" ) and marketposition = 1 then begin 91 | // if Close < EntryPrice(0) then begin 92 | // Sell ("PParB") all shares this Bar at Close; 93 | // HighLimitPrice = Highest(high,Barssinceentry(0)+1); 94 | // LowLimitPrice = Lowest(Low,7); 95 | // IsParSystem_Switch = false; 96 | // DEBUGSTR = "PParB-Action"; 97 | // end; 98 | // end; 99 | 100 | // if (entryname(0) = "ParS" Or entryname(0) = "ProfitCoverB" ) and marketposition = -1 then begin 101 | // if Close > EntryPrice(0) then begin 102 | // BuyToCover ("PParS") all shares this Bar at Close; 103 | // HighLimitPrice = Highest(high,7);//nearest - highest price 104 | // LowLimitPrice= Lowest(Low,Barssinceentry(0)+1);//near 105 | // IsParSystem_Switch = false; 106 | // DEBUGSTR = "PParS-Action"; 107 | // DEBUGINTPTR = BarNumber + MaxBarsBack; 108 | // end; 109 | // end; 110 | //end; 111 | 112 | //////////////////////////////=====================================/////////////////////////////////////// 113 | // if IsParSystem_Switch = false and HighLimitPrice <> 0 and LowLimitPrice <> 0 then begin 114 | 115 | // //============= 116 | // if Close Cross Above HighLimitPrice then Buy ( "HB" ) this bar at close; 117 | // if Close Cross Under LowLimitPrice then SellShort ( "LS" ) this bar at close; 118 | 119 | // //============= 120 | // if entryname(0) = "HB" and marketposition = 1 then begin 121 | // if Close < HighLimitPrice then begin 122 | // Sell ("PB") all shares this Bar at Close; 123 | // HighLimitPrice = Highest(high,3);//Modify Highest-Break Price 124 | // end; 125 | // end; 126 | 127 | // if entryname(0) = "LS" and marketposition = -1 then begin 128 | // if Close > LowLimitPrice then begin 129 | // BuyToCover ("PS") all shares this Bar at Close; 130 | // LowLimitPrice= Lowest(Low,3);//Modify Lowest-Break Price 131 | // end; 132 | // end; 133 | 134 | // //============= 135 | // if entryname(0) = "HB" and marketposition = 1 and ( Openpositionprofit >= 0 ) then begin 136 | // if Close Cross Under var1 then begin 137 | // SellShort ( "ProfitCoverB" ) this bar at close; 138 | // IsParSystem_Switch = true; 139 | // end; 140 | // end; 141 | 142 | 143 | // if entryname(0) = "LS" and marketposition = -1 and ( Openpositionprofit >= 0 ) then begin 144 | // if Close Cross Above var1 then begin 145 | // Buy ( "ProfitCoverS" ) this bar at close; 146 | // IsParSystem_Switch = true; 147 | // end; 148 | // end; 149 | // end; 150 | 151 | 152 | if LastBarOnChart then begin 153 | 154 | if Text_Exist(Value60) then text_delete(Value60); 155 | 156 | Value60 = Text_New(Date,Time,High, symbol); 157 | 158 | if SymbolColor = 0 then text_setcolor(Value60,Red); 159 | if SymbolColor = 1 then text_setcolor(Value60,Green); 160 | if SymbolColor = 2 then text_setcolor(Value60,White); 161 | if SymbolColor = 3 then text_setcolor(Value60,Yellow); 162 | if SymbolColor = 4 then text_setcolor(Value60,Blue); 163 | if SymbolColor = 5 then text_setcolor(Value60,DarkCyan); 164 | if SymbolColor = 6 then text_setcolor(Value60,DarkMagenta); 165 | if SymbolColor = 7 then text_setcolor(Value60,LightGray); 166 | 167 | text_setsize(Value60,16); 168 | Text_SetAttribute(Value60,1,True); 169 | Text_SetFontName(Value60,"Verdana"); 170 | end; 171 | 172 | 173 | var: 174 | MP(0), 175 | LastTradeProfitPoint(0), 176 | Quality(0), 177 | TradeCount(0); 178 | 179 | MP = marketposition; 180 | 181 | if (MP[1] = 0 OR MP[1] = -1) and MP = 1 then begin 182 | Quality = Quality + positionprofit(1); 183 | TradeCount = TradeCount + 1; 184 | //print(symbolname,"_",Date,"_",Time,"_",Quality,"_",positionprofit(1),"_",TradeCount); 185 | end; 186 | 187 | if (MP[1] = 0 OR MP[1] = 1) and MP = -1 then begin 188 | Quality = Quality + positionprofit(1); 189 | TradeCount = TradeCount+1; 190 | //print(symbolname,"_",Date,"_",Time,"_",Quality,"_",positionprofit(1),"_",TradeCount); 191 | end; 192 | 193 | // print("date:",date," ","time:",time," ","IsParSystem_Switch:",IsParSystem_Switch," ","DEBUGSTR :",DEBUGSTR," ","DEBUGINTPTR :",DEBUGINTPTR ); 194 | -------------------------------------------------------------------------------- /MACD-Hedge (2).txt: -------------------------------------------------------------------------------- 1 | inputs: 2 | 3 | Length(14); 4 | 5 | inputs: 6 | 7 | FastLength( 12 ), 8 | 9 | SlowLength( 26 ), 10 | 11 | MACDLength( 9 ) ; 12 | 13 | variables: 14 | 15 | var0( 0 ), 16 | 17 | var1( 0 ), 18 | 19 | var2( 0 ), 20 | 21 | var3( 0 ); 22 | 23 | var: 24 | CrossAlert(0); 25 | 26 | 27 | 28 | /////////==================================================/////////////// 29 | variables: 30 | 31 | Int SeriesLossRecord(0), 32 | Double OpenBPrice(0), 33 | Double OpenSPrice(0), 34 | Double LastProfit(0); 35 | 36 | var: 37 | MP(0), 38 | LastTradeProfitPoint(0), 39 | Quality(0), 40 | TradeCount(0); 41 | 42 | MP = marketposition; 43 | 44 | 45 | var: 46 | var10(0), 47 | var11(0), 48 | var12(0), 49 | var12Pre(0); 50 | 51 | var10 = MACD( Close, FastLength, SlowLength ) ; 52 | var11 = XAverage( var10, MACDLength ) ; 53 | var12 = var10 - var11 ; 54 | var12Pre = MACD( Close, FastLength, SlowLength )[1] - XAverage( var10, MACDLength )[1]; 55 | 56 | if var12Pre < 0 and var12 > 0 then begin 57 | OpenBPrice= Close; 58 | LastProfit = OpenSPrice - OpenBPrice; 59 | if LastProfit < 0 then begin 60 | SeriesLossRecord = SeriesLossRecord + 1; 61 | Value1 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 62 | text_setsize(Value1,20); 63 | text_setcolor(Value1,Red); 64 | end 65 | else begin 66 | SeriesLossRecord = 0; 67 | Value2 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 68 | text_setsize(Value2,20); 69 | text_setcolor(Value2,Red); 70 | end; 71 | end; 72 | 73 | if var12Pre > 0 and var12 < 0 then begin 74 | OpenSPrice= Close; 75 | LastProfit = OpenSPrice- OpenBPrice; 76 | if LastProfit < 0 then begin 77 | SeriesLossRecord = SeriesLossRecord + 1; 78 | Value3 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 79 | text_setsize(Value3,20); 80 | text_setcolor(Value3,Red); 81 | end 82 | else begin 83 | SeriesLossRecord = 0; 84 | Value4 = text_new(date,time,high,numtostr(SeriesLossRecord,0)); 85 | text_setsize(Value4,20); 86 | text_setcolor(Value4,Red); 87 | end; 88 | end; 89 | 90 | 91 | var: 92 | bool CrossAbove(True), 93 | bool CrossUnder(false); 94 | CrossAbove = var12Pre < 0 and var12 > 0 ; 95 | CrossUnder = var12Pre > 0 and var12 < 0 ; 96 | 97 | 98 | print(date," ",time," ",var12," ",var12Pre," ", 0," ",SeriesLossRecord," ",LastProfit," ",CrossAbove," ",CrossUnder); 99 | 100 | //Value5 = text_new(date,time,(high+low)/2,numtostr(SeriesLossRecord,0)); 101 | 102 | Value88= Stochastic( H, L, C, Length, 3, 3, 1, var0, var1, var2, var3 ) ; 103 | 104 | var: 105 | 106 | Sys(0); 107 | 108 | if SeriesLossRecord >= 1 then begin 109 | 110 | Sys = 1; 111 | 112 | end; 113 | 114 | if SeriesLossRecord = 0 then begin 115 | 116 | Sys = 0; 117 | 118 | if MarketPosition = -1 and CurrentBar > 2 and var2 crosses Above var3 then begin 119 | buytocover ( "S-Over" )next bar at Market ; 120 | Sys = 0; 121 | end; 122 | 123 | if MarketPosition = 1 and CurrentBar > 2 and var2 crosses Under var3 then begin 124 | Sell ( "B-Over" )next bar at Market ; 125 | Sys = 0; 126 | end; 127 | 128 | end; 129 | 130 | if Sys = 1 then begin 131 | 132 | condition1 = MarketPosition = 0 and CurrentBar > 2 and var2 crosses under var3 and var2 > 70 And var11 <= OpenBPrice; 133 | condition10 = MarketPosition = 0 and ExitName(1) = "PB" and var2 > 70 and barssinceexit(1) <=5 ; 134 | condition2 = MarketPosition = -1 and CurrentBar > 2 and var2 crosses Above var3 ; 135 | condition22 = MarketPosition = -1 and var2 = 100 ; 136 | 137 | if condition1 Or Condition10 then begin 138 | SellShort ( "S" ) next bar at Market ; 139 | end; 140 | 141 | if condition2 Or Condition22 then begin 142 | buytocover ( "PS" ) next bar at Market ; 143 | //Sys = 0; 144 | end; 145 | 146 | condition11 = MarketPosition = 0 and CurrentBar > 2 and var2 crosses above var3 and var2 < 30 And var11 >= OpenSPrice; 147 | condition21 = MarketPosition = 0 and ExitName(1) = "PS" and var2 < 30 and barssinceexit(1) <=3 ; 148 | condition32 = MarketPosition = 1 and var2 = 0 ; 149 | 150 | condition12 = MarketPosition = 1 and CurrentBar > 2 and var2 cross under var3; 151 | 152 | if condition11 Or Condition21 then begin 153 | Buy ( "B" ) next bar at Market ; 154 | end; 155 | 156 | if condition12 Or condition32 then begin 157 | sell ( "PB" ) next bar at Market ; 158 | //Sys = 0; 159 | end; 160 | 161 | end; 162 | 163 | 164 | inputs: 165 | 166 | AccountName("1999_2-0009904"), 167 | Commmison(1), 168 | Slipise(5); 169 | 170 | var: 171 | TradeNum(0), 172 | NoCommisonSlipiseAccountSeries(0), 173 | HasCommisonSlipiseAccountSeries(0); 174 | 175 | MP = marketposition; 176 | 177 | if ((MP[1] <> 0 ) and MP = 0) OR (MP[1] =1 and MP = -1) OR (MP[1] =-1 and MP = 1) then begin 178 | NoCommisonSlipiseAccountSeries = NoCommisonSlipiseAccountSeries+ positionprofit(1); 179 | HasCommisonSlipiseAccountSeries = HasCommisonSlipiseAccountSeries + positionprofit(1) - (Commmison * MinMove*(1/PriceScale) + Slipise * MinMove*(1/PriceScale))*bigpointvalue; 180 | TradeNum = TradeNum + 1; 181 | //print(Date," ",Time," ",symbolname,"_",NoCommisonSlipiseAccountSeries ,"_",HasCommisonSlipiseAccountSeries ,"_", MinMove*(1/PriceScale)," ",bigpointvalue," ",TradeNum); 182 | end; 183 | 184 | var: 185 | 186 | RealOpenPrice(0); 187 | 188 | if LastBarOnChart then begin 189 | 190 | if Text_Exist(Value60) then text_delete(Value60); 191 | 192 | RealOpenPrice = GetPositionAveragePrice(Symbol,AccountName); 193 | 194 | Value60 = Text_New(0, 0, 0,Symbol + newline + "NoCommisionSliplise: " + Numtostr(NoCommisonSlipiseAccountSeries,2) + newline + 195 | "HasCommisonSlipiseAccountSeries: " + Numtostr(HasCommisonSlipiseAccountSeries ,2) + newline + "TradeNum: " + NumToStr(TradeNum ,2) + newline + "TicChengben(Include In-Out): " 196 | + NumToStr(Commmison+Slipise,1) + "Tick =" + NumToStr((Commmison+Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newline + "--Commision: " + NumToStr(Commmison,1) + "Tick =" + NumToStr((Commmison)* MinMove*(1/PriceScale)*bigpointvalue,2) + 197 | NewLine + "--Slipise: " + NumToStr(Slipise,1) + "Tick =" + NumToStr((Slipise)* MinMove*(1/PriceScale)*bigpointvalue,2) + newLine+ "Now-Silipse: " + NumToStr(absvalue(Close - Close[1])/MinMove*(1/PriceScale)*bigpointvalue,2) + " RealNowOpen-Silpse: " + 198 | NumToStr(absvalue(RealOpenPrice - EntryPrice(0))/MinMove*(1/PriceScale)*bigpointvalue,2) 199 | + newline + "ChartNowOpenPrice: " + NumToStr(EntryPrice(0),2) + newline + "RealAccountOpenPrice: " + NumToStr(RealOpenPrice,2)); 200 | 201 | Text_Float(Value60, 5, 75); 202 | text_setcolor(Value60,Red); 203 | text_setsize(Value60,8); 204 | Text_SetAttribute(Value60,1,True); 205 | Text_SetFontName(Value60,"Verdana"); 206 | 207 | end; 208 | 209 | -------------------------------------------------------------------------------- /Multicharts-Trend-New2.txt: -------------------------------------------------------------------------------- 1 | [IntrabarOrderGeneration = false] 2 | 3 | inputs: 4 | 5 | int OpenShares(1), 6 | 7 | int ISSeriesLossAndThenMovingProfitTargrt(0); 8 | 9 | 10 | variables: 11 | 12 | AfStep( 0.02 ), 13 | 14 | AfLimit( 0.2 ); 15 | 16 | variables: 17 | 18 | var0( 0 ), 19 | 20 | var1( 0 ), 21 | 22 | var2( 0 ), 23 | 24 | var3( 0 ) ; 25 | 26 | 27 | /////////==================================================/////////////// 28 | var: 29 | 30 | SeriesLossCount(0), 31 | SeriesLossMoney(0), 32 | MP(0); 33 | 34 | MP = MarketPosition; 35 | 36 | if MP <> 0 and BarsSinceEntry(0) = 1 then begin 37 | if positionprofit(1) <= 0 then begin 38 | SeriesLossCount = SeriesLossCount + 1; 39 | SeriesLossMoney = SeriesLossMoney + positionprofit(1); 40 | end; 41 | 42 | if positionprofit(1) >= 0 then begin 43 | SeriesLossCount = 0; 44 | SeriesLossMoney = 0; 45 | end; 46 | 47 | Value4 = text_new(date,time,high,numtostr(SeriesLossCount ,0)); 48 | text_setsize(Value4,20); 49 | text_setcolor(Value4,Red); 50 | 51 | if SeriesLossCount >= 2 then begin 52 | //value2 = text_new_bn(Barnumber,high,"Has Profit:" + newline + "-BS MovProfit Persist!" + newline + "-Break MoveProfit Persist!"); 53 | print(date," ",time," ",symbol," ","seriesloss is above 2,please start persist mode."); 54 | //text_setcolor(value2 ,White); 55 | //text_setsize(value2 ,8); 56 | //text_setfontname(value2 ,"Verdana"); 57 | end; 58 | end; 59 | /////////==================================================/////////////// 60 | 61 | //if SeriesLossCount >= 2 then begin 62 | // ISSeriesLossAndThenMovingProfitTargrtVar = true; 63 | //end; 64 | 65 | /////////==================================================/////////////// 66 | 67 | Value1 = ParabolicSAR( AfStep, AfLimit, var0, var1, var2, var3 ) ; 68 | 69 | if close cross above var1 then begin 70 | Buy ( "B" ) OpenShares shares this bar at Close; 71 | print(date," ",time," ",symbol," ","buy"); 72 | end; 73 | 74 | if close cross under var1 then begin 75 | Sell Short ( "S" ) OpenShares shares this bar at Close; 76 | print(date," ",time," ",symbol," ","sellshort"); 77 | end; 78 | 79 | 80 | if EntryName(0) = "B" and marketposition = 1 and Close < EntryPrice(0) then begin 81 | Sell("BEven") all shares this bar at Close; 82 | print(date," ",time," ",symbol," ","b-breakeven"); 83 | end; 84 | 85 | if EntryName(0) = "S" and marketposition = -1 and Close > EntryPrice(0) then begin 86 | BuytoCover("SEven") all shares this bar at Close; 87 | print(date," ",time," ",symbol," ","s-breakeven"); 88 | end; 89 | 90 | /////////==================================================/////////////// 91 | /////////==================================================/////////////// 92 | 93 | var: 94 | 95 | DoubleBuyEntryLine(0), 96 | DoubleSelEntryLine(0); 97 | 98 | if MP = 0 and ExitName(1) = "BEven" then begin 99 | 100 | value10 = BarsSinceEntry(1); 101 | DoubleBuyEntryLine = Highest(High,value10)[1]; 102 | 103 | if MarketPosition = 0 and Close Cross Above DoubleBuyEntryLine then begin 104 | Buy("UpBreak") this bar at Close; 105 | print(date," ",time," ",symbol," ","upbreak-b-again"); 106 | end; 107 | 108 | end; 109 | 110 | if MP = 0 and ExitName(1) = "SEven" then begin 111 | value20 = BarsSinceEntry(1); 112 | DoubleSelEntryLine= Lowest(Low,value20)[1]; 113 | 114 | if MarketPosition = 0 and Close Cross Under DoubleSelEntryLine then begin 115 | SellShort("DownBreak") this bar at Close; 116 | print(date," ",time," ",symbol," ","downbreak-s-again"); 117 | end; 118 | end; 119 | 120 | /////////==================================================/////////////// 121 | /////////==================================================/////////////// 122 | ///////////////////////////////////////////////////////////////////////////////////////////////// 123 | //////////////////////////////////////////////////////////////////////////////////////////////// 124 | 125 | if LastBarOnChart then begin 126 | //Notify Symbol-info 127 | //notify Param 128 | //notify trading-strategyinfo 129 | 130 | if Text_Exist(value55) = true then text_delete(value55); 131 | 132 | //value55 = text_new_bn(Barnumber,high,Symbol + newline + 133 | //"LastProfit: " + Numtostr(positionprofit(1) ,2) + newline + 134 | //"BigPointValue: " + Numtostr(BigpointValue ,2) + " MinMove:" + NumToStr(MinMove*(1/PriceScale),2) + " MinMove-Value(MinM*BigValue): " + NumToStr(MinMove*(1/PriceScale)*bigpointvalue,2) + newline + newline + 135 | //"%OpenShares%: " + NumToStr(Openshares,1) + newline + 136 | //"%ISSeriesLossAndThenMovingProfitTargrt% " + NumToStr(ISSeriesLossAndThenMovingProfitTargrt,1) + newline + 137 | //"%SeriesLossNum%: " + NumToStr(SeriesLossCount ,1) + newline + 138 | //"%LossRenkoMoney%: " + NumToStr(SeriesLossMoney,2) + " & LossRenkoNum:" + NumToStr(SeriesLossmoney/(absvalue(Open[1]-Close[1])*Bigpointvalue),2) + NewLine + NewLine+ 139 | //"Persist Strategy: " + NewLine + 140 | //"When Loss Two-Three Nums,Then Go into Persist Mode to Persist DrawBack!"); 141 | 142 | text_setcolor(value55,Green); 143 | text_setsize(value55,10); 144 | text_setfontname(value55,"Verdana"); 145 | end; 146 | 147 | 148 | /////////==================================================/////////////// 149 | /////////==================================================/////////////// 150 | ////////////////////////////////////////////////////////////////////////// 151 | ////////////////////////////////////////////////////////////////////////// 152 | Inputs: 153 | MaxProfitRenko(3), 154 | DrawBackRenko(1); 155 | 156 | var: 157 | intrabarpersist WinMax(0), 158 | intrabarpersist MaxProfit(0), 159 | intrabarpersist WinNow(0); 160 | 161 | var: 162 | 163 | varRenko(0); 164 | 165 | varRenko = AbsValue(Open[1] - Close[1]); 166 | 167 | if ISSeriesLossAndThenMovingProfitTargrt = 1 then begin 168 | 169 | if marketposition<>0 then begin 170 | if marketposition = 1 then begin 171 | WinMax=( close- entryprice(0) )/ varRenko ; 172 | if(WinMax>MaxProfit) then MaxProfit=WinMax; 173 | if(MaxProfit<>0) then WinNow= MaxProfit - WinMax; 174 | end; 175 | 176 | if ( Marketposition = 1 and MaxProfit >= MaxProfitRenko and WinNow >= DrawBackRenko and openpositionprofit > 0 ) then begin 177 | Sell ("SDrawDown_Out") this bar at Close; 178 | print(date," ",time," ",symbol," ","b-drawdownout"); 179 | WinMax = 0; 180 | MaxProfit = 0; 181 | WinNow = 0; 182 | end; 183 | end; 184 | 185 | if marketposition<>0 then begin 186 | if marketposition = -1 then begin 187 | WinMax=( EntryPrice(0) - Close )/ varRenko ; 188 | if(WinMax > MaxProfit) then MaxProfit = WinMax; 189 | if(MaxProfit<> 0) then WinNow = MaxProfit-WinMax; 190 | end; 191 | 192 | if ( Marketposition = -1 and MaxProfit >= MaxProfitRenko and WinNow >= DrawBackRenko and openpositionprofit > 0 ) then begin 193 | BuytoCover ("BDrawDown_Out")this bar at Close; 194 | print(date," ",time," ",symbol," ","s-drawdownout"); 195 | WinMax = 0; 196 | MaxProfit = 0; 197 | WinNow = 0; 198 | end; 199 | end; 200 | end; 201 | ////////////////////////////////////////////////////////////////////////// 202 | ////////////////////////////////////////////////////////////////////////// 203 | 204 | -------------------------------------------------------------------------------- /Multicharts Tl_New Demo.txt: -------------------------------------------------------------------------------- 1 | [IntrabarOrderGeneration = false] 2 | inputs: 3 | FastLength( 1 ), 4 | SlowLength( 1380 ), 5 | DayHighPositionSwitchLine(0), 6 | DayLowPositionSwitchLine(0); 7 | 8 | tl_delete(Value30); 9 | Value30 = tl_new(Date-3,100,DayHighPositionSwitchLine,Date + 3,2359,DayHighPositionSwitchLine); 10 | tl_setcolor(Value30,Red); 11 | tl_setsize(Value30,5); 12 | 13 | tl_delete(Value50); 14 | Value50= tl_new(Date-3,100,DayLowPositionSwitchLine,Date + 3,2359,DayLowPositionSwitchLine); 15 | tl_setcolor(Value50,Blue); 16 | tl_setsize(Value50,5); 17 | 18 | variables: 19 | MALong( 0 ), 20 | MAShort( 0 ); 21 | MAShort= AverageFC( Close, FastLength ) ; 22 | MALong = AverageFC( Close, SlowLength ) ; 23 | 24 | var: 25 | valueBuy(0), 26 | valueSell(0); 27 | 28 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 29 | var: 30 | sDate(date), 31 | sTime(time), 32 | sPrice(Close); 33 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | inputs: 35 | PriceH( High ), 36 | PriceL( Low ), 37 | PriceC( Close ), 38 | StochLength( 14 ), 39 | SmoothingLength1( 3 ), 40 | SmoothingLength2( 3 ), 41 | SmoothingType( 1 ), 42 | OverSold( 30 ), 43 | OverBought( 70) ; 44 | 45 | variables: 46 | var10( 0 ), 47 | var11( 0 ), 48 | var12( 0 ), 49 | var13( 0 ) ; 50 | 51 | var: 52 | barFlag(0); 53 | 54 | Value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1, 55 | SmoothingLength2, SmoothingType, var10, var11, var12, var13 ) ; 56 | 57 | var: 58 | bool ConditionHighAvgBuy(false), 59 | bool ConditionLowAvgSel(false); 60 | 61 | ConditionHighAvgBuy = var12 crosses over var13 and var12 <= OverSold and MAShort >= MALong ; 62 | ConditionLowAvgSel = var12 crosses under var13 and var12 >= OverBought and MAShort <= MALong ; 63 | 64 | var: 65 | bool ConditionFenDuanCoverPoint1(false), 66 | bool ConditionFenDuanCoverPoint2(false); 67 | 68 | ConditionFenDuanCoverPoint1= var12 crosses under var13 and var12 >= OverBought and MAShort >= MALong ; 69 | ConditionFenDuanCoverPoint2= var12 crosses over var13 and var12 <= OverSold and MAShort <= MALong ; 70 | 71 | var: 72 | BuyNearLowest(0), 73 | SelNearHigest(0); 74 | 75 | var: 76 | OutHigh(0), 77 | OutLow(0), 78 | SingleCanGoHighLowerIn(0); 79 | ////////////// 80 | if ConditionHighAvgBuy then begin 81 | Value10=Arw_New(Date,Time,High,False); 82 | Alert(Text("Up")); 83 | buy ("HBuy-1-2") next bar at market; 84 | SingleCanGoHighLowerIn = 1; 85 | BuyNearLowest = Lowest(Low,3); 86 | end; 87 | 88 | if ConditionLowAvgSel then begin 89 | Value10=Arw_New(Date,Time,High,True); 90 | sellshort ("LSell-1-2") next bar at market; 91 | SingleCanGoHighLowerIn = 1; 92 | Alert(Text("Down")) ; 93 | SelNearHigest = Highest(high,3); 94 | end; 95 | 96 | ///////////////////////////////////////////////////////////////////////////////// 97 | ///////////////////////////////////////////////////////////////////////////////// 98 | if marketposition = 1 and entryname = "HBuy-1-2" then begin 99 | sell("BDownEntryPrice") all shares next bar at BuyNearLowest stop; 100 | end; 101 | 102 | if marketposition = -1 and entryname = "LSell-1-2" then begin 103 | buytocover("SHighEntryPrice") all shares next bar at SelNearHigest stop; 104 | end; 105 | ///////////////////////////////////////////////////////////////////////////////// 106 | ///////////////////////////////////////////////////////////////////////////////// 107 | 108 | if ConditionFenDuanCoverPoint1 then begin 109 | sell ("HS") next bar at market; 110 | Alert(Text("HS")); 111 | OutHigh = Highest(high,2); 112 | end; 113 | 114 | if ConditionFenDuanCoverPoint2 then begin 115 | buytocover ("LS") next bar at market; 116 | Alert(Text("LS")); 117 | OutLow = Lowest(Low,2); 118 | end; 119 | 120 | if Close >= OutHigh and OutHigh <> 0 and SingleCanGoHighLowerIn = 1 then begin 121 | buy ("HigherB-1-2") next bar at market; 122 | Alert(Text("HigherB-1-2")); 123 | end; 124 | 125 | if Close <= OutLow and OutLow <> 0 and SingleCanGoHighLowerIn = 1 then begin 126 | sellshort ("LowerS-1-2") next bar at market; 127 | Alert(Text("LowerS-1-2")); 128 | end; 129 | 130 | if MAShort Cross above MALong then begin 131 | if marketposition = -1 then begin 132 | buytocover("MACRossBCover") all shares next bar at market; 133 | Alert(Text("MACRossBCover")); 134 | 135 | end; 136 | end; 137 | 138 | if MAShort Cross Under MALong then begin 139 | if marketposition = 1 then begin 140 | sell("MACRossSCover") all shares next bar at market; 141 | Alert(Text("MACRossSCover")); 142 | 143 | end; 144 | end; 145 | 146 | if MAShort Cross above MALong or MAShort Cross Under MALong then begin 147 | OutHigh = 0; 148 | OutLow = 0; 149 | SingleCanGoHighLowerIn = 0; 150 | end; 151 | 152 | // 153 | //if marketposition <>0 and barssinceentry >=1 and openpositionprofit <= 0 then begin 154 | // if marketposition = 1 then begin 155 | // sell ("3K-No-ProfitS") all shares next bar at market; 156 | // end; 157 | 158 | // if marketposition = -1 then begin 159 | // buytocover ("3K-No-ProfitB") all shares next bar at market; 160 | // end; 161 | //end; 162 | 163 | // 164 | if ConditionFenDuanCoverPoint1 then begin 165 | tl_delete(Value20); 166 | Value11=Arw_New(Date,Time,High,True); 167 | arw_setcolor(Value11,White); 168 | //Value8=Text_New(Date,Time,High,"Ot:" + NumToStr(Highest(high,4),2)); 169 | Value20 = tl_new(Date,100,Highest(high,4),Date,2359,Highest(high,4)); 170 | end; 171 | 172 | if ConditionFenDuanCoverPoint2 then begin 173 | tl_delete(Value21); 174 | Value12=Arw_New(Date,Time,High,false); 175 | arw_setcolor(Value12,White); 176 | //Value9=Text_New(Date,Time,High,"Ot:" + NumToStr(Lowest(low,4),2)); 177 | Value21=tl_new(Date,100,Lowest(low,4),date,2359,Lowest(low,4)); 178 | end; 179 | 180 | /////////////// 181 | Variable: 182 | IntraBarPersist MP(100), 183 | IntraBarPersist preId(0), 184 | IntraBarPersist CommID(0); 185 | 186 | var: 187 | ClolorLoopNum(0); 188 | 189 | MP = marketposition; 190 | 191 | if MP <>0 and LastBarOnChart then begin 192 | 193 | For ClolorLoopNum =0 To 7 Begin 194 | 195 | if Random(10) > 1000 then begin 196 | Text_Delete(preId); 197 | CommID = CommID + 1; 198 | preId= text_new_bn(currentbar + 17 ,High,"1-2K,Decision Left"); 199 | text_setcolor(preId,red); 200 | text_setfontname(preID,"Verdana"); 201 | 202 | print("symbol:",symbol,"date:",date,"time:",time,"MP:",MP,"preId:",preId,"CommID:",CommID,"2468"); 203 | 204 | end; 205 | 206 | if Random(10) < 0 then begin 207 | Text_Delete(preId); 208 | CommID = CommID + 1; 209 | preId= text_new_bn(currentbar + 17 ,High,"1-2K,Decision Left"); 210 | text_setcolor(preId,blue); 211 | text_setfontname(preID,"Verdana"); 212 | 213 | print("symbol:",symbol,"date:",date,"time:",time,"MP:",MP,"preId:",preId,"CommID:",CommID,"1357"); 214 | 215 | end; 216 | End; 217 | 218 | if ClolorLoopNum = 7 then ClolorLoopNum = 0; 219 | end; 220 | 221 | if marketposition = 0 then begin 222 | CommID = 0; 223 | preId = 0; 224 | Text_Delete(preId); 225 | end; 226 | 227 | if LastBarOnChart then begin 228 | 229 | if Text_Exist(Value60) then text_delete(Value60); 230 | 231 | Value60 = Text_New(0, 0, 0, symbol); 232 | Text_Float(Value60, 5, 75); 233 | text_setcolor(Value60,Red); 234 | text_setsize(Value60,16); 235 | Text_SetAttribute(Value60,1,True); 236 | Text_SetFontName(Value60,"Verdana"); 237 | end; 238 | 239 | //print("symbol:",symbol,"date:",date,"time:",time,"MP:",MP,"preId:",preId,"CommID:",CommID,"ALL"); 240 | 241 | --------------------------------------------------------------------------------