답변완료
함수요청
안녕하세요?
data1, 국내선물 1분봉으로 일중거래를 하고자 합니다.
data2는 특정 지수의 일봉을 놓고
- 매수 : 완성 익봉 시가 진입(1,2,3 and조건)
1. data1의 당일 시가가 data1의 전영업일 종가 대비 상승 출발
2. data2의 전일 등락률이 0보다 큼(전영업일에 상승 마감)
3. data1의 당일 시가가 data2의 종가의 값 보다 작음
- 매도 : 완성 익봉 시가 진입(1,2,3 and조건)
1. data1의 당일 시가가 data1의 전영업일 종가 대비 하락 출발
2. data2의 전일 등락률이 0보다 작음(전영업일에 하락 마감)
3. data1의 당일 시가가 data2의 종가의 값 보다 큼
- 매수청산 : 완성 익봉 시가 진입([1 and 2 and 3] or [1 and 2 and 4] 조건)
1. data1 현재가가 100ma 이탈시
2. data1 현재가가 150ma 이탈시
3. data2 전영업일 고점돌파시
4. data2 전영업일 저점이탈시
- 매도청산 : 완성 익봉 시가 진입([1 and 2 and 3] or [1 and 2 and 4] 조건)
1. data1 현재가가 100ma 돌파시
2. data1 현재가가 150ma 돌파시
3. data2 전영업일 고점돌파시
4. data2 전영업일 저점이탈시
- 강제청산 : 15시 20분
- 진입횟수 제어 : 매수든 매도든 진입기준 1회
상기의 논리상으로 스크립트 작성 부탁드립니다.
감사합니다.
2023-01-19
1030
글번호 165559
시스템
답변완료
수식 문의드립니다.
안녕하세요,
2023년 01월 25일 부터 주식시장 호가단위가 다음과 같이 변경된다고 하는데요.
2000 미만 : 1원
2000~5000 : 5원
5000~20000 : 10원
20000~50000 : 50원
50000~200000 : 100원
200000~500000 : 500원
500000 이상 : 1000원
(거래소/코스닥 동일)
위 사항을 적용하려면 이전에 알려주신 상한가 수식을 어떻게 변경해야 할까요?
--------------------------------------------------------------------
var : 상한가(0), UpLimit(0);
var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0);
if date >= 19981207 then {
if date < 20050328 && CodeCategory() == 2 then
UpLimit = (BP[0] * 1.12);
Else if date >= 20050328 and date < 20150615 Then
UpLimit = (BP[0] * 1.15);
Else
UpLimit = (BP[0] * 1.30);
if CodeCategory() == 2 then
{
if date >= 20030721 then
{
up1 = int(UpLimit/100+0.00001)*100;
up2 = int(UpLimit/100+0.00001)*100;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
else
{
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/10+0.00001)*10;
up7 = int(UpLimit/1+0.00001)*1;
}
}
Else
{
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
if CodeCategory() == 1 || CodeCategory() == 2 then
{
if sdate < 20101004 Then
{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up6);
}
Else
{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up7);
}
}
else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF
상한가 = up6;
}
}
--------------------------------------------------------------------
답변 부탁드립니다.
감사합니다.
2023-01-19
929
글번호 165554
검색
답변완료
Nadaraya-Watson Envelope
MT4 지표인데 예스로 변환 부탁드립니다.
//+------------------------------------------------------------------+
//| nd.mq5 |
//| Copyright 2022, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Grasco."
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 2
#property indicator_type1 DRAW_LINE
#property indicator_type2 DRAW_LINE
#property indicator_width1 2
#property indicator_width2 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_applied_price PRICE_WEIGHTED
//--- input parameters
input int Length=500; // Bars Count
input int Bandwidth=17; // Bandwidth
input double Multiplayer=1.5;
// n = get the bar index
//--- indicator buffers
double ExtUpBuffer[];
double ExtDownBuffer[];
double ExtCABuffer[];
double y[]; // for calculation
int ExtBarsHandle;
int k = 2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(){
//--- indicator buffers mapping
SetIndexBuffer(0,ExtUpBuffer);
SetIndexBuffer(1,ExtDownBuffer);
SetIndexBuffer(2,y,INDICATOR_CALCULATIONS);
//---
IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//--- sets first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0);
PlotIndexGetInteger(1,PLOT_DRAW_BEGIN,0);
PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0.0);
PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0.0);
//--- name for DataWindow
string short_name=StringFormat("Nadraya",Length);
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
PlotIndexSetString(0,PLOT_LABEL,short_name+" Upper");
PlotIndexSetString(1,PLOT_LABEL,short_name+" Lower");
ExtBarsHandle = iMA(_Symbol,_Period,Length,0,MODE_EMA,PRICE_WEIGHTED);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
//---
if(IsStopped()) return 0;
int calculated=BarsCalculated(ExtBarsHandle);
if(rates_total<calculated) return(0);
if(rates_total<Length)
return(0);
int copyBars = 0;
if (prev_calculated>rates_total || prev_calculated<=0){
copyBars = rates_total;
}
else{
copyBars = rates_total-prev_calculated;
if(prev_calculated>0) copyBars++;
}
int start=prev_calculated-1;
if(start<Length)
start=Length;
double sum_e = 0.0;
for(int i=rates_total-Length; i<rates_total && !IsStopped(); i++){
double sum = 0.0;
double sumw= 0.0;
for(int j = rates_total-Length;j<rates_total-1;j++){
double w = MathExp(-(MathPow(i-j,2)/(Bandwidth*Bandwidth*2)));
sum += price[j]*w;
sumw += w;
}
double y2 = sum/sumw;
sum_e += (MathAbs(price[i]-y2));
y[i] = y2;
}
double mae = sum_e/Length*Multiplayer;
for(int i=rates_total-Length+1; i<rates_total && !IsStopped(); i++){
double y2 = y[i];
double y1 = y[i-1];
ExtUpBuffer[i]=y2+mae;
ExtDownBuffer[i]=y2-mae;
//Print(mae);
//Print(y[i]);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
2023-01-19
1239
글번호 165552
시스템